Guardati un po' rdtsc (assembly):
RDTSC Read Time Stamp Counter
Mnemonic: RDTSC
Opcode : 0F 31
Bug in : Poorly documented for Pentium Processor
Function:
RDTSC reads a Pentium internal 64 bit register which is being incremented
from 0000 0000 0000 0000 at every CPU internal clockcycle. Note that this
gives a clockcycle-accurate timer with a range of more than 8800 years at
66 Mhz...
The instruction places the counter in the EDX:EAX register pair.
Io farei una cosa del tipo (ad occhio, per nasm, non testato):
- Codice: Seleziona tutto
.data
minor dd 0
major dd 0
.code
_start_bench:
rdtsc
mov dword[minor],eax
mov dword[major],edx
ret
_end_bench:
rdtsc
sub dword[minor],eax
sbc dword[major],edx
;return a pointer to a long-long
mov eax,minor
ret
In Windows, leggiti l'sdk su QueryPerformanceCounter/QueryPerformanceFrequency - ho del codice a mano, se ne hai bisogno te lo mando.
HTH,HAND
Il faut être toujours ivre. Tout est là : c'est l'unique question. Pour ne pas sentir l'horrible fardeau du Temps qui brise vos épaules et vous penche vers la terre,il faut vous enivrer sans trêve...