From owner-freebsd-questions@FreeBSD.ORG Fri Jan 9 15:55:31 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7D33C16A4CE for ; Fri, 9 Jan 2004 15:55:31 -0800 (PST) Received: from smtpout.mac.com (smtpout.mac.com [17.250.248.47]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7D79143D1D for ; Fri, 9 Jan 2004 15:55:30 -0800 (PST) (envelope-from cswiger@mac.com) Received: from mac.com (smtpin07-en2 [10.13.10.152]) by smtpout.mac.com (8.12.6/MantshX 2.0) with ESMTP id i09NtTcA014106; Fri, 9 Jan 2004 15:55:29 -0800 (PST) Received: from [192.168.1.6] (pool-68-161-129-47.ny325.east.verizon.net [68.161.129.47]) (authenticated bits=0)i09NtTKQ027658; Fri, 9 Jan 2004 15:55:29 -0800 (PST) In-Reply-To: <300110000.1073689940@palle.girgensohn.se> References: <300110000.1073689940@palle.girgensohn.se> Mime-Version: 1.0 (Apple Message framework v609) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <4D5E97DF-42FF-11D8-848D-003065A20588@mac.com> Content-Transfer-Encoding: 7bit From: Charles Swiger Date: Fri, 9 Jan 2004 18:55:28 -0500 To: Palle Girgensohn X-Mailer: Apple Mail (2.609) cc: freebsd-questions@freebsd.org Subject: Re: how find out CPU clockrate? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Jan 2004 23:55:31 -0000 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 -- -Chuck