Skip to content

Commit

Permalink
improve tstrfloats_bench
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour committed May 14, 2021
1 parent f331368 commit 5024b89
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tests/benchmarks/tstrfloats_bench.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#[
on OSX:
nim r -d:danger tests/benchmarks/tstrfloats_bench.nim
nim r -d:danger -d:numIter:100_000_00 tests/benchmarks/tstrfloats_bench.nim
("toStringSprintf", "genFloatCast", 11.956240000000001)
("toStringSprintf", "genFloatConf", 1.581176000000001)
("toStringDragonbox", "genFloatCast", 0.1652149999999999)
Expand All @@ -9,13 +9,14 @@ nim r -d:danger tests/benchmarks/tstrfloats_bench.nim

import std/[times, strfloats]

const numIter {.intdefine.} = 10

template gen(algo, genFloat) =
proc main {.gensym.} =
let n = 100_000_00
var buf: array[strFloatBufLen, char]
var c = 0
let t = cpuTime()
for i in 0..<n:
for i in 0..<numIter:
let x = genFloat(i)
let m = algo(buf, x)
when false: # debugging
Expand Down

0 comments on commit 5024b89

Please sign in to comment.