FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Accurate timer

 
Post new topic   Reply to topic     Forum Index -> General
View previous topic :: View next topic  
Author Message
Eelco



Joined: 28 Jun 2004
Posts: 10
Location: Netherlands

PostPosted: Wed Jun 30, 2004 12:06 pm    Post subject: Accurate timer Reply with quote

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
View user's profile Send private message
aldacron



Joined: 05 May 2004
Posts: 1322
Location: Seoul, South Korea

PostPosted: Thu Jul 01, 2004 12:00 am    Post subject: Re: Accurate timer Reply with quote

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 Wink

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
View user's profile Send private message Send e-mail
Eelco



Joined: 28 Jun 2004
Posts: 10
Location: Netherlands

PostPosted: Thu Jul 01, 2004 3:12 am    Post subject: Reply with quote

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
View user's profile Send private message
kris



Joined: 27 Mar 2004
Posts: 1494
Location: South Pacific

PostPosted: Thu Jul 01, 2004 4:05 pm    Post subject: Reply with quote

mango.log wraps and exposes the OS timer, but it's only accurate to 1ms.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> General All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group