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
TickCounter helper

Enums§

TickCounterFrequencyBase
The origin of the provided counter frequency

Functions§

frequency
Returns a frequency of tick counter in hertz (Hz)
precision_nanoseconds
Returns a precision of tick counters in nanoseconds
start
Returns a current value of the tick counter to use as a staring point
stop
Returns a current value of the tick counter to use as a stopping point
x86_64_measure_frequency
Returns a measured value of tick counter frequency on x86_64 architecture in hertz (Hz)
x86_64_processor_id
Returns a tick counter and CPUID values based on Intel CPU’s RDTSCP instruction
x86_64_tick_counter
Returns a current value of the tick counter based on Intel CPU’s RDTSC instruction