CPU Speed

[Home]   [Puzzles & Projects]    [Delphi Techniques]   [Math Topics]   [Library]   [Utilities]

Search

 

Search DelphiForFun.org only

Support DFF

 

If you shop at Amazon anyway,  consider using this link. We receive a few cents from each purchase.   Thanks.

In Association with Amazon.com

 

Support DFF

 If you benefit from the website,  in terms of knowledge, entertainment value, or something otherwise useful, consider making a donation via PayPal  to help defray the costs.  (No PayPal account necessary to donate via credit card.)  Transaction is secure.

 

 

Contact

Feedback:  Send an e-mail with your comments about this program (or anything else).

 

Search DelphiForFun.org only

 

 

 

 

 

Here's a clever little program that will report CPU speed in Mhz (megahertz - millions of instruction cycles per second).   I found it in the Delphi section of experts-exchange.com (search for rdtsc),  where it was proposed to resolve a problem of code running slowly on a client's machine.  The problem identified in this case was Intel's "SpeedStep" feature for recent mobile processor models  which, on some operating systems (e.g.  XP), slows the processor to conserve power  when operating on batteries.   CPUSpeed showed that the processor was only running at 10% of its rated speed!  Disabling the feature, resolved the problem.

 

The program uses the ReadTimeStampCounter  (rdtsc) machine instruction to get cycle counter values before and after a 1/2 second delay and subtracting to get the number of instruction cycles during that half-second.   An Intel paper available at  http://cedar.intel.com/software/idap/media/pdf/rdtscpm1.pdf   describes the considerations for using rdtsc.  The calculation is almost self defining:  cycles per second = cycles / seconds, or, as reported,   millions of cycles per second = cycles / microseconds.   The programs sets priorities to high values before performing the calculation and restores them after to increase the accuracy of the timing.   I've tried it on four computers here and results match  CPU specs.    

 

Cool example of using inline assembler instructions  and running a windows program with no form  (even if you probably won't really need it very often). 

 

Download Source

Download Executable

 

Created: February 5, 2003

Modified: November 07, 2008

 

  [Feedback]   [Newsletters (subscribe/view)] [About me]
Copyright © 2000-2011, Gary Darby    All rights reserved.