I am writing a program where i have to time how long it takes different processes. I am using the function gettimeofday which returns seconds and microseconds. I was wondering how would I turn in the result to milliseconds?
Thanks in advance.
I am writing a program where i have to time how long it takes different processes. I am using the function gettimeofday which returns seconds and microseconds. I was wondering how would I turn in the result to milliseconds?
Thanks in advance.
If you can get microseconds divide it by 1000 to get milli (?)
There's a difference between resolution and accuracy.
the resolution is 1uS, but the accuracy might be 20mS (ie, 50 times a second, the OS adds 20000 to the uS value).
You need to bear this in mind if you are thinking of using it as an accurate clock.
If you really want a fast and accurate clock, its going to be OS/compiler specific.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.