diff --git a/perf/cairo-perf-timer-posix.c b/perf/cairo-perf-timer-posix.c index 2d91894e7..29fd3fb4a 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 f3975fa94..c03256def 100644 --- a/perf/cairo-perf-timer-win32.c +++ b/perf/cairo-perf-timer-win32.c @@ -64,7 +64,7 @@ alarm_handler (void *closure, DWORD dwTimerLowValue, DWORD dwTimerHighValue) { 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 bea91c2d3..e9344377b 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 6c88a6e2b..c750381b7 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 a913b81f9..aad76e91d 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