Advertisement

Linux timing functions

Started by October 17, 2003 03:01 PM
2 comments, last by Bacardi34 21 years, 3 months ago
Im new to linux and i need to write a timing function for my app. I am used to the windows timeGetTime and dont know what lunix functions i should be using to accomplish the task. Any suggestions? Thx!
Previously posted answer.

Advertisement
I use gettimeofday which is (as far as i know) the only standard way to get a time that has a granuality of less than a second.

struct timeval tv;
gettimeofday( &tv, 0);

returns the time in seconds and microseconds.
struct timeval {
long tv_sec; /* seconds */
long tv_usec; /* microseconds */
};

If anyone knows an even more accurate timer, let us know.
A while ago someone mentioned the RDTSC x86 assembly instruction. That''s about as precise as you can possibly get.

This topic is closed to new replies.

Advertisement