how find out CPU clockrate?

Palle Girgensohn girgen at pingpong.net
Fri Jan 9 15:12:25 PST 2004


Hi!

How can I programatically find out the CPU frequency?

I'm trying to port a program from Linux, and it uses /proc/cpuinfo.

$ cat /compat/linux/proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 14
stepping        : 2
flags           : fpu vme de pse tsc msr pae mce cx8 sep mtrr pge mca cmov 
pat pse36 mmx fxsr
cpu MHz         : 349.20
bogomips        : 349.20


Pretty neat, but it does not exist in FreeBSD, and sysctl does not give out 
this information. Grepping the dmesg.boot seems somewhat odd for a C 
program:

$ dmesg | grep -i hz
Timecounter "i8254"  frequency 1193182 Hz
CPU: Pentium II/Pentium II Xeon/Celeron (349.20-MHz 686-class CPU)


Better ideas?

/Palle




More information about the freebsd-questions mailing list