|
-
May 25th, 2005, 12:31 PM
#1
Thread Starter
Frenzied Member
clock ticks
Hi
I am trying to messure the time it takes for Dijkstras algorithm to calculate a route. I am using clock(); to messure. But I have a few questions about the method....what is ticks and clock ticks per second???
-
May 25th, 2005, 01:58 PM
#2
Not NoteMe
Re: clock ticks
I'm unfamiliar with clock().
One tick is, i guess one clock cycle. i.e. what the CPU does in one 'tick'. Ticks per second are how many it does in one second (i.e. the speed of your CPU). Not 100% if this is what it means by a 'tick' though.
I'd use the API GetTickCount(), which gives the number of miliseconds passed since startup. So you could call it before and after your function. The difference would be the miliseconds it too to run your function.
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts. 
-
May 25th, 2005, 02:59 PM
#3
Thread Starter
Frenzied Member
Re: clock ticks
thanks But I need the time in microseconds
-
May 25th, 2005, 03:27 PM
#4
Not NoteMe
Re: clock ticks
Why? If the function is done too quickly then why not just run it multiple times and count from that?
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts. 
-
May 25th, 2005, 07:04 PM
#5
Re: clock ticks
GetTickCount is inaccurate. It's especially inaccurate on the 9x series (updating only 13 times a second or so).
clock() is just as inaccurate. You have no guarantee at all about the actual resolution of this call. POSIX demands that CLOCKS_PER_SEC be 1000000, but nothing demands that the status is updated that often. CLK_TCK is equivalent to CLOCKS_PER_SEC, but outdated and considered obsolete.
clock() is also unsafe, because it wraps around a lot. On a POSIX-compliant system with a 32-bit clock_t, it wraps every 72 minutes, which is a lot. Get such a wrap into your measurement period and you get confusing results.
clock() is also unpredictable. OSs differ in what they include in the measurement, e.g. some unices include the processor time of child processes, while others don't.
If you're measuring real time and have no need for portability, I recommend queryPerformanceCounter() on Windows. There's also some calls for getting the actual processor usage that are better than clock().
On Linux, you can use the times() function to get more accurate info about where and how a process spends its time.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|