CPU Clock Timer

Example

Timing is as simple as

julia> LIKWID.Timer.@timeit sleep(1)
(clock = 1.0021697811990014, cycles = 3307182468)

Apart from the time it took to execute sleep(1) (clock) one also gets the number of CPU clock cycles corresponding to the time interval (cycles).

Note that the macro usage above is essentially equivalent to the following manual sequence

julia> LIKWID.Timer.init()
true

julia> t_start = LIKWID.Timer.start_clock()
TimerData(cycles start: 60459589412988386, cycles stop: 0)

julia> sleep(1)

julia> t_stop = LIKWID.Timer.stop_clock(t_start)
TimerData(cycles start: 60459589412988386, cycles stop: 60459592861915014)

julia> LIKWID.Timer.get_clock(t_stop)
1.045121729122075

julia> LIKWID.Timer.get_clock_cycles(t_stop)
3448926580

julia> LIKWID.Timer.finalize()

Index

Functions

LIKWID.Timer.stop_clockFunction
stop_clock(timer::LibLikwid.TimerData) -> newtimer::LibLikwid.TimerData

Stop the clock and return a LibLikwid.TimerData object including the start and stop timestamps. The input timer should be the output of Timer.start_clock().

source
LIKWID.Timer.timeitFunction
timeit(f)

Time the given function f using Timer.start_clock, Timer.stop_clock, etc. under the hood. Automatically initializes and finalizes the timer module.

Examples

julia> LIKWID.Timer.timeit() do
           sleep(1)
       end
(clock = 1.0008815780376372, cycles = 3603224844)
source