How to get CPU turbo frequency?
I want to write small statusbar widget in C which will show current CPU frequency (including turbo).
For example I can (in shell) run
To get turbo freq
which shows turbo frequency.
But how to do it in C? How to get only current frequency of fastest running CPU?
I want to write small statusbar widget in C which will show current CPU frequency (including turbo).
For example I can (in shell) run
sysctl -n dev.cpu.0.freq
and that return maximal base frequency (or in Intel case: max base frequency + 1 MHz).To get turbo freq
pmcstat
command can be used
Code:
pmcstat -s unhalted-core-cycles -w 1 2>&1 | sed -E 's/ {15}//g'
But how to do it in C? How to get only current frequency of fastest running CPU?