Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to get your CPU Speed Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
Calculating the CPU speed 21-Mar-04
Category
System
Language
Delphi All Versions
Views
467
User Rating
9
# Votes
1
Replies
0
Publisher:
Darley, F. Joe
Reference URL:
			1   
2   (* NOTE: this may not work on all computers due to hardware limitations. *)
3   
4   function RDTSC : Int64; assembler;
5   asm
6     db $0F, $31 // opcode for RDTSC
7   end;
8   
9   function RDQPC : Int64;
10  begin
11    //retrieves the current value of the high-resolution performance counter, if one 
12  //exists.
13    QueryPerformanceCounter(result);
14  end;
15  
16  function CPUSpeed : Integer;
17  var
18  f, tsc, pc : Int64;
19  begin
20  //etrieves the frequency of the high-resolution performance counter, if one exists.
21  if QueryPerformanceFrequency(f) then
22  begin
23    Sleep(0);
24    pc := RDQPC;
25    tsc := RDTSC;
26    Sleep(100);
27    pc := RDQPC-pc;
28    tsc := RDTSC-tsc;
29   result := round(tsc * f / (pc * 1000000));
30  end
31  else
32    result := -1;
33  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC