times.2: Recommend clock_gettime(2) as alternative to times(2)

Recommend clock_gettime(2), not gettimeofday(2) as alternative to times(2).

From times(2):
  "To measure changes in elapsed time, use gettimeofday(2)
  instead."

From gettimeofday(2):
  "POSIX.1-2008 marks gettimeofday() as obsolete, recommending the
  use of clock_gettime(2) instead."

Some context, showing how use of gettimeofday() causes actual bugs
(also read comments):
http://blog.habets.pp.se/2010/09/gettimeofday-should-never-be-used-to-measure-time

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
Thomas Habets 2012-10-22 14:59:56 +02:00 committed by Michael Kerrisk
parent 1959393715
commit ff393a5f0d
1 changed files with 2 additions and 2 deletions

View File

@ -35,7 +35,7 @@
.\" Added notes on nonstandard behavior: Linux allows 'buf' to
.\" be NULL, but POSIX.1 doesn't specify this and it's nonportable.
.\"
.TH TIMES 2 2012-04-16 "Linux" "Linux Programmer's Manual"
.TH TIMES 2 2012-10-22 "Linux" "Linux Programmer's Manual"
.SH NAME
times \- get process times
.SH SYNOPSIS
@ -174,7 +174,7 @@ combined with the fact that the returned value may overflow the range of
.IR clock_t ,
means that a portable application would be wise to avoid using this value.
To measure changes in elapsed time, use
.BR gettimeofday (2)
.BR clock_gettime (2)
instead.
.\" .PP
.\" On older systems the number of clock ticks per second is given