How can I get the CPU clock speed in C++?
I am running Ubuntu 9.10 if that makes any difference.
How can I get the CPU clock speed in C++?
I am running Ubuntu 9.10 if that makes any difference.
Read the pseudo-file /proc/cpuinfo
. See this link for an explanation of the fields it contains.
This information is available in sysfs. In particular, check out scaling_cur_freq
and cpuinfo_cur_freq
in /sys/devices/system/cpu/cpu*/cpufreq
.
When I had a Compaq Athlon64 laptop, its /proc/cpuinfo always reported its maximum speed.
I only got reliable current frequency numbers from the files in /sys/devices/system/cpu/*/cpufreq
.
I suppose your mileage may vary.