perf: Drop separate setup function from each test case.

We are already doing loop measurement internally, so each function
can already do any setup it needs without it affecting the measurement.
This commit is contained in:
Carl Worth 2006-08-31 11:42:51 -07:00
parent 578b74473d
commit fd13e874a7
3 changed files with 22 additions and 20 deletions

View file

@ -33,15 +33,14 @@ int cairo_perf_alarm_expired = 0;
typedef struct _cairo_perf {
const char *name;
cairo_perf_func_t setup;
cairo_perf_func_t run;
unsigned int min_size;
unsigned int max_size;
} cairo_perf_t;
cairo_perf_t perfs[] = {
{ "paint", paint_setup, paint, 32, 1024 },
{ "paint_alpha", paint_alpha_setup, paint, 32, 1024 },
{ "paint", paint, 32, 1024 },
{ "paint_alpha", paint_alpha, 32, 1024 },
{ NULL }
};
@ -105,7 +104,6 @@ main (int argc, char *argv[])
size, size,
&target->closure);
cr = cairo_create (surface);
perf->setup (cr, size, size);
perf->run (cr, size, size);
}
}

View file

@ -68,8 +68,7 @@ typedef void (*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)
CAIRO_PERF_DECL (paint_setup);
CAIRO_PERF_DECL (paint_alpha_setup);
CAIRO_PERF_DECL (paint);
CAIRO_PERF_DECL (paint_alpha);
#endif

View file

@ -25,20 +25,8 @@
#include "cairo-perf.h"
void
paint_setup (cairo_t *cr, int width, int height)
{
cairo_set_source_rgba (cr, 1.0, 0.2, 0.6, 0.5);
}
void
paint_alpha_setup (cairo_t *cr, int width, int height)
{
cairo_set_source_rgb (cr, 0.2, 0.6, 0.9);
}
void
paint (cairo_t *cr, int width, int height)
static void
do_paint (cairo_t *cr)
{
cairo_perf_timer_t timer;
@ -50,3 +38,20 @@ paint (cairo_t *cr, int width, int height)
printf ("Rate: %g\n", CAIRO_PERF_LOOP_RATE (timer));
}
void
paint (cairo_t *cr, int width, int height)
{
cairo_set_source_rgb (cr, 0.2, 0.6, 0.9);
do_paint (cr);
}
void
paint_alpha (cairo_t *cr, int width, int height)
{
cairo_set_source_rgb (cr, 0.2, 0.6, 0.9);
do_paint (cr);
}