mirror of
https://github.com/status-im/nim-dagger.git
synced 2025-02-08 12:54:41 +00:00
formatting
This commit is contained in:
parent
e527ebf7da
commit
b43fd950bc
@ -5,6 +5,7 @@ import std/os
|
|||||||
import std/options
|
import std/options
|
||||||
import std/importutils
|
import std/importutils
|
||||||
import std/[times, os, strutils]
|
import std/[times, os, strutils]
|
||||||
|
import std/terminal
|
||||||
|
|
||||||
|
|
||||||
import pkg/questionable
|
import pkg/questionable
|
||||||
@ -30,16 +31,19 @@ import codex/slots/backends/helpers
|
|||||||
import create_circuits
|
import create_circuits
|
||||||
|
|
||||||
template benchmark(benchmarkName: string, blk: untyped) =
|
template benchmark(benchmarkName: string, blk: untyped) =
|
||||||
var ts = 0.0
|
let nn = 5
|
||||||
let nn = 3
|
var vals = newSeqOfCap[float](nn)
|
||||||
for i in 1..nn:
|
for i in 1..nn:
|
||||||
block:
|
block:
|
||||||
let t0 = epochTime()
|
let t0 = epochTime()
|
||||||
`blk`
|
`blk`
|
||||||
let elapsed = epochTime() - t0
|
let elapsed = epochTime() - t0
|
||||||
ts += elapsed / i.toFloat
|
vals.add elapsed
|
||||||
let elapsedStr = ts.formatFloat(format = ffDecimal, precision = 3)
|
|
||||||
echo "CPU Time [", benchmarkName, "] ", "avg(", nn, "): ", elapsedStr, "s"
|
var elapsedStr = ""
|
||||||
|
for v in vals:
|
||||||
|
elapsedStr &= ", " & v.formatFloat(format = ffDecimal, precision = 3)
|
||||||
|
stdout.styledWriteLine(fgGreen, "CPU Time [", benchmarkName, "] ", "avg(", $nn, "): ", elapsedStr, " s")
|
||||||
|
|
||||||
proc setup(
|
proc setup(
|
||||||
circuitDir: string, name: string,
|
circuitDir: string, name: string,
|
||||||
@ -118,7 +122,7 @@ when isMainModule:
|
|||||||
ncells: 512, # number of cells in this slot
|
ncells: 512, # number of cells in this slot
|
||||||
)
|
)
|
||||||
|
|
||||||
for i in 1..3:
|
for i in 1..10:
|
||||||
args.nsamples = i
|
args.nsamples = i
|
||||||
echo "\nbenchmarking args: ", args
|
echo "\nbenchmarking args: ", args
|
||||||
args.runBenchmark()
|
args.runBenchmark()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user