summaryrefslogtreecommitdiff
path: root/time
diff options
context:
space:
mode:
authorWilliam A. Rowe Jr <wrowe@apache.org>2002-08-04 18:29:33 +0000
committerWilliam A. Rowe Jr <wrowe@apache.org>2002-08-04 18:29:33 +0000
commit1c1ec981deb465e72688ccb92b5b37c2fd98314b (patch)
treefb7e2e25a2346bce759d846e6ffc4137ee15a69c /time
parent6705f2ab8338279a887302ba14b08bce27812378 (diff)
downloadapr-1c1ec981deb465e72688ccb92b5b37c2fd98314b.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: https://svn.apache.org/repos/asf/apr/apr/trunk@63792 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'time')
-rw-r--r--time/unix/time.c6
-rw-r--r--time/win32/time.c20
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,