diff options
author | wrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68> | 2002-08-04 18:29:33 +0000 |
---|---|---|
committer | wrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68> | 2002-08-04 18:29:33 +0000 |
commit | 5ea82baeecd06f46620d3b3e1c0458fd97d5de45 (patch) | |
tree | fb7e2e25a2346bce759d846e6ffc4137ee15a69c /time | |
parent | 3e1c98be85374d80d91e31ce20a0d55037cdb9d9 (diff) | |
download | libapr-5ea82baeecd06f46620d3b3e1c0458fd97d5de45.tar.gz |
Time in exact ms intervals can be very useful in benchmarking... this
patch defines a general API for doing so if the platform supports
toggling the clock resolution. Don't recommend doing so for HTTPD,
but flood and ab should appreciate it.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@63792 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'time')
-rw-r--r-- | time/unix/time.c | 6 | ||||
-rw-r--r-- | time/win32/time.c | 20 |
2 files changed, 26 insertions, 0 deletions
diff --git a/time/unix/time.c b/time/unix/time.c index 65b82b0aa..2669f30cf 100644 --- a/time/unix/time.c +++ b/time/unix/time.c @@ -364,6 +364,12 @@ APR_DECLARE(void) apr_unix_setup_time(void) #endif +/* A noop on all known Unix implementations */ +APR_DECLARE(void) apr_time_clock_hires(apr_pool_t *p) +{ + return; +} + /* Deprecated */ APR_DECLARE(apr_status_t) apr_explode_time(apr_time_exp_t *result, apr_time_t input, diff --git a/time/win32/time.c b/time/win32/time.c index 672b683cf..42b531b26 100644 --- a/time/win32/time.c +++ b/time/win32/time.c @@ -65,6 +65,7 @@ #endif #include <string.h> #include <winbase.h> +#include "misc.h" /* Leap year is any year divisible by four, but not by 100 unless also * divisible by 400 @@ -282,6 +283,25 @@ APR_DECLARE(void) apr_sleep(apr_interval_time_t t) Sleep((DWORD)(t / 1000)); } + +static apr_status_t clock_restore(void *unsetres) +{ + ULONG newRes; + SetTimerResolution((ULONG)unsetres, FALSE, &newRes); + return APR_SUCCESS; +} + +APR_DECLARE(void) apr_time_clock_hires(apr_pool_t *p) +{ + ULONG newRes; + if (SetTimerResolution(10000, TRUE, &newRes) == 0 /* STATUS_SUCCESS */) { + /* register the cleanup... */ + apr_pool_cleanup_register(p, (void*)10000, clock_restore, + apr_pool_cleanup_null); + } +} + + /* Deprecated */ APR_DECLARE(apr_status_t) apr_explode_time(apr_time_exp_t *result, apr_time_t input, |