Crate tick_counter
source ·Expand description
Hardware-based tick counters for high-precision benchmarks
x86_64
- executes RDTSC CPU instruction to read the time-stamp counter.AArch64
- reads value of the CNTVCT_EL0 counter-timer register.
Basic usage
let start = tick_counter::start();
// ... lines of code to benchmark
let elapsed_ticks = tick_counter::stop() - start;
println!("Number of elapsed ticks: {}", elapsed_ticks);
Basic usage with helper
use tick_counter::TickCounter;
let tick_counter = TickCounter::current();
// ... lines of code to benchmark
let elapsed_ticks = tick_counter.elapsed();
println!("Number of elapsed ticks: {}", elapsed_ticks);
Structs
- TickCounter helper
Enums
- The origin of the provided counter frequency
Functions
- Returns a frequency of tick counter in hertz (Hz)
- Returns a precision of tick counters in nanoseconds
- Returns a current value of the tick counter to use as a staring point
- Returns a current value of the tick counter to use as a stopping point
- Returns a measured value of tick counter frequency on
x86_64
architecture in hertz (Hz) - Returns a tick counter and CPUID values based on Intel CPU’s
RDTSCP
instruction - Returns a current value of the tick counter based on Intel CPU’s
RDTSC
instruction