Make perf interface return a rate. Start print target and test names.

This commit is contained in:
Carl Worth 2006-08-31 11:51:28 -07:00
parent fd13e874a7
commit 0c741675e1
3 changed files with 20 additions and 14 deletions

View file

@ -38,11 +38,7 @@ typedef struct _cairo_perf {
unsigned int max_size;
} cairo_perf_t;
cairo_perf_t perfs[] = {
{ "paint", paint, 32, 1024 },
{ "paint_alpha", paint_alpha, 32, 1024 },
{ NULL }
};
cairo_perf_t perfs[];
/* Some targets just aren't that interesting for performance testing,
* (not least because many of these surface types use a meta-surface
@ -88,6 +84,7 @@ main (int argc, char *argv[])
cairo_surface_t *surface;
cairo_t *cr;
unsigned int size;
double rate;
if (getenv("CAIRO_PERF_DURATION"))
cairo_perf_duration = strtol(getenv("CAIRO_PERF_DURATION"), NULL, 0);
@ -104,7 +101,11 @@ main (int argc, char *argv[])
size, size,
&target->closure);
cr = cairo_create (surface);
perf->run (cr, size, size);
rate = perf->run (cr, size, size);
if (perf->min_size == perf->max_size)
printf ("%s\t%s\t%g\n", target->name, perf->name, rate);
else
printf ("%s\t%s-%d\t%g\n", target->name, perf->name, size, rate);
}
}
}
@ -112,3 +113,8 @@ main (int argc, char *argv[])
return 0;
}
cairo_perf_t perfs[] = {
{ "paint", paint, 32, 1024 },
{ "paint_alpha", paint_alpha, 32, 1024 },
{ NULL }
};

View file

@ -64,9 +64,9 @@ extern int cairo_perf_alarm_expired;
#define CAIRO_PERF_LOOP_RATE(timervar) \
((timervar).count) / timer_elapsed (&(timervar))
typedef void (*cairo_perf_func_t) (cairo_t *cr, int width, int height);
typedef double (*cairo_perf_func_t) (cairo_t *cr, int width, int height);
#define CAIRO_PERF_DECL(func) void func (cairo_t *cr, int width, int height)
#define CAIRO_PERF_DECL(func) double func (cairo_t *cr, int width, int height)
CAIRO_PERF_DECL (paint);
CAIRO_PERF_DECL (paint_alpha);

View file

@ -25,7 +25,7 @@
#include "cairo-perf.h"
static void
static double
do_paint (cairo_t *cr)
{
cairo_perf_timer_t timer;
@ -36,22 +36,22 @@ do_paint (cairo_t *cr)
}
CAIRO_PERF_LOOP_FINI (timer);
printf ("Rate: %g\n", CAIRO_PERF_LOOP_RATE (timer));
return CAIRO_PERF_LOOP_RATE (timer);
}
void
double
paint (cairo_t *cr, int width, int height)
{
cairo_set_source_rgb (cr, 0.2, 0.6, 0.9);
do_paint (cr);
return do_paint (cr);
}
void
double
paint_alpha (cairo_t *cr, int width, int height)
{
cairo_set_source_rgb (cr, 0.2, 0.6, 0.9);
do_paint (cr);
return do_paint (cr);
}