mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-09 22:06:21 +00:00
22 lines
395 B
Nim
22 lines
395 B
Nim
|
import
|
||
|
std/[times, stats]
|
||
|
|
||
|
template withTimer*(stats: var RunningStat, body: untyped) =
|
||
|
# TODO unify timing somehow
|
||
|
let start = cpuTime()
|
||
|
|
||
|
block:
|
||
|
body
|
||
|
|
||
|
let stop = cpuTime()
|
||
|
stats.push stop - start
|
||
|
|
||
|
template withTimerRet*(stats: var RunningStat, body: untyped): untyped =
|
||
|
let start = cpuTime()
|
||
|
let tmp = block:
|
||
|
body
|
||
|
let stop = cpuTime()
|
||
|
stats.push stop - start
|
||
|
|
||
|
tmp
|