Looking for replacement for clock() function

  • Thread starter Thread starter engri
  • Start date Start date
  • Tags Tags
    Clock Function
AI Thread Summary
The discussion centers on issues with a program running under Wine on a Linux system, specifically regarding the accuracy of time functions. The user initially seeks a function that provides more precise timing than the standard time() function, which only offers accuracy to the nearest second. They mention that while compiling the program under Linux is an option, they need it to function correctly under Wine. A solution is found by including a specific function from an external source, which resolves the timing issue for both Win32 and Linux environments. Additionally, the use of Boost libraries is suggested as an alternative, specifically the boost::timer object, which can provide more accurate elapsed time measurements.
engri
Messages
4
Reaction score
0
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.
 
Technology news on Phys.org
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/
 
Last edited by a moderator:
engri said:
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.


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

Code:
#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";
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
Thread 'Project Documentation'
Trying to package up a small bank account manager project that I have been tempering on for a while. One that is certainly worth something to me. Although I have created methods to whip up quick documents with all fields and properties. I would like something better to reference in order to express the mechanical functions. It is unclear to me about any standardized format for code documentation that exists. I have tried object orientated diagrams with shapes to try and express the...
Back
Top