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
LIKWID.Timer.finalizeLIKWID.Timer.get_clockLIKWID.Timer.get_clock_cyclesLIKWID.Timer.get_cpu_clockLIKWID.Timer.get_cpu_clock_currentLIKWID.Timer.initLIKWID.Timer.start_clockLIKWID.Timer.stop_clockLIKWID.Timer.timeit
Functions
LIKWID.Timer.init — FunctionInitialize LIKWIDs timer module
LIKWID.Timer.finalize — FunctionClose and finalize LIKWIDs timer module
LIKWID.Timer.get_cpu_clock — FunctionReturn the CPU clock determined at Timer.init().
LIKWID.Timer.get_cpu_clock_current — FunctionReturn the current CPU clock read from sysfs
LIKWID.Timer.start_clock — FunctionStart the clock and return a LibLikwid.TimerData object including the start timestamp.
LIKWID.Timer.stop_clock — Functionstop_clock(timer::LibLikwid.TimerData) -> newtimer::LibLikwid.TimerDataStop 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().
LIKWID.Timer.get_clock — Functionget_clock(timer::LibLikwid.TimerData)Return the measured interval in seconds for the given timer. The input timer should be the output of Timer.stop_clock.
LIKWID.Timer.get_clock_cycles — Functionget_clock_cycles(timer::LibLikwid.TimerData)Return the measured interval in cycles for the given timer. The input timer should be the output of Timer.stop_clock.
LIKWID.Timer.timeit — Functiontimeit(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)LIKWID.Timer.@timeit — MacroConvenience macro for Timer.timeit.
Examples
julia> LIKWID.Timer.@timeit sleep(1)
(clock = 1.0008815780376372, cycles = 3603224844)