[cairo-commit] perf/cairo-perf-micro.c

Chris Wilson ickle at kemper.freedesktop.org
Mon Aug 1 05:00:40 PDT 2011


 perf/cairo-perf-micro.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

New commits:
commit c5405f732410fe851b8d4c73365336ec2490358b
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Aug 1 12:59:11 2011 +0100

    perf: Save/restore gstate across runs
    
    Reset the cairo_t to the initial state so that subsequent tests are not
    affected by earlier tests.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/perf/cairo-perf-micro.c b/perf/cairo-perf-micro.c
index 1937440..ee5269a 100644
--- a/perf/cairo-perf-micro.c
+++ b/perf/cairo-perf-micro.c
@@ -203,7 +203,9 @@ cairo_perf_run (cairo_perf_t	   *perf,
 		   name, perf->target->name,
 		   _content_to_string (perf->target->content, 0),
 		   perf->size);
+	cairo_save (perf->cr);
 	perf_func (perf->cr, perf->size, perf->size, 1);
+	cairo_restore (perf->cr);
 	status = cairo_surface_write_to_png (cairo_get_target (perf->cr), filename);
 	if (status) {
 	    fprintf (stderr, "Failed to generate output check '%s': %s\n",
@@ -232,10 +234,14 @@ cairo_perf_run (cairo_perf_t	   *perf,
 	if (similar)
 	    cairo_push_group_with_content (perf->cr,
 					   cairo_boilerplate_content (perf->target->content));
+	else
+	    cairo_save (perf->cr);
 	perf_func (perf->cr, perf->size, perf->size, 1);
 	loops = cairo_perf_calibrate (perf, perf_func);
 	if (similar)
 	    cairo_pattern_destroy (cairo_pop_group (perf->cr));
+	else
+	    cairo_restore (perf->cr);
 
 	low_std_dev_count = 0;
 	for (i =0; i < perf->iterations; i++) {
@@ -243,10 +249,13 @@ cairo_perf_run (cairo_perf_t	   *perf,
 	    if (similar)
 		cairo_push_group_with_content (perf->cr,
 					       cairo_boilerplate_content (perf->target->content));
+	    else
+		cairo_save (perf->cr);
 	    times[i] = perf_func (perf->cr, perf->size, perf->size, loops) / loops;
 	    if (similar)
 		cairo_pattern_destroy (cairo_pop_group (perf->cr));
-
+	    else
+		cairo_restore (perf->cr);
 	    if (perf->raw) {
 		if (i == 0)
 		    printf ("[*] %s.%s %s.%d %g",


More information about the cairo-commit mailing list