time(1): add an option to use the monotonic clock
POSIX-compliance requires use of the real-time clock, but we have a non-default
option to use the monotonic clock.
Differential D14032
time(1): add an option to use the monotonic clock asomers on Jan 24 2018, 6:28 PM. Authored by Tags None Referenced Files
Details
time(1): add an option to use the monotonic clock POSIX-compliance requires use of the real-time clock, but we have a non-default Tested "time sleep 5" with and without -m, while stepping the system
Diff Detail
Event Timeline
Comment Actions Hmm, it is remarkable to see this after the monotonic clock has existed for so long. Also, GNU time and mksh's keyword appear to use CLOCK_REALTIME without configurability. I'm not sure preserving the letter of POSIX is important enough to add this option. time is not meant as a high-accuracy benchmarking tool with portable results. Also, relative time services with CLOCK_REALTIME like nanosleep() are not supposed to be affected by clock jumps (but they are affected by speedup/slowdown such as from ntp_adjtime(2)). So changing the clock used by time to CLOCK_MONOTONIC without configurability may be an option as well. Note that various shells (but not our sh) have a time keyword, which allows timing builtins, pipelines and functions. This keyword tends not to support any options and uses a different implementation. Depending on the shell, some form of quoting or env may or may not be required to call the external time with options. Comment Actions This looks good. I think jilles is right, implementing it with CLOCK_MONOTONIC by default may be better than making it optional. Most people won't look at the man page, and this gives it more of a "do what I mean" behavior. You might want to run it by bde and see what he thinks about it. |