-rw-r--r-- 1655 libcpucycles-20230105/doc/man/cpucycles.3 raw
.\" Automatically generated by Pandoc 2.9.2.1 .\" .TH "cpucycles" "3" "" "" "" .hy .SS NAME .PP cpucycles - count CPU cycles .SS SYNOPSIS .IP .nf \f[C] #include <cpucycles.h> long long count = cpucycles(); long long persecond = cpucycles_persecond(); const char *implementation = cpucycles_implementation(); \f[R] .fi .PP Link with \f[C]-lcpucycles\f[R]. Old systems may also need \f[C]-lrt\f[R]. .SS DESCRIPTION .PP \f[C]cpucycles()\f[R] returns an estimate for the number of CPU cycles that have occurred since an unspecified time in the past (perhaps system boot, perhaps program startup). .PP Accessing true cycle counters can be difficult on some CPUs and operating systems. \f[C]cpucycles()\f[R] does its best to produce accurate results, but selects a low-precision counter if the only other option is failure. .PP \f[C]cpucycles_persecond()\f[R] returns an estimate for the number of CPU cycles per second. This estimate comes from \f[C]/etc/cpucyclespersecond\f[R] if that file exists, otherwise from various OS mechanisms, otherwise from the \f[C]cpucyclespersecond\f[R] environment variable if that is set, otherwise 1000000000. .PP \f[C]cpucycles_implementation()\f[R] returns the name of the counter in use: e.g., \f[C]\[dq]amd64-pmc\[dq]\f[R]. .PP \f[C]cpucycles\f[R] is actually a function pointer. The first call to \f[C]cpucycles()\f[R] or \f[C]cpucycles_persecond()\f[R] or \f[C]cpucycles_implementation()\f[R] selects one of the available counters and updates the \f[C]cpucycles\f[R] pointer accordingly. Subsequent calls to \f[C]cpucycles()\f[R] are thread-safe. .SS SEE ALSO .PP \f[B]gettimeofday\f[R](2), \f[B]clock_gettime\f[R](2)