[cairo-commit] 2 commits - perf/cairo-perf.c
Carl Worth
cworth at kemper.freedesktop.org
Thu Aug 31 13:22:20 PDT 2006
perf/cairo-perf.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 64 insertions(+), 8 deletions(-)
New commits:
diff-tree 19a5b8b9b53219dc8ae508a2fcd7b2ca617bc9b8 (from 689e9c446eb0ec69cb560fa44f4a1f6a0b28cb17)
Author: Carl Worth <cworth at cworth.org>
Date: Thu Aug 31 13:22:17 2006 -0700
perf: Run for multiple iterations and print std. deviation
diff --git a/perf/cairo-perf.c b/perf/cairo-perf.c
index 0b57969..6c88a6e 100644
--- a/perf/cairo-perf.c
+++ b/perf/cairo-perf.c
@@ -27,7 +27,9 @@
#include "cairo-perf.h"
-int cairo_perf_duration = 5;
+int cairo_perf_duration = 1;
+
+int cairo_perf_iterations = 10;
int cairo_perf_alarm_expired = 0;
@@ -90,20 +92,55 @@ _content_to_string (cairo_content_t cont
}
}
+typedef struct _stats
+{
+ double mean;
+ double std_dev;
+} stats_t;
+
+static void
+_compute_stats (double *values, int num_values, stats_t *stats)
+{
+ int i;
+ double sum, delta;
+
+ sum = 0.0;
+ for (i = 0; i < num_values; i++)
+ sum += values[i];
+
+ stats->mean = sum / num_values;
+
+ sum = 0.0;
+ for (i = 0; i < num_values; i++) {
+ delta = values[i] - stats->mean;
+ sum += delta * delta;
+ }
+
+ /* Let's use a std. deviation normalized to the mean for easier
+ * comparison. */
+ stats->std_dev = sqrt(sum / num_values) / stats->mean;
+}
+
int
main (int argc, char *argv[])
{
- int i, j;
+ int i, j, k;
cairo_test_target_t *target;
cairo_perf_t *perf;
cairo_surface_t *surface;
cairo_t *cr;
unsigned int size;
- double rate;
+ double *rates;
+ stats_t stats;
if (getenv("CAIRO_PERF_DURATION"))
cairo_perf_duration = strtol(getenv("CAIRO_PERF_DURATION"), NULL, 0);
+ if (getenv("CAIRO_PERF_ITERATIONS"))
+ cairo_perf_iterations = strtol(getenv("CAIRO_PERF_ITERATIONS"), NULL, 0);
+
+ rates = xmalloc (cairo_perf_iterations * sizeof (double));
+
for (i = 0; targets[i].name; i++) {
target = &targets[i];
if (! target_is_measurable (target))
@@ -116,15 +153,15 @@ main (int argc, char *argv[])
size, size,
&target->closure);
cr = cairo_create (surface);
- rate = perf->run (cr, size, size);
- if (perf->min_size == perf->max_size)
- printf ("%s-%s\t%s\t%g\n",
- target->name, _content_to_string (target->content),
- perf->name, rate);
- else
- printf ("%s-%s\t%s-%d\t%g\n",
- target->name, _content_to_string (target->content),
- perf->name, size, rate);
+ for (k =0; k < cairo_perf_iterations; k++)
+ rates[k] = perf->run (cr, size, size);
+ _compute_stats (rates, cairo_perf_iterations, &stats);
+ if (i==0 && j==0 && size == perf->min_size)
+ printf ("backend-content\ttest-size\trate\tstd dev.\titerations\n");
+ printf ("%s-%s\t%s-%d\t%g\t%g%%\t%d\n",
+ target->name, _content_to_string (target->content),
+ perf->name, size,
+ stats.mean, stats.std_dev * 100.0, cairo_perf_iterations);
}
}
}
diff-tree 689e9c446eb0ec69cb560fa44f4a1f6a0b28cb17 (from 7917e1201fd38089111bb7723256747ae32347e0)
Author: Carl Worth <cworth at cworth.org>
Date: Thu Aug 31 12:34:21 2006 -0700
perf: Add indication of content to output
diff --git a/perf/cairo-perf.c b/perf/cairo-perf.c
index c442afb..0b57969 100644
--- a/perf/cairo-perf.c
+++ b/perf/cairo-perf.c
@@ -75,6 +75,21 @@ target_is_measurable (cairo_test_target_
}
}
+static const char *
+_content_to_string (cairo_content_t content)
+{
+ switch (content) {
+ case CAIRO_CONTENT_COLOR:
+ return "rgb";
+ case CAIRO_CONTENT_ALPHA:
+ return "a";
+ case CAIRO_CONTENT_COLOR_ALPHA:
+ return "rgba";
+ default:
+ return "<unknown_content>";
+ }
+}
+
int
main (int argc, char *argv[])
{
@@ -103,9 +118,13 @@ main (int argc, char *argv[])
cr = cairo_create (surface);
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);
+ printf ("%s-%s\t%s\t%g\n",
+ target->name, _content_to_string (target->content),
+ perf->name, rate);
else
- printf ("%s\t%s-%d\t%g\n", target->name, perf->name, size, rate);
+ printf ("%s-%s\t%s-%d\t%g\n",
+ target->name, _content_to_string (target->content),
+ perf->name, size, rate);
}
}
}
More information about the cairo-commit
mailing list