From df8cc10073b0cacd198eda5a24f2b2f61a0a7085 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 5 Sep 2006 22:48:38 -0700 Subject: [PATCH] perf: Make cairo_perf_timer structure private. Make timer functions void. --- perf/cairo-perf-timer-posix.c | 22 +++++++++++++++------- perf/cairo-perf-timer-win32.c | 20 ++++++++++++++------ perf/cairo-perf-timer.h | 17 ++++------------- perf/paint.c | 7 +++---- 4 files changed, 36 insertions(+), 30 deletions(-) diff --git a/perf/cairo-perf-timer-posix.c b/perf/cairo-perf-timer-posix.c index 1e9575fe7..7c7ec19b2 100644 --- a/perf/cairo-perf-timer-posix.c +++ b/perf/cairo-perf-timer-posix.c @@ -36,22 +36,30 @@ /* timers */ +static cairo_perf_timer_t tr; + +struct _cairo_perf_timer_t +{ + struct timeval start; + struct timeval stop; +}; + void -timer_start (cairo_perf_timer_t *tr) { - gettimeofday (&tr->start, NULL); +timer_start (void) { + gettimeofday (&tr.start, NULL); } void -timer_stop (cairo_perf_timer_t *tr) { - gettimeofday (&tr->stop, NULL); +timer_stop (void) { + gettimeofday (&tr.stop, NULL); } double -timer_elapsed (cairo_perf_timer_t *tr) { +timer_elapsed (void) { double d; - d = tr->stop.tv_sec - tr->start.tv_sec; - d += (tr->stop.tv_usec - tr->start.tv_usec) / 1000000.0; + d = tr.stop.tv_sec - tr.start.tv_sec; + d += (tr.stop.tv_usec - tr.start.tv_usec) / 1000000.0; return d; } diff --git a/perf/cairo-perf-timer-win32.c b/perf/cairo-perf-timer-win32.c index ce813e0a6..679abca3f 100644 --- a/perf/cairo-perf-timer-win32.c +++ b/perf/cairo-perf-timer-win32.c @@ -34,24 +34,32 @@ /* timers */ +struct _cairo_perf_timer_t +{ + LARGE_INTEGER start; + LARGE_INTEGER stop; +}; + +static cairo_perf_timer_t tr; + void -timer_start (cairo_perf_timer_t *tr) { - QueryPerformanceCounter(&tr->start); +timer_start (void) { + QueryPerformanceCounter(&tr.start); } void -timer_stop (cairo_perf_timer_t *tr) { - QueryPerformanceCounter(&tr->stop); +timer_stop (void) { + QueryPerformanceCounter(&tr.stop); } double -timer_elapsed (cairo_perf_timer_t *tr) { +timer_elapsed (void) { double d; LARGE_INTEGER freq; QueryPerformanceFrequency(&freq); - d = (tr->stop.QuadPart - tr->start.QuadPart) / (double) freq.QuadPart; + d = (tr.stop.QuadPart - tr.start.QuadPart) / (double) freq.QuadPart; return d; } diff --git a/perf/cairo-perf-timer.h b/perf/cairo-perf-timer.h index 37a5184b1..b03ddce61 100644 --- a/perf/cairo-perf-timer.h +++ b/perf/cairo-perf-timer.h @@ -30,29 +30,20 @@ #include "cairo-perf.h" -typedef struct _cairo_perf_timer_t { -#ifdef USE_WINAPI - LARGE_INTEGER start; - LARGE_INTEGER stop; -#else - struct timeval start; - struct timeval stop; -#endif - long count; -} cairo_perf_timer_t; +typedef struct _cairo_perf_timer_t cairo_perf_timer_t; /* timers */ extern int alarm_expired; void -timer_start (cairo_perf_timer_t *tr); +timer_start (void); void -timer_stop (cairo_perf_timer_t *tr); +timer_stop (void); double -timer_elapsed (cairo_perf_timer_t *tr); +timer_elapsed (void); /* alarms */ diff --git a/perf/paint.c b/perf/paint.c index 97b8de5f0..858f15dd1 100644 --- a/perf/paint.c +++ b/perf/paint.c @@ -29,16 +29,15 @@ static double do_paint (cairo_t *cr) { int i; - cairo_perf_timer_t timer; - timer_start (&timer); + timer_start (); for (i=0; i < 3; i++) cairo_paint (cr); - timer_stop (&timer); + timer_stop (); - return 1.0 / timer_elapsed (&timer); + return 1.0 / timer_elapsed (); } double