From d0aae4dbcf6d3ca67a4a7b364fba80f719af2ac1 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 4 Oct 2006 13:23:50 -0700 Subject: [PATCH] perf: Make cairo_t* available to perf functions --- perf/README | 33 ++++++++++++++++----------------- perf/cairo-perf.c | 2 +- perf/cairo-perf.h | 2 +- perf/paint.c | 2 +- perf/tessellate.c | 2 +- 5 files changed, 20 insertions(+), 21 deletions(-) diff --git a/perf/README b/perf/README index 31dfc2f9b..6965c3f94 100644 --- a/perf/README +++ b/perf/README @@ -40,29 +40,28 @@ Here is the basic structure of a performance test file: static cairo_perf_ticks_t do_my_new_test (cairo_t *cr, int width, int height) + { + cairo_perf_timer_start (); + + /* Make the cairo calls to be measured */ + + cairo_perf_timer_stop (); + + return cairo_perf_timer_elapsed (); + } + + void + my_new_test (cairo_perf_t *perf, cairo_t *cr, int width, int height) { /* First do any setup for which the execution time should not * be measured. For example, this might include loading * images from disk, creating patterns, etc. */ - cairo_perf_timer_start (); - - /* Now make the real cairo calls to be measured */ - - cairo_perf_timer_stop (); - - /* Finally, any cleanup */ - - /* Then return the time that elapsed. */ - - return cairo_perf_timer_elapsed (); - } - - void - my_new_test (cairo_perf_t *perf) - { + /* Then launch the actual performance testing. */ cairo_perf_run (perf, "my_new_test", do_my_new_test); - } + + /* Finally, perform any cleanup from the setup above. */ + } That's really all there is to writing a new test. The first function above is the one that does the real work and returns a timing diff --git a/perf/cairo-perf.c b/perf/cairo-perf.c index b2768c3f9..e786ab722 100644 --- a/perf/cairo-perf.c +++ b/perf/cairo-perf.c @@ -223,7 +223,7 @@ main (int argc, char *argv[]) target->closure); perf.cr = cairo_create (surface); - perf_case->run (&perf); + perf_case->run (&perf, perf.cr, perf.size, perf.size); cairo_surface_destroy (surface); } diff --git a/perf/cairo-perf.h b/perf/cairo-perf.h index 6b40ae886..5c5ec21b6 100644 --- a/perf/cairo-perf.h +++ b/perf/cairo-perf.h @@ -69,7 +69,7 @@ cairo_perf_run (cairo_perf_t *perf, const char *name, cairo_perf_func_t perf_func); -#define CAIRO_PERF_DECL(func) void (func) (cairo_perf_t *perf); +#define CAIRO_PERF_DECL(func) void (func) (cairo_perf_t *perf, cairo_t *cr, int width, int height); /* paint.c */ CAIRO_PERF_DECL (paint); diff --git a/perf/paint.c b/perf/paint.c index 324f397ac..de28d3c89 100644 --- a/perf/paint.c +++ b/perf/paint.c @@ -168,7 +168,7 @@ paint_source_surface_argb32 (cairo_t *cr, int width, int height) } void -paint (cairo_perf_t *perf) +paint (cairo_perf_t *perf, cairo_t *cr, int width, int height) { cairo_perf_run (perf, "paint_over_solid", paint_over_solid); cairo_perf_run (perf, "paint_over_solid_alpha", paint_over_solid_alpha); diff --git a/perf/tessellate.c b/perf/tessellate.c index e8f3dd675..fc97db70a 100644 --- a/perf/tessellate.c +++ b/perf/tessellate.c @@ -141,7 +141,7 @@ tessellate_256 (cairo_t *cr, int width, int height) } void -tessellate (cairo_perf_t *perf) +tessellate (cairo_perf_t *perf, cairo_t *cr, int width, int height) { cairo_perf_run (perf, "tessellate-16", tessellate_16); cairo_perf_run (perf, "tessellate-64", tessellate_64);