diff --git a/perf/cairo-perf-timer-posix.c b/perf/cairo-perf-timer-posix.c index 29fd3fb4a..1e9575fe7 100644 --- a/perf/cairo-perf-timer-posix.c +++ b/perf/cairo-perf-timer-posix.c @@ -28,6 +28,9 @@ #include #include #include +#ifdef _POSIX_PRIORITY_SCHEDULING +#include +#endif #include "cairo-perf.h" @@ -81,3 +84,12 @@ set_alarm (double seconds) { setitimer (ITIMER_REAL, &tr, NULL); } + +/* yield */ + +void +yield (void) { +#ifdef _POSIX_PRIORITY_SCHEDULING + sched_yield (); +#endif +} diff --git a/perf/cairo-perf-timer-win32.c b/perf/cairo-perf-timer-win32.c index c03256def..ce813e0a6 100644 --- a/perf/cairo-perf-timer-win32.c +++ b/perf/cairo-perf-timer-win32.c @@ -74,3 +74,10 @@ set_alarm (double seconds) { if (!SetWaitableTimer (hTimer, &expTime, 0, alarm_handler, &cairo_perf_alarm_expired, FALSE)) fprintf (stderr, "SetWaitableTimer failed!\n"); } + +/* yield */ + +void +yield (void) { + SleepEx(0, TRUE); +} diff --git a/perf/cairo-perf-timer.h b/perf/cairo-perf-timer.h index e9344377b..37a5184b1 100644 --- a/perf/cairo-perf-timer.h +++ b/perf/cairo-perf-timer.h @@ -62,4 +62,9 @@ alarm_handler (int signal); void set_alarm (double seconds); +/* yield */ + +void +yield (void); + #endif diff --git a/perf/cairo-perf.c b/perf/cairo-perf.c index 4cef04699..32d96d3f1 100644 --- a/perf/cairo-perf.c +++ b/perf/cairo-perf.c @@ -102,7 +102,11 @@ compare_doubles (const void *_a, const void *_b) const double *a = _a; const double *b = _b; - return *a - *b; + if (*a > *b) + return 1; + if (*a < *b) + return -1; + return 0; } static void @@ -162,8 +166,10 @@ main (int argc, char *argv[]) size, size, &target->closure); cr = cairo_create (surface); - for (k =0; k < cairo_perf_iterations; k++) + for (k =0; k < cairo_perf_iterations; k++) { + yield (); rates[k] = perf->run (cr, size, size); + } _compute_stats (rates, cairo_perf_iterations, &stats); if (i==0 && j==0 && size == perf->min_size) printf ("backend-content\ttest-size\trate\tstd dev.\titerations\n");