Skip to content

intel/intel-cpu-frequency-library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Intel® CPU Frequency Library

A simple library to sample the frequency on single CPU cores. The frequency is sampled by computing the ratio of actual performed cycles to the cycles that have passed in base frequency according to rdtsc.

Build

As buildsystem we use cmake:

mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/path/to/install_dir ..
cmake --build . --config Release
cmake --install .

Usage

To include the library in CMake:

find_package(cpufreqlib   
              HINTS 
              /path/to/install_dir/cmake)
target_link_libraries(your_target
                      PRIVATE cpufreqlib)             

To sample the current frequency of the current core call:

#include <cpufreqlib.h>
// ...
float base_freq = get_base_cpu_freq_hz(); // get base frequency
// ...
float freq = get_curr_cpu_freq_hz(); // get current frequency

Note that sampling on two SMT threads of the same physical CPU might lead to false measurements

About

A small C++ library to sample the frequency on x86 CPUs

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published