You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 18, 2019. It is now read-only.
Currently it is difficult to isolate setup code from the part of the code that one really wants to measure. Silly example:
procsilly(n: int) {.measure: [100, 10000, 1000000].} =let s =newSeq[int](n)
let l = s.len # <-- measure just this?doAssert l == n
The measurement is obviously completely dominated by the setup code let s = newSeq[int](n). A work-around is to initialize data in the surrounding scope and close over the data variables. But this prevents to parametrize the benchmark and there seems to be an overhead of copying the data to the benchmark. There is also the general overhead:
procoverhead(b: bool) {.measure: [true].} =doAssert b
which is ~4 cycles for me.
What about the following API:
procsilly(n: int): Measure {.measure: [100, 10000, 1000000].} =let s =newSeq[int](n)
timed:
let l = s.len # <-- measure just this?doAssert l == n
Where timed is a template that internally measure the time/cycles before and after executing its body and updating result with the corresponding time/cycle deltas. This would allow to separate the setup & optimization prevention code from the actual benchmark code.
Currently it is difficult to isolate setup code from the part of the code that one really wants to measure. Silly example:
The measurement is obviously completely dominated by the setup code
let s = newSeq[int](n). A work-around is to initialize data in the surrounding scope and close over the data variables. But this prevents to parametrize the benchmark and there seems to be an overhead of copying the data to the benchmark. There is also the general overhead:which is ~4 cycles for me.
What about the following API:
Where
timedis a template that internally measure the time/cycles before and after executing itsbodyand updatingresultwith the corresponding time/cycle deltas. This would allow to separate the setup & optimization prevention code from the actual benchmark code.