how can i count the processor cycles used to do some code
Posted on 2002-11-11 08:42:10 by Thor0Asgard
Do you known Agner fog's Pentium optimization article? It contains accurate code to benchmark pieces of code, but you must run it on real mode, so you must go to DOS. - This is the code you need, actually it seems to be separated from the article, maybe it's in the article too...
Posted on 2002-11-11 09:34:52 by Knightmare
Look for the detail of the RDTSC intruction.

A good documentation is the number II volume of Intel Programmer's Guide. They also have good texts talking about it on their site.
Posted on 2002-11-11 12:36:23 by amcd
the time format is MSR what is MSR time format ?
do i have to put the rdtsc instruction
store the time in vars
do my code
and sub the time with the backed time into my vars
and then has the time between the 2 rdtsc ?
Posted on 2002-11-11 14:36:12 by Thor0Asgard

You should use the board search option: some people posted useful macros to deal with RDTSC, it can be a good example.

If you only need to benchmark, you can also use the GetTickCount() API function... it returns millisecons in eax, so it is a bit less precise, but easier to use, and in a relatively long loop, the variation is ridiculous between two executions of the same code is ridiculous.
Posted on 2002-11-12 00:58:52 by JCP
IIRC, GetTickCount API returns the no. of milliseconds since the system booted.
Posted on 2002-11-12 05:58:15 by roticv
Yes, but if you save the value of the first call and substract it of the value of the second call to it, you will have the time in ms spent during the two different calls...
Posted on 2002-11-12 08:19:11 by JCP