View previous topic :: View next topic |
Author |
Message |
Eelco
Joined: 28 Jun 2004 Posts: 10 Location: Netherlands
|
Posted: Wed Jun 30, 2004 12:06 pm Post subject: Accurate timer |
|
|
im looking for some accurate timing functions. date.d and time.d wont do, they have a sucky 10ms resolution, which obviously wont do when timing processes that take maybe lless than a ms.
i know resolutions of a couple of ns are possible, but are they already available in D, or how can best obtain them?
(btw i have to say these forums arnt very alive... my previous post got viewed 19 times in three days :S) |
|
Back to top |
|
|
aldacron
Joined: 05 May 2004 Posts: 1322 Location: Seoul, South Korea
|
Posted: Thu Jul 01, 2004 12:00 am Post subject: Re: Accurate timer |
|
|
Eelco wrote: | im looking for some accurate timing functions. date.d and time.d wont do, they have a sucky 10ms resolution, which obviously wont do when timing processes that take maybe lless than a ms.
i know resolutions of a couple of ns are possible, but are they already available in D, or how can best obtain them?
|
For now you'll have to use either OS-specific functions (such as QueryPerformanceCounter on Windows) or use inline asm to execute the RDTSC instruction. It would be nice to have an abstraction in Phobos, but I don't know if it's on the radar. Perhaps you could abstract it in a class yourself and contribute it to Deimos
Quote: |
(btw i have to say these forums arnt very alive... my previous post got viewed 19 times in three days :S) |
Most D discussion happens on the newsgroup, which is very active. Both the language and dsource.org are still very young, and both are growing. The forums here will likely one day be as active as the NG. But really, the site hasn't been open very long. |
|
Back to top |
|
|
Eelco
Joined: 28 Jun 2004 Posts: 10 Location: Netherlands
|
Posted: Thu Jul 01, 2004 3:12 am Post subject: |
|
|
thanks,
i had alreadystumbled across the ASM way. i dont have a clue if im doing it correctly, but it works. this is what i do:
Code: | ulong Cycle(){
asm{
rdtsc;
ret;
}
} |
i dont take into account clockspeed now, but its just for persona benchmarking of functions so thats not a real problem.
i assume i can find queryperformancecounter in windows.h then? |
|
Back to top |
|
|
kris
Joined: 27 Mar 2004 Posts: 1494 Location: South Pacific
|
Posted: Thu Jul 01, 2004 4:05 pm Post subject: |
|
|
mango.log wraps and exposes the OS timer, but it's only accurate to 1ms. |
|
Back to top |
|
|
|