Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: C++ and accurate timers under Linux?

  1. #11
    Join Date
    Aug 2007
    Location
    Canada
    Beans
    459
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: C++ and accurate timers under Linux?

    Quote Originally Posted by dwhitney67 View Post
    Brilliant! You took the number of seconds that a process executed and multiplied by a 1000 to yield milliseconds. Now why didn't I think of that?
    Thanks dwhitney67... I just wanted to give the correct output to the OP, but actually your solution was fine, since the OP can straight forward get the seconds.
    Best, Gnusci

    "Never make a calculation until you know the answer." -- Wheeler, Spacetime Physics, pg 60.

  2. #12
    Join Date
    Aug 2006
    Beans
    278

    Re: C++ and accurate timers under Linux?

    Quote Originally Posted by Zugzwang View Post
    What brought you to the conclusion that clock() uses RTC? According to a man page for clock(), the function measures time spent in the process with an accuracy dependent on the implementation of the function.
    I somehow mixed it up with the time() function. My apologies.

  3. #13
    Join Date
    Jul 2010
    Beans
    1

    Re: C++ and accurate timers under Linux?

    I see that this thread is long dead, but for future googlers who come across it as I did in their search for an accurate way to compare execution times in C or C++, a very simple solution is provided by the cycle.h file included with the source code for FFTW, available at http://www.fftw.org. It can be included in any program (subject to FFTW's license) independently from the rest of FFTW, and implements a tick counter using inline assembly provided for many different architectures.

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •