I usuall optimize my code for clean code and don't spend much time worrying about optimizing for particular hardware, or really worrying about hardware at all. This is why I was surprised when I ran this on our deparment computer lab:
wking@xphy1:~$ grep MHz /proc/cpuinfo
cpu MHz : 2000.000
cpu MHz : 3166.000
What! Why is the CPU speed changing for a dual-core chip? Some
searching around lead me to cpufrequtils (Debian: cpufrequtils
,
Gentoo: sys-power/cpufrequtils
) and cpufreq-info
:
wking@xphy1$ cpufreq-info
cpufrequtils 006: cpufreq-info (C) Dominik Brodowski 2004-2009
Report errors and bugs to cpufreq@vger.kernel.org, please.
analyzing CPU 0:
driver: acpi-cpufreq
CPUs which run at the same hardware frequency: 0
CPUs which need to have their frequency coordinated by software: 0
maximum transition latency: 10.0 us.
hardware limits: 2.00 GHz - 3.17 GHz
available frequency steps: 3.17 GHz, 2.67 GHz, 2.33 GHz, 2.00 GHz
available cpufreq governors: conservative, ondemand, userspace,
powersave, performance
current policy: frequency should be within 2.00 GHz and 3.17 GHz.
The governor "ondemand" may decide which speed to use
within this range.
current CPU frequency is 2.00 GHz (asserted by call to hardware).
cpufreq stats: 3.17 GHz:4.40%, 2.67 GHz:0.05%, 2.33 GHz:0.05%,
2.00 GHz:95.49% (3538)
analyzing CPU 1:
driver: acpi-cpufreq
CPUs which run at the same hardware frequency: 1
CPUs which need to have their frequency coordinated by software: 1
maximum transition latency: 10.0 us.
hardware limits: 2.00 GHz - 3.17 GHz
available frequency steps: 3.17 GHz, 2.67 GHz, 2.33 GHz, 2.00 GHz
available cpufreq governors: conservative, ondemand, userspace,
powersave, performance
current policy: frequency should be within 2.00 GHz and 3.17 GHz.
The governor "ondemand" may decide which speed to use
within this range.
current CPU frequency is 2.00 GHz (asserted by call to hardware).
cpufreq stats: 3.17 GHz:4.03%, 2.67 GHz:0.77%, 2.33 GHz:0.03%,
2.00 GHz:95.17% (3743)
Now it makes sense ;). Apparently the current (possibly throttled)
frequency is listed in /proc/cpuinfo
, not the maximum frequency.
Also, the computer lab computers don't seem to be working very hard ;).