Home > Archive > Unix Programming > September 2005 > Get current time
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| rishi.shah@patni.com 2005-09-27, 7:02 pm |
| How can we get current time accurate to milli sec in C++/unix?
Is there some API to perform this function?
| |
| Rich Teer 2005-09-27, 7:02 pm |
| On Tue, 27 Sep 2005, rishi.shah@patni.com wrote:
> How can we get current time accurate to milli sec in C++/unix?
> Is there some API to perform this function?
Dujno about milliseconds, but gettimeofday will give it to you
in microseconds, provided your HW and OS support that granularity.
HTH,
--
Rich Teer, SCNA, SCSA, OpenSolaris CAB member
President,
Rite Online Inc.
Voice: +1 (250) 979-1638
URL: http://www.rite-group.com/rich
| |
| Roger Leigh 2005-09-27, 7:02 pm |
| Rich Teer <rich.teer@rite-group.com> writes:
> On Tue, 27 Sep 2005, rishi.shah@patni.com wrote:
>
>
> Dujno about milliseconds, but gettimeofday will give it to you
> in microseconds, provided your HW and OS support that granularity.
ftime(3) will give you milliseconds. I can't say I've used it,
though; I always use gettimeofday(2).
--
Roger Leigh
Printing on GNU/Linux? http://gimp-print.sourceforge.net/
Debian GNU/Linux http://www.debian.org/
GPG Public Key: 0x25BFB848. Please sign and encrypt your mail.
| |
| Chris Friesen 2005-09-27, 7:02 pm |
| rishi.shah@patni.com wrote:
> How can we get current time accurate to milli sec in C++/unix?
> Is there some API to perform this function?
gettimeofday()
clock_gettime()
The second one is interesting because you can specify CLOCK_REALTIME (ie
wallclock) or CLOCK_MONOTONIC (doesn't jump with NTP corrections).
Chris
|
|
|
|
|