Skip to content

Commit 94a1e73

Browse files
committed
measure cputime and realtime
1 parent 37af582 commit 94a1e73

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/execution.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,21 +314,24 @@ function generate_benchmark_definition(eval_module, out_vars, setup_vars, core,
314314
$(setup)
315315
__evals = __params.evals
316316
__gc_start = Base.gc_num()
317-
__start_time = time_ns()
317+
__start_realtime = Timers.realtime()
318+
__start_cputime = Timers.cputime()
318319
__return_val = $(invocation)
319320
for __iter in 2:__evals
320321
$(invocation)
321322
end
322-
__sample_time = time_ns() - __start_time
323+
__sample_realtime = Timers.realtime() - __start_realtime
324+
__sample_cputime = Timers.cputime() - __start_cputime
323325
__gcdiff = Base.GC_Diff(Base.gc_num(), __gc_start)
324326
$(teardown)
325-
__time = max((__sample_time / __evals) - __params.overhead, 0.001)
327+
__realtime = max((__realsample_time / __evals) - __params.overhead, 0.001)
328+
__cputime = max((__cpusample_time / __evals) - __params.overhead, 0.001)
326329
__gctime = max((__gcdiff.total_time / __evals) - __params.overhead, 0.0)
327330
__memory = Int(fld(__gcdiff.allocd, __evals))
328331
__allocs = Int(fld(__gcdiff.malloc + __gcdiff.realloc +
329332
__gcdiff.poolalloc + __gcdiff.bigalloc,
330333
__evals))
331-
return __time, __gctime, __memory, __allocs, __return_val
334+
return __realtime, __cputime, __gctime, __memory, __allocs, __return_val
332335
end
333336
function $BenchmarkTools.sample(b::$BenchmarkTools.Benchmark{$(id)},
334337
p::$BenchmarkTools.Parameters = b.params)

src/parameters.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,14 @@ end
7575
@noinline nullfunc() = nothing
7676

7777
@noinline function overhead_sample(evals)
78-
start_time = time_ns()
78+
start_realtime = Timers.realtime()
79+
start_cputime = Timers.cputime()
7980
for _ in 1:evals
8081
nullfunc()
8182
end
82-
sample_time = time_ns() - start_time
83-
return (sample_time / evals)
83+
sample_realtime = Timers.realtime() - start_realtime
84+
sample_cputime = Timers.cputtime() - start_cputime
85+
return (sample_realtime / evals, sample_cputime / evals)
8486
end
8587

8688
function estimate_overhead()

0 commit comments

Comments
 (0)