So are the two programs then going to run on different computers? Is that part of your requirement that one will run on Windows and the other *nix?
Printable View
So are the two programs then going to run on different computers? Is that part of your requirement that one will run on Windows and the other *nix?
well, outside of the windows world it appears that CLOCKS_PER_SEC=1000000L, so the counter overflows in little more than one hour. and no, there's nothing (portable) you can do about it.Quote:
Originally posted by CornedBee
Actually clock()'s unit is 1/CLOCKS_PER_SEC.
1/1000th of a second on Windows, and I doubt how accurate this actually is.
You can use time(time_t*), it has second resolution. But that's probably too inaccurate.
For high numbers, but with great accuracy, you can use QueryPerformanceCounter, only available in Windows.
Ok, you did say that you wanted to synchronize two different computers! (sorry I didn't see that before). I happen to work with embeded systems at my job and am familliar with this area. I strongly recommend that you do NOT rely on timers. Even if the computers you have have good oscillators, there will still be a little bit of drift between the different clocks. (BTW, clock() is a very bad method to use for other reasons -- it measures the amount of time spent in the current process, not the difference of between two times). The only way to synchronize correctly is to have one computer send a signal to the second computer -- perhaps through a TCP/IP port. Anyway, good luck!
- Kevin