Have been trying to get even semi-sensible timings with rdtsc.
What I did was make a program to time the Sleep() timer with rdtsc and print out the results. I'm getting
1 second
seconds = 0
------------------------------------
2 seconds
seconds = 5
------------------------------------
3 seconds
seconds = 6
------------------------------------
4 seconds
seconds = 3
------------------------------------
5 seconds
seconds = 8
------------------------------------
6 seconds
seconds = 9
------------------------------------
7 seconds
seconds = 6
------------------------------------
8 seconds
seconds = 7
------------------------------------
9 seconds
seconds = 12
------------------------------------
10 seconds
seconds = 13
------------------------------------
Now I can't believe that the Sleep() function is THAT innacurate. And it seems to cycle consistently with either a 1 second lag or 3 second difference. I just don't see how the eax:edx pair returned from rdtsc can overflow 4 times between the 1 second timing and the 2 second timing...
Can anyone else see if they get the same strange results on their system? It will compile under masm32v7, just change the mhz variable to match your system speed.
What I did was make a program to time the Sleep() timer with rdtsc and print out the results. I'm getting
1 second
seconds = 0
------------------------------------
2 seconds
seconds = 5
------------------------------------
3 seconds
seconds = 6
------------------------------------
4 seconds
seconds = 3
------------------------------------
5 seconds
seconds = 8
------------------------------------
6 seconds
seconds = 9
------------------------------------
7 seconds
seconds = 6
------------------------------------
8 seconds
seconds = 7
------------------------------------
9 seconds
seconds = 12
------------------------------------
10 seconds
seconds = 13
------------------------------------
Now I can't believe that the Sleep() function is THAT innacurate. And it seems to cycle consistently with either a 1 second lag or 3 second difference. I just don't see how the eax:edx pair returned from rdtsc can overflow 4 times between the 1 second timing and the 2 second timing...
Can anyone else see if they get the same strange results on their system? It will compile under masm32v7, just change the mhz variable to match your system speed.
Make the following change for better results - perfect on my machine :) (WinXP)
_1 seconds = milli-seconds = _1003
_2 seconds = milli-seconds = _2001
_3 seconds = milli-seconds = _3001
_4 seconds = milli-seconds = _4011
_5 seconds = milli-seconds = _5010
_6 seconds = milli-seconds = _6020
_7 seconds = milli-seconds = _7009
_8 seconds = milli-seconds = _8019
_9 seconds = milli-seconds = _9019
10 seconds = milli-seconds = 10018
sub eax, time_low ; Find the difference
sbb edx, time_high
My results really aren't that bad considering I have 10 applications running including the Windows Media Player!
_1 seconds = milli-seconds = _1003
_2 seconds = milli-seconds = _2001
_3 seconds = milli-seconds = _3001
_4 seconds = milli-seconds = _4011
_5 seconds = milli-seconds = _5010
_6 seconds = milli-seconds = _6020
_7 seconds = milli-seconds = _7009
_8 seconds = milli-seconds = _8019
_9 seconds = milli-seconds = _9019
10 seconds = milli-seconds = 10018