Page 1 of 1
code timing , whats wrong ?
Posted: Mon Nov 17, 2008 11:34 am
by kmtdk
well
i have tryed to time my code, using the RDTSC instrcution
but each time i use the instruction, Extreamly many cycles have passed since the last time,
and i dont have any code in betewen
the source is attached ( it is compiled as a "com" program, i have tryed on os, no change)
the time keeps changeing, but the difference is far too high.
Kmt dk
Re: code timing , whats wrong ?
Posted: Mon Nov 17, 2008 5:33 pm
by Combuster
Re: code timing , whats wrong ?
Posted: Tue Nov 18, 2008 7:29 am
by kmtdk
the code stores the 64 bit integer at the variable ( i use si to point)
but have i done it reverse , so edx shuld be the first , and then eax.??
KMt dk
Re: code timing , whats wrong ?
Posted: Tue Nov 18, 2008 7:45 am
by djmauretto
Did you mean:
Re: code timing , whats wrong ?
Posted: Tue Nov 18, 2008 8:03 am
by Masterkiller
it returns EDX:EAX, so EAX store less-significant bytes and they are 32-bit = 4 bytes, you store them between two bytes so rewrite the EAX. In the memory less-significant bytes are stored in lower addresses.
Edit: Lower address is the address that you do not add offset (since the offset is positive). EAX is less-significant, so it should be stored at lower address e.g. [si+0], not [si+4]
Re: code timing , whats wrong ?
Posted: Tue Nov 18, 2008 8:08 am
by kmtdk
* DOH
i forgot i was using 32 bit instructions, so that was one Big error.( the reason is i have worked on 16 bit too much ... )
so the code shuld look like this:
I will just test it ( and if i dont post/ edit, it means that i dont have tryed it..)
KMT dk
Re: code timing , whats wrong ?
Posted: Tue Nov 18, 2008 8:30 am
by djmauretto
kmtdk wrote:* DOH
i forgot i was using 32 bit instructions, so that was one Big error.( the reason is i have worked on 16 bit too much ... )
so the code shuld look like this:
I will just test it ( and if i dont post/ edit, it means that i dont have tryed it..)
KMT dk
Re: code timing , whats wrong ?
Posted: Wed Nov 19, 2008 3:07 pm
by kmtdk
Well
now i got it to work, but one thing shuld be told
this does not work 100 % under windows, but it does ( it counts wierd), but you can see a different
the code is attached , and use it as you want, but if you want to publise the code, ask for permission.
bye the way, the code is Not optimised .
happy timing ,:P
KMT dk
Re: code timing , whats wrong ?
Posted: Wed Nov 19, 2008 4:23 pm
by Combuster
I expect the TSC to jump large amounts when the OS decides to yield the CPU to another process. Also, unsynchronized counters can cause strange effects (going back in time, anyone?) when windows tosses the application between cores (windows' CPU affinity sucks big time, try forcing applications onto a single core and see whether it works better)