mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-01-21 11:50:42 +01:00
perf: Add yield and fix double comparison
- add a yield () function that's called before every test. It reduced the std dev slightly for me - fix double comparisons to not just compare the integer part
This commit is contained in:
parent
bcb7863f00
commit
1bb6f9fb10
4 changed files with 32 additions and 2 deletions
|
|
@ -28,6 +28,9 @@
|
|||
#include <signal.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#ifdef _POSIX_PRIORITY_SCHEDULING
|
||||
#include <sched.h>
|
||||
#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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,4 +62,9 @@ alarm_handler (int signal);
|
|||
void
|
||||
set_alarm (double seconds);
|
||||
|
||||
/* yield */
|
||||
|
||||
void
|
||||
yield (void);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue