summaryrefslogtreecommitdiff
path: root/perf
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2007-10-19 23:25:57 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2007-10-20 00:32:00 +0100
commitae2535e4cb7c09eda1be13079d7a23b262aaef7b (patch)
tree3d65d24f7bb685d9b2832e0f48c79a03100ff3c6 /perf
parent081507a09e61e1e4a048e40f8ba67a76aa76bbef (diff)
[cairo-perf] Run performance tests over similar surfaces as well.
Immediately repeat the performance test against a similar surface to ensure that they introduce no regressions. Primarily introduced to sanity check the change to use XShmPixmaps instead of XPixmaps in the xlib backend, but it should be generally useful.
Diffstat (limited to 'perf')
-rw-r--r--perf/cairo-perf.c121
1 files changed, 75 insertions, 46 deletions
diff --git a/perf/cairo-perf.c b/perf/cairo-perf.c
index 388bfa7a6..de88a87b2 100644
--- a/perf/cairo-perf.c
+++ b/perf/cairo-perf.c
@@ -105,27 +105,45 @@ target_is_measurable (cairo_boilerplate_target_t *target)
}
static const char *
-_content_to_string (cairo_content_t content)
+_content_to_string (cairo_content_t content, cairo_bool_t similar)
{
- switch (content) {
+ switch (content|similar) {
case CAIRO_CONTENT_COLOR:
return "rgb";
+ case CAIRO_CONTENT_COLOR|1:
+ return "rgb&";
case CAIRO_CONTENT_ALPHA:
return "a";
+ case CAIRO_CONTENT_ALPHA|1:
+ return "a&";
case CAIRO_CONTENT_COLOR_ALPHA:
return "rgba";
+ case CAIRO_CONTENT_COLOR_ALPHA|1:
+ return "rgba&";
default:
return "<unknown_content>";
}
}
+static cairo_bool_t
+cairo_perf_has_similar (cairo_perf_t *perf)
+{
+ cairo_surface_t *target = cairo_get_target (perf->cr);
+
+ /* exclude the image backend */
+ if (cairo_surface_get_type (target) == CAIRO_SURFACE_TYPE_IMAGE)
+ return FALSE;
+
+ return TRUE;
+}
+
void
cairo_perf_run (cairo_perf_t *perf,
const char *name,
cairo_perf_func_t perf_func)
{
static cairo_bool_t first_run = TRUE;
- unsigned int i;
+ unsigned int i, similar, has_similar;
cairo_perf_ticks_t *times;
cairo_stats_t stats = {0.0, 0.0};
int low_std_dev_count;
@@ -156,56 +174,67 @@ cairo_perf_run (cairo_perf_t *perf,
times = xmalloc (perf->iterations * sizeof (cairo_perf_ticks_t));
- /* We run one iteration in advance to warm caches, etc. */
- cairo_perf_yield ();
- (perf_func) (perf->cr, perf->size, perf->size);
-
- low_std_dev_count = 0;
- for (i =0; i < perf->iterations; i++) {
+ has_similar = cairo_perf_has_similar (perf);
+ for (similar = 0; similar <= has_similar; similar++) {
+ /* We run one iteration in advance to warm caches, etc. */
cairo_perf_yield ();
- times[i] = (perf_func) (perf->cr, perf->size, perf->size);
+ if (similar)
+ cairo_push_group_with_content (perf->cr, perf->target->content);
+ (perf_func) (perf->cr, perf->size, perf->size);
+ if (similar)
+ cairo_pattern_destroy (cairo_pop_group (perf->cr));
+
+ low_std_dev_count = 0;
+ for (i =0; i < perf->iterations; i++) {
+ cairo_perf_yield ();
+ if (similar)
+ cairo_push_group_with_content (perf->cr, perf->target->content);
+ times[i] = (perf_func) (perf->cr, perf->size, perf->size);
+ if (similar)
+ cairo_pattern_destroy (cairo_pop_group (perf->cr));
+
+ if (perf->raw) {
+ if (i == 0)
+ printf ("[*] %s-%s %s-%d %g",
+ perf->target->name,
+ _content_to_string (perf->target->content, similar),
+ name, perf->size,
+ cairo_perf_ticks_per_second () / 1000.0);
+ printf (" %lld", times[i]);
+ } else if (! perf->exact_iterations) {
+ if (i > 0) {
+ _cairo_stats_compute (&stats, times, i+1);
+
+ if (stats.std_dev <= CAIRO_PERF_LOW_STD_DEV)
+ {
+ low_std_dev_count++;
+ if (low_std_dev_count >= CAIRO_PERF_STABLE_STD_DEV_COUNT)
+ break;
+ } else {
+ low_std_dev_count = 0;
+ }
+ }
+ }
+ }
if (perf->raw) {
- if (i == 0)
- printf ("[*] %s-%s %s-%d %g",
- perf->target->name,
- _content_to_string (perf->target->content),
- name, perf->size,
- cairo_perf_ticks_per_second () / 1000.0);
- printf (" %lld", times[i]);
+ printf ("\n");
} else {
- if (i > 0) {
- _cairo_stats_compute (&stats, times, i+1);
-
- if (stats.std_dev <= CAIRO_PERF_LOW_STD_DEV &&
- ! perf->exact_iterations)
- {
- low_std_dev_count++;
- if (low_std_dev_count >= CAIRO_PERF_STABLE_STD_DEV_COUNT)
- break;
- } else {
- low_std_dev_count = 0;
- }
- }
+ _cairo_stats_compute (&stats, times, i);
+ printf ("[%3d] %8s-%-5s %26s-%-3d ",
+ perf->test_number, perf->target->name,
+ _content_to_string (perf->target->content, similar),
+ name, perf->size);
+
+ printf ("%10lld %#8.3f %#8.3f %#5.2f%% %3d\n",
+ stats.min_ticks,
+ (stats.min_ticks * 1000.0) / cairo_perf_ticks_per_second (),
+ (stats.median_ticks * 1000.0) / cairo_perf_ticks_per_second (),
+ stats.std_dev * 100.0, stats.iterations);
}
- }
- if (perf->raw) {
- printf ("\n");
- } else {
- printf ("[%3d] %8s-%-4s %26s-%-3d ",
- perf->test_number, perf->target->name,
- _content_to_string (perf->target->content),
- name, perf->size);
-
- printf ("%10lld %#8.3f %#8.3f %#5.2f%% %3d\n",
- stats.min_ticks,
- (stats.min_ticks * 1000.0) / cairo_perf_ticks_per_second (),
- (stats.median_ticks * 1000.0) / cairo_perf_ticks_per_second (),
- stats.std_dev * 100.0, stats.iterations);
+ perf->test_number++;
}
-
- perf->test_number++;
free (times);
}