Results 1 to 5 of 5

Thread: clock ticks

  1. #1

    Thread Starter
    Frenzied Member CyberCarsten's Avatar
    Join Date
    Sep 1999
    Location
    Aalborg Ø, Denmark
    Posts
    1,544

    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???
    razor
    Software Engineer Student, Aalborg University, Denmark
    http://www.cs.auc.dk

    My email at AUC: will get a new email soon
    My website: http://www.razorsoftware.net


    Windows XP Pro/ Gentoo Linux (Laptop)
    Windows XP Pro (Home PC)

  2. #2
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    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.


  3. #3

    Thread Starter
    Frenzied Member CyberCarsten's Avatar
    Join Date
    Sep 1999
    Location
    Aalborg Ø, Denmark
    Posts
    1,544

    Re: clock ticks

    thanks But I need the time in microseconds
    razor
    Software Engineer Student, Aalborg University, Denmark
    http://www.cs.auc.dk

    My email at AUC: will get a new email soon
    My website: http://www.razorsoftware.net


    Windows XP Pro/ Gentoo Linux (Laptop)
    Windows XP Pro (Home PC)

  4. #4
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    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.


  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    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
  •  



Click Here to Expand Forum to Full Width