bachra04
asked on
Display time in milliseconds in C++/C linux /unix
Hi guys,
I need help on how to display time in milliseconds in c/c++ under linux ?
I need help on how to display time in milliseconds in c/c++ under linux ?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The problem I have seen is how to printf the value, I'm seeing weird values
267.0000
948.0000
then
15.0000
etc ...
I'm expecting that time of day will be increasing
267.0000
948.0000
then
15.0000
etc ...
I'm expecting that time of day will be increasing
For both system calls? The man page to gettimeofday (http://linux.die.net/man/2/gettimeofday) states:
(even though I wouldn't expect such a weird behaviour)
POSIX.1-2008 marks gettimeofday() as obsolete, recommending the use of clock_gettime(2) instead. [...] The time returned by gettimeofday() is affected by discontinuous jumps in the system time (e.g., if the system administrator manually changes the system time). If you need a monotonically increasing clock, see clock_gettime(2).
(even though I wouldn't expect such a weird behaviour)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window
Sara