Csaba Kiraly 73f90c2dc5
fix benchmark template
Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
2022-01-17 11:26:11 -06:00

10 lines
307 B
Nim

import times, strutils
export strutils.formatFloat
template benchmark*(benchmarkName: string, code: untyped) =
let t0 = epochTime()
code
let elapsed = epochTime() - t0
let elapsedStr = elapsed.formatFloat(format = ffDecimal, precision = 3)
echo "CPU Time [", benchmarkName, "] ", elapsedStr, "s"