diff --git a/perf/cairo-perf.c b/perf/cairo-perf.c index 780cc8899..1f7e1673d 100644 --- a/perf/cairo-perf.c +++ b/perf/cairo-perf.c @@ -27,7 +27,7 @@ #include "cairo-perf.h" -int cairo_perf_duration = -1; +int cairo_perf_duration = 5; int cairo_perf_alarm_expired = 0; @@ -80,24 +80,6 @@ target_is_measurable (cairo_test_target_t *target) } } -void -start_timing (bench_timer_t *tr) { - if (cairo_perf_duration == -1) { - if (getenv("CAIRO_PERF_DURATION")) - cairo_perf_duration = strtol(getenv("CAIRO_PERF_DURATION"), NULL, 0); - else - cairo_perf_duration = 5; - } - tr->count = 0; - timer_start (tr); - set_alarm (cairo_perf_duration); -} - -void -stop_timing (bench_timer_t *tr) { - timer_stop (tr); -} - int main (int argc, char *argv[]) { @@ -108,6 +90,9 @@ main (int argc, char *argv[]) cairo_t *cr; unsigned int size; + if (getenv("CAIRO_PERF_DURATION")) + cairo_perf_duration = strtol(getenv("CAIRO_PERF_DURATION"), NULL, 0); + for (i = 0; targets[i].name; i++) { target = &targets[i]; if (! target_is_measurable (target)) diff --git a/perf/cairo-perf.h b/perf/cairo-perf.h index 23c377a3d..bea7494f3 100644 --- a/perf/cairo-perf.h +++ b/perf/cairo-perf.h @@ -43,12 +43,6 @@ typedef struct { #include "timer-alarm.h" -void -start_timing (bench_timer_t *tr); - -void -stop_timing (bench_timer_t *tr); - extern int cairo_perf_duration; extern int cairo_perf_alarm_expired; @@ -58,20 +52,24 @@ extern int cairo_perf_alarm_expired; * out how to do an async timer. On a quiet system, this doesn't * seem to significantly affect the results. */ -# define PERF_LOOP_INIT(timervar) do { \ - start_timing(&(timervar)); \ - while (! cairo_perf_alarm_expired) { \ +# define PERF_LOOP_INIT(timervar) do { \ + timervar.count = 0; \ + timer_start (&(timervar)); \ + set_alarm (cairo_perf_duration); \ + while (! cairo_perf_alarm_expired) { \ SleepEx(0, TRUE) #else -# define PERF_LOOP_INIT(timervar) do { \ - start_timing(&(timervar)); \ +# define PERF_LOOP_INIT(timervar) do { \ + timervar.count = 0; \ + timer_start (&(timervar)); \ + set_alarm (cairo_perf_duration); \ while (! cairo_perf_alarm_expired) { #endif -#define PERF_LOOP_FINI(timervar) \ - (timervar).count++; \ - } \ - stop_timing (&(timervar)); \ +#define PERF_LOOP_FINI(timervar) \ + (timervar).count++; \ + } \ + timer_stop (&(timervar)); \ } while (0) #define PERF_LOOP_RATE(timervar) \