Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 Jan 2004 18:55:28 -0500
From:      Charles Swiger <cswiger@mac.com>
To:        Palle Girgensohn <girgen@pingpong.net>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: how find out CPU clockrate?
Message-ID:  <4D5E97DF-42FF-11D8-848D-003065A20588@mac.com>
In-Reply-To: <300110000.1073689940@palle.girgensohn.se>
References:  <300110000.1073689940@palle.girgensohn.se>

next in thread | previous in thread | raw e-mail | index | archive | help
On Jan 9, 2004, at 6:12 PM, Palle Girgensohn wrote:
> How can I programatically find out the CPU frequency?
[ ... ]
> Better ideas?

Here's a chunk of code from an old homework assignment from my days at  
CMU.  :-)

http://www.pkix.net/~chuck/clockspeed/

This uses an iterative method to achieve results within a certain  
accuracy-- a few percent-- but it works as a normal user without  
requiring anything more than the standard Unix interval timers.

28-ns1% ./freq
The clock frequency is approximately 395 Megahertz

29-ns1% dmesg | head
Copyright (c) 1992-2003 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
         The Regents of the University of California. All rights  
reserved.
FreeBSD 4.9-STABLE #9: Tue Dec  2 16:05:30 EST 2003
     root@ns1.pkix.net:/usr/obj/usr/src/sys/NORMAL
Timecounter "i8254"  frequency 1193182 Hz
CPU: Pentium II/Pentium II Xeon/Celeron (399.86-MHz 686-class CPU)
   Origin = "GenuineIntel"  Id = 0x652  Stepping = 2
Features=0x183f9ff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,SEP,MTRR,PGE,MCA,C 
MOV,PAT,PSE36,MMX,FXSR>

-- 
-Chuck



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4D5E97DF-42FF-11D8-848D-003065A20588>