[cairo-commit] perf/cairo-perf.c perf/cairo-perf.h
perf/cairo-perf-timer.h perf/cairo-perf-timer-posix.c
perf/cairo-perf-timer-win32.c
Carl Worth
cworth at kemper.freedesktop.org
Thu Aug 31 14:08:49 PDT 2006
perf/cairo-perf-timer-posix.c | 17 +++++++++++++++--
perf/cairo-perf-timer-win32.c | 2 +-
perf/cairo-perf-timer.h | 2 +-
perf/cairo-perf.c | 4 ++--
perf/cairo-perf.h | 2 +-
5 files changed, 20 insertions(+), 7 deletions(-)
New commits:
diff-tree 6ae6d91c0c3a2f8fdff39c1c84fbef3aa45bf958 (from 2ebb9af4346c5e60d2497cfb9c5809d0c8045878)
Author: Carl Worth <cworth at cworth.org>
Date: Thu Aug 31 14:08:43 2006 -0700
perf: Switch from alarm to setitimer for more fine-grained control of timers
diff --git a/perf/cairo-perf-timer-posix.c b/perf/cairo-perf-timer-posix.c
index 2d91894..29fd3fb 100644
--- a/perf/cairo-perf-timer-posix.c
+++ b/perf/cairo-perf-timer-posix.c
@@ -63,8 +63,21 @@ alarm_handler (int signal) {
}
void
-set_alarm (int seconds) {
+set_alarm (double seconds) {
+ struct itimerval tr;
+ long sec, usec;
+
cairo_perf_alarm_expired = 0;
signal (SIGALRM, alarm_handler);
- alarm (seconds);
+
+ sec = floor (seconds);
+ seconds -= sec;
+ usec = seconds * 1e6;
+
+ tr.it_interval.tv_sec = 0;
+ tr.it_interval.tv_usec = 0;
+ tr.it_value.tv_sec = sec;
+ tr.it_value.tv_usec = usec;
+
+ setitimer (ITIMER_REAL, &tr, NULL);
}
diff --git a/perf/cairo-perf-timer-win32.c b/perf/cairo-perf-timer-win32.c
index f3975fa..c03256d 100644
--- a/perf/cairo-perf-timer-win32.c
+++ b/perf/cairo-perf-timer-win32.c
@@ -64,7 +64,7 @@ alarm_handler (void *closure, DWORD dwTi
HANDLE hTimer = NULL;
void
-set_alarm (int seconds) {
+set_alarm (double seconds) {
if (hTimer == NULL)
hTimer = CreateWaitableTimer(NULL, TRUE, NULL);
cairo_perf_alarm_expired = 0;
diff --git a/perf/cairo-perf-timer.h b/perf/cairo-perf-timer.h
index bea91c2..e934437 100644
--- a/perf/cairo-perf-timer.h
+++ b/perf/cairo-perf-timer.h
@@ -60,6 +60,6 @@ void
alarm_handler (int signal);
void
-set_alarm (int seconds);
+set_alarm (double seconds);
#endif
diff --git a/perf/cairo-perf.c b/perf/cairo-perf.c
index 6c88a6e..c750381 100644
--- a/perf/cairo-perf.c
+++ b/perf/cairo-perf.c
@@ -27,7 +27,7 @@
#include "cairo-perf.h"
-int cairo_perf_duration = 1;
+double cairo_perf_duration = 1;
int cairo_perf_iterations = 10;
@@ -134,7 +134,7 @@ main (int argc, char *argv[])
stats_t stats;
if (getenv("CAIRO_PERF_DURATION"))
- cairo_perf_duration = strtol(getenv("CAIRO_PERF_DURATION"), NULL, 0);
+ cairo_perf_duration = strtod(getenv("CAIRO_PERF_DURATION"), NULL);
if (getenv("CAIRO_PERF_ITERATIONS"))
cairo_perf_iterations = strtol(getenv("CAIRO_PERF_ITERATIONS"), NULL, 0);
diff --git a/perf/cairo-perf.h b/perf/cairo-perf.h
index a913b81..aad76e9 100644
--- a/perf/cairo-perf.h
+++ b/perf/cairo-perf.h
@@ -32,7 +32,7 @@
#include "cairo-perf-timer.h"
-extern int cairo_perf_duration;
+extern double cairo_perf_duration;
extern int cairo_perf_alarm_expired;
#if CAIRO_HAS_WIN32_SURFACE
More information about the cairo-commit
mailing list