OSDN Git Service

Reimplement clock(3) using clock_gettime(3)
authorAlex Van Brunt <avanbrunt@nvidia.com>
Fri, 26 Sep 2014 20:32:47 +0000 (13:32 -0700)
committerElliott Hughes <enh@google.com>
Sat, 4 Oct 2014 02:05:52 +0000 (19:05 -0700)
commita508714800242b294291060641ed35d719bdc857
treed6f21643baa2122edb30cb5540105c750c417b2f
parentea9800e98598c71fe76c4e2a0d0498b6bd490a83
Reimplement clock(3) using clock_gettime(3)

Unlike times(), clock_gettime() is implemented as a vDSO on many architectures.
So, using clock_gettime() will return a more accurate time and do so with less
overhead because it does have the overhead of calling into the kernel.

It is also significantly more accurate because it measures the actual time in
nanoseconds rather than the number of ticks (typically 1 millisecond or more).

Bug: 17814435

(cherry picked from commit 8d0b2dbf2154d5da17ff09b1d4f864d281362ad2)

Change-Id: Id4945d9f387330518f78669809639952e9227ed9
libc/bionic/clock.cpp