diff options
author | Nick Mathewson <nickm@torproject.org> | 2016-07-08 12:53:51 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2016-07-19 11:40:46 +0200 |
commit | dc6f5d1dc1ccc86f32b39b939a5f83c35865d666 (patch) | |
tree | 2af4197a9440c5f5ddc39152c8f029f6df2bf340 /src/test/test-timers.c | |
parent | aa971c59246332391116caafd18855bccf2f99a5 (diff) | |
download | tor-dc6f5d1dc1ccc86f32b39b939a5f83c35865d666.tar.gz tor-dc6f5d1dc1ccc86f32b39b939a5f83c35865d666.zip |
Basic portable monotonic timer implementation
This code uses QueryPerformanceCounter() [**] on Windows,
mach_absolute_time() on OSX, clock_gettime() where available, and
gettimeofday() [*] elsewhere.
Timer types are stored in an opaque OS-specific format; the only
supported operation is to compute the difference between two timers.
[*] As you know, gettimeofday() isn't monotonic, so we include
a simple ratchet function to ensure that it only moves forward.
[**] As you may not know, QueryPerformanceCounter() isn't actually
always as monotonic as you might like it to be, so we ratchet that
one too.
We also include a "coarse monotonic timer" for cases where we don't
actually need high-resolution time. This is GetTickCount{,64}() on
Windows, clock_gettime(CLOCK_MONOTONIC_COARSE) on Linux, and falls
back to regular monotonic time elsewhere.
Diffstat (limited to 'src/test/test-timers.c')
0 files changed, 0 insertions, 0 deletions