Board index » delphi » CPU speed

CPU speed

How can I calculate the speed of my CPU using lowlevel or high level
language?
 

Re:CPU speed


In article <i3oa5.10703$MS3.203...@news1.online.no>, "Bendik says...

Quote

>How can I calculate the speed of my CPU using lowlevel or high level
>language?

If it's a Pentium, use RDTSC.

Fifty dollars please.

Re:CPU speed


JRS:  In article <8kfi5o$...@drn.newsguy.com> of Tue, 11 Jul 2000
09:31:52 seen in news:comp.lang.pascal.borland,

Quote
ThePascalDoctor@gouge_u.med wrote:
>In article <i3oa5.10703$MS3.203...@news1.online.no>, "Bendik says...

>>How can I calculate the speed of my CPU using lowlevel or high level
>>language?

>If it's a Pentium, use RDTSC.

>Fifty dollars please.

Your answer is too brief to be of use to most readers.

Web <URL: http://www.merlyn.demon.co.uk/ptograms/rdtsc.pas> shows how
RDTSC can be programmed in Pascal & Delphi (FrdtscL); you should then do
something like (undertested) :

        function FrdtscL : longint ; assembler {TP/BP} ;
        asm  dw $310F  {Clock to edx:eax}
          db $66 ; mov dx,ax ; db $66 ; shr dx,16  end {FrdtscL} ;

        ...
        T := FrdtscL ; Delay(1000) ; Writeln(FrdtscL-T, ' Hz') ;

Note that it actually returns an Int64 ...

--
? John Stockton, Surrey, UK.  j...@merlyn.demon.co.uk   Turnpike v4.00   MIME. ?
 Web <URL: http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
     Check boilerplate spelling -- error is a public sign of incompetence.
       Never fully trust an article from a poster who gives no real name.

Re:CPU speed


Quote
>>>How can I calculate the speed of my CPU using lowlevel or high level
>>>language?

>>If it's a Pentium, use RDTSC.

>>Fifty dollars please.

>Your answer is too brief to be of use to most readers.

>Web <URL: http://www.merlyn.demon.co.uk/ptograms/rdtsc.pas> shows how
>RDTSC can be programmed in Pascal & Delphi (FrdtscL); you should then do
>something like (undertested) :

>        function FrdtscL : longint ; assembler {TP/BP} ;
>        asm  dw $310F  {Clock to edx:eax}
>          db $66 ; mov dx,ax ; db $66 ; shr dx,16  end {FrdtscL} ;

>        ...
>        T := FrdtscL ; Delay(1000) ; Writeln(FrdtscL-T, ' Hz') ;

>Note that it actually returns an Int64 ...

And again: this will produce nice GPF's on Cyrix, Amd's 486's etc.

Re:CPU speed


In article <zP9APpE0J3a5E...@merlyn.demon.co.uk>, Dr says...

Quote

>JRS:  In article <8kfi5o$...@drn.newsguy.com> of Tue, 11 Jul 2000
>09:31:52 seen in news:comp.lang.pascal.borland,
>ThePascalDoctor@gouge_u.med wrote:
>>In article <i3oa5.10703$MS3.203...@news1.online.no>, "Bendik says...

>>>How can I calculate the speed of my CPU using lowlevel or high level
>>>language?

>>If it's a Pentium, use RDTSC.

>>Fifty dollars please.

>Your answer is too brief to be of use to most readers.

No it's not.

RDTSC is a unique enough keyword that you can type it into any search engine and
and you'll find plenty of help.  Even your web page.

Next time you lecture somebody to RTFM I'm going to remind you of this.

One hundred dollars please.

Re:CPU speed


In article <zP9APpE0J3a5E...@merlyn.demon.co.uk>

Quote
>        function FrdtscL : longint ; assembler {TP/BP} ;
>        asm  dw $310F  {Clock to edx:eax}
>          db $66 ; mov dx,ax ; db $66 ; shr dx,16  end {FrdtscL} ;
>Note that it actually returns an Int64 ...

OK, so let's tell the readers how to grab the whole thing:

function rdtsc64: comp;

var
int64: comp;

begin
asm
db $0F, $31; {RDTSC}
db $66, $89, $46, $F0; {mov eax into low 32 bits of int64}
db $66, $89, $56, $F4; {mov edx into hi 32 bits of int64}
end;
rdtsc64:=int64;
end;

Fifty dollars please.

Re:CPU speed


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Marco van de Voort <mar...@toad.stack.nl> schrieb in im Newsbeitrag:
slrn8mo5rc.jsb.mar...@toad.stack.nl...

Quote
> >>>How can I calculate the speed of my CPU using lowlevel or high
> >>>level language?

For the old cyrix's, you could try something like the well-known and
well-hated delay code does:

var l: longint;
    t: byte absoulte $0040:$006C;    // the lowest byte of BIOS
timer, increments every 18.2th of a second
    t2: byte;

begin
    t2 := t;
    l := 0;
    repeat until t <> t2;
    t2 := t;
    repeat inc(l) until t <> t2;
    writeln (l);
end.

But this will return unusable results when running in Windoze, so let
it run several times. You could calculate the MHz from l if you want,
but this is not exact. But for a installation routine yelling at the
user "YOU HAVE TO HAVE AT LEAST 37.2234 MHz AND YOU ONLY HAVE
176.2244565!" this is enough.

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 6.5.1 Int. for non-commercial use
<http://www.pgpinternational.com>
Comment: Get a free virus at file://localhost/dev/aux/clock$

iQA/AwUBOWxUOZHoP2uzWQlaEQIQiACg08xGSyuc7SoOnvrvvAQ8aCrHSToAn3xQ
Ra92a8TFKd+ocsC24px/GWfs
=Mknp
-----END PGP SIGNATURE-----

Re:CPU speed


JRS:  In article <8ki2ts$...@drn.newsguy.com> of Wed, 12 Jul 2000
08:30:04 seen in news:comp.lang.pascal.borland,

Quote
ThePascalDoctor@gouge_u.med wrote:
>In article <zP9APpE0J3a5E...@merlyn.demon.co.uk>, Dr says...

>>JRS:  In article <8kfi5o$...@drn.newsguy.com> of Tue, 11 Jul 2000
>>09:31:52 seen in news:comp.lang.pascal.borland,
>>ThePascalDoctor@gouge_u.med wrote:
>>>In article <i3oa5.10703$MS3.203...@news1.online.no>, "Bendik says...

>>>>How can I calculate the speed of my CPU using lowlevel or high level
>>>>language?

>>>If it's a Pentium, use RDTSC.

>>>Fifty dollars please.

>>Your answer is too brief to be of use to most readers.

>No it's not.

>RDTSC is a unique enough keyword that you can type it into any search engine and
>and you'll find plenty of help.  Even your web page.

This is a discussion newsgroup, and where an adequate answer can be
provided in a screenful or so, it should be so provided.  There is all
sorts of dross on the Web, as well as good stuff; here errors get
corrected.

You claim to be at some sort of University, though the details fluctuate
rapidly; I expect that you have a fast, free, permanent Net connection.
Many over here have a slow, pay-by-time dial-up connection, and will
find the suggestion of a Web search considerably less helpful than the
provision of a specific URL.

--
? John Stockton, Surrey, UK.  j...@merlyn.demon.co.uk   Turnpike v4.00   MIME ?
 Web <URL:http://www.uwasa.fi/~ts/http/tsfaq.html> -> Timo Salmi: Usenet Q&A.
 Web <URL:http://www.merlyn.demon.co.uk/news-use.htm> :  about usage of News.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.

Re:CPU speed


Re:CPU speed


In article <$m+T1lF9WOb5E...@merlyn.demon.co.uk>, John "RTFF" Stockton says...

Quote

>JRS:  In article <8ki2ts$...@drn.newsguy.com> of Wed, 12 Jul 2000
>08:30:04 seen in news:comp.lang.pascal.borland,
>ThePascalDoctor@gouge_u.med wrote:
>>In article <zP9APpE0J3a5E...@merlyn.demon.co.uk>, Dr says...

>>>JRS:  In article <8kfi5o$...@drn.newsguy.com> of Tue, 11 Jul 2000
>>>09:31:52 seen in news:comp.lang.pascal.borland,
>>>ThePascalDoctor@gouge_u.med wrote:
>>>>In article <i3oa5.10703$MS3.203...@news1.online.no>, "Bendik says...

>>>>>How can I calculate the speed of my CPU using lowlevel or high level
>>>>>language?

>>>>If it's a Pentium, use RDTSC.

>>>>Fifty dollars please.

>>>Your answer is too brief to be of use to most readers.

>>No it's not.

>>RDTSC is a unique enough keyword that you can type it into any search engine and
>>and you'll find plenty of help.  Even your web page.

>This is a discussion newsgroup, and where an adequate answer can be
>provided in a screenful or so, it should be so provided.

I shall remind you of this next time you lecture someone to RTFF.

Two hundred dollars please.

---

Yesterday upon the stair
I met a man who wasn't there.
He wasn't there again today...
I wish that man would go away.

Re:CPU speed


Re:CPU speed


"Bendik Eide" <mic-e...@online.no> schrieb im Newsbeitrag
news:i3oa5.10703$MS3.203362@news1.online.no...

Quote
> How can I calculate the speed of my CPU using lowlevel or high level
> language?

You may visit my site on http://members.yline.com/~tom_at_work/index.html
and download the CPU unit which does such a detection. In addition the
provided documentation explains the procedure in great detail.

This unit is for the Free Pascal compiler only. But if you want I can give
you a pointer to ports to other pascal dialects....

If you have further questions feel free to contact me.

Regards,
    Thomas

Re:CPU speed


Re:CPU speed


JRS:  In article <8kkjm1$2...@drn.newsguy.com> of Thu, 13 Jul 2000
07:28:17 seen in news:comp.lang.pascal.borland,

Quote
ThePascalDoctor@gouge_u.csc wrote:
>>This is a discussion newsgroup, and where an adequate answer can be
>>provided in a screenful or so, it should be so provided.

>I shall remind you of this next time you lecture someone to RTFF.

When the answer is in the FAQ, the question ought not to have been asked
yet again; the answers in the FAQ have been read repeatedly, discussed
frequently, and updated where appropriate.  Further discussion will
normally be unnecessary, unless the questioner fails to understand the
FAQ.

But the more important point, which you do not yet appear to have
perceived, is that, for those who have not yet learnt to consult the FAQ
on any point with which it may deal, the best advice is that which is
directed towards persuading them to do so.

--
? John Stockton, Surrey, UK.  j...@merlyn.demon.co.uk   Turnpike v4.00   MIME. ?
 <URL: http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
 <URL: ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal FAQ;
 <URL: http://www.merlyn.demon.co.uk/clpb-faq.txt> Pedt Scragg: c.l.p.b. mFAQ.

Re:CPU speed


Quote
In article <4YKy6oAsChb5E...@merlyn.demon.co.uk>, John "RTFF" Stockman wrote...

>JRS:  In article <8kkjm1$2...@drn.newsguy.com> of Thu, 13 Jul 2000
>07:28:17 seen in news:comp.lang.pascal.borland,
>ThePascalDoctor@gouge_u.csc wrote:
>>>This is a discussion newsgroup, and where an adequate answer can be
>>>provided in a screenful or so, it should be so provided.

>>I shall remind you of this next time you lecture someone to RTFF.

>When the answer is in the FAQ, the question ought not to have been asked
>yet again; the answers in the FAQ have been read repeatedly, discussed
>frequently, and updated where appropriate.  Further discussion will
>normally be unnecessary, unless the questioner fails to understand the
>FAQ.

>But the more important point, which you do not yet appear to have
>perceived, is that, for those who have not yet learnt to consult the FAQ
>on any point with which it may deal, the best advice is that which is
>directed towards persuading them to do so.

The point which YOU "do not yet appear to have perceived", is that, for those
who have not yet "learnt" [sic] to consult search engines on the web, the best
advice is that which is directed towards persuading them to do so.

Five hundred dollars please.

Go to page: [1] [2] [3]

Other Threads