[cairo] Cairo 1.3 performance loss

David Turner david at freetype.org
Thu Feb 1 02:51:26 PST 2007


> This still times individual iterations (but runs X of them and takes the
> median). The problem is that on this machine gettimeofday()'s
> granularity is too coarse to register any difference in time for many of
> the tests.
> 

Sorry for the confusion, here's a patch that adds a '-m' flag to cairo-perf
that can be used to specify test case multipliers. You can also define
the CAIRO_PERF_MULTIPLIER environment variable.

Hope this helps,

- David
-------------- next part --------------
From f233cfdd4541e47924b459f77d2313a796199cb0 Mon Sep 17 00:00:00 2001
From: David Turner <david at freetype.org>
Date: Thu, 1 Feb 2007 11:49:38 +0100
Subject: [PATCH] adding -m multiplier flag to cairo-perf program, used to specify test case multipliers
---
 perf/cairo-perf.c |   25 +++++++++++++++++++++++--
 perf/cairo-perf.h |    1 +
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/perf/cairo-perf.c b/perf/cairo-perf.c
index 18cc652..ceca3eb 100644
--- a/perf/cairo-perf.c
+++ b/perf/cairo-perf.c
@@ -143,7 +143,15 @@ cairo_perf_run (cairo_perf_t		*perf,
     low_std_dev_count = 0;
     for (i =0; i < perf->iterations; i++) {
 	cairo_perf_yield ();
-	times[i] = (perf_func) (perf->cr, perf->size, perf->size);
+
+	if (perf->multiplier > 1) {
+		int  count;
+		times[i] = 0;
+		for (count = perf->multiplier; count > 0; count--)
+			times[i] += (perf_func) (perf->cr, perf->size, perf->size);
+        }
+	else	
+	    times[i] = (perf_func) (perf->cr, perf->size, perf->size);
 
 	if (perf->raw) {
 	    if (i == 0)
@@ -200,6 +208,7 @@ usage (const char *argv0)
 	     "\n"
 	     "  -r	raw; display each time measurement instead of summary statistics\n"
 	     "  -i	iterations; specify the number of iterations per test case\n"
+	     "  -m      multiplier; specify the number of times each test case is repeated in an iteration\n"
 	     "  -l	list only; just list selected test case names without executing\n"
 	     "\n"
 	     "If test names are given they are used as sub-string matches so a command\n"
@@ -219,13 +228,17 @@ parse_options (cairo_perf_t *perf, int a
 	perf->iterations = CAIRO_PERF_ITERATIONS_DEFAULT;
     perf->exact_iterations = 0;
 
+    perf->multiplier = 1;
+    if (getenv("CAIRO_PERF_MULTIPLIER"))
+	perf->multiplier = strtol(getenv("CAIRO_PERF_MULTIPLIER"), NULL, 0);
+
     perf->raw = FALSE;
     perf->list_only = FALSE;
     perf->names = NULL;
     perf->num_names = 0;
 
     while (1) {
-	c = getopt (argc, argv, "i:lr");
+	c = getopt (argc, argv, "i:m:lr");
 	if (c == -1)
 	    break;
 
@@ -239,6 +252,14 @@ parse_options (cairo_perf_t *perf, int a
 		exit (1);
 	    }
 	    break;
+	case 'm':
+	    perf->multiplier = strtoul (optarg, &end, 10);
+	    if (*end != '\0') {
+		fprintf (stderr, "Invalid argument for -m (not an integer): %s\n",
+			 optarg);
+		exit (1);
+	    }
+	    break;
 	case 'l':
 	    perf->list_only = TRUE;
 	    break;
diff --git a/perf/cairo-perf.h b/perf/cairo-perf.h
index 1ef9600..17a60ef 100644
--- a/perf/cairo-perf.h
+++ b/perf/cairo-perf.h
@@ -64,6 +64,7 @@ cairo_perf_yield (void);
 typedef struct _cairo_perf {
     /* Options from command-line */
     unsigned int iterations;
+    unsigned int multiplier;
     cairo_bool_t exact_iterations;
     cairo_bool_t raw;
     cairo_bool_t list_only;
-- 
1.4.1



More information about the cairo mailing list