[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: time: Should real time usage account discontinous jumps?

From: David C Niemi
Subject: Re: time: Should real time usage account discontinous jumps?
Date: Thu, 26 Sep 2013 10:34:52 -0400 (EDT)
User-agent: Alpine 1.10 (LFD 962 2008-03-14)

I presume the point here is about the wall clock time, not actual CPU time usage, which is measured completely separately and for which CLOCK_MONOTONIC* are not in the picture.

I can only think of 3 fairly special cases where a difference in CLOCK_MONOTONIC_RAW differs meaningfully from a difference in the system time:

1) a leap second occurs

2) the hardware clock is inaccurate and NTP is making frequent small adjustments

3) the system time was set wrong and NTP is adjusting clock speed to get it to the correct time

Case 1 is very infrequent, and unlikely to be seen while you are using time other than on a very long-running task; and if it is a long-running task the error in the hardware clock could well exceed 1 second. So it's about a wash either way.

Case 2 you are much better off with the system time than the hardware time, because the hardware time is far less accurate.

Case 3 you are temporarily better off with hardware time, but this is a rather special case.

So on the whole I don't see CLOCK_MONOTONIC_RAW being a more accurate source, especially not in the long run. In addition, CLOCK_MONOTONIC_RAW is Linux-specific, and portability and simplicity are worthwhile goals in themselves when not faced with a clearly advantageous alternative.

David C Niemi

On Wed, 25 Sep 2013, Petr Pisar wrote:

The GNU time as well as bash built-in compute real time process usage as
a simple difference between two real time points. If there was a time
adjustement in between (by NTP or manual), the meassured value would be

I have found any hint nowhere if this is intended behavior or if one should
meassure some kind of monotic time line.

Is there any general agreement? My personal opinion is that monotonic
clock_gettime(CLOCK_MONOTONIC_RAW) is the best option.

-- Petr

| David C Niemi  (Reston, VA, USA)  niemi at tuxers dot net |

reply via email to

[Prev in Thread] Current Thread [Next in Thread]