Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Looking for replacement for clock() function

  1. Jun 6, 2009 #1
    This function seems to be working incorrectly when I run my programm under wine on linux system. (program compiled with mingw32 on win32) Is there any other function that can give me more accuracy than 1 second? (i know time() is working well but i need something that changes a little bit more frequent) Yes. I know I could compile it under linux but I need it to work under Wine right now.
     
  2. jcsd
  3. Jun 6, 2009 #2
    ok never mind. i included this function and now it works fine both under win32 and linux:

    http://www.openasthra.com/c-tidbits/gettimeofday-function-for-windows/ [Broken]
     
    Last edited by a moderator: May 4, 2017
  4. Jun 12, 2009 #3

    You could always use the boost libraries to instantiate a boost::timer object.

    Code (Text):

    #include <boost/timer.hpp>

    ...


    // Create a boost::timer object
    boost::timer timerObject;

    // Something you want to time goes here
    // ...

    // Now calculate the elapsed time
    std::cout << "Elapsed time = " << timerObject.elapsed << " sec.\n";
     
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook