Re: ReadClock question - Possible overflow?
- From: "f0dder" <f0dder_nospam@xxxxxxxxxxxxxxxx>
- Date: Wed, 31 May 2006 12:31:13 +0200
yancheng.cheok@xxxxxxxxx wrote:
; RDTSC.ASM Agner
Fog 2003
; © 2003 GNU General Public License www.gnu.org/copyleft/gpl.html
PublicAlias _ReadClock ; Underscore needed when called from
Windows
push ebx
sub eax, eax
cpuid ; serialize
rdtsc ; read time stamp counter
push eax
push edx
sub eax, eax
cpuid ; serialize
pop edx
pop eax
pop ebx
ret
ReadClock ENDP
I was wondering when having ReadClock function to perform time
measurement. Is there any posibility that the time stamp counter will
overflow (i.e., edx:eax is alreay holding the maximum value, the next
clock cycle, it will reset to 0), hence giving inaccurate time
measurement result?
Sure, if you have a *very* fast computer running for a *very* long time :)
Be careful what you use RDTSC timing for, by the way. While overflowing
might not be too big a concern, you must take frequency-lowering into
account (power saving options, found mostly in laptops but also in
late-model desktop CPUs), and multi-core machines as well - games based on
the Unreal engine crash on AMD64x2 because they use RDTSC for timing, and
when windows schedules the game thread to another core, you get negative
time deltas. b00m.
.
- References:
- ReadClock question - Possible overflow?
- From: yancheng . cheok
- ReadClock question - Possible overflow?
- Prev by Date: ReadClock question - Possible overflow?
- Next by Date: Re: bootloader
- Previous by thread: ReadClock question - Possible overflow?
- Next by thread: Re: ReadClock question - Possible overflow?
- Index(es):
Relevant Pages
|