[cairo-commit] 3 commits - perf/cairo-perf-diff-files.c
test/.gitignore test/Makefile.am
test/scale-down-source-surface-paint.c
test/scale-down-source-surface-paint-ref.png
Carl Worth
cworth at kemper.freedesktop.org
Fri Jan 19 16:47:32 PST 2007
perf/cairo-perf-diff-files.c | 151 ++++++++++++++++++++-------
test/.gitignore | 1
test/Makefile.am | 2
test/scale-down-source-surface-paint-ref.png |binary
test/scale-down-source-surface-paint.c | 72 ++++++++++++
5 files changed, 188 insertions(+), 38 deletions(-)
New commits:
diff-tree 2f6d184e6659e91909ed933d36bef441f1b5df4d (from 8354906381b2ccc3211214bad55c1f505d3dce3a)
Author: Kalle Vahlman <kalle.vahlman at gmail.com>
Date: Sat Jan 13 12:36:03 2007 +0200
Add --use-ms option to cairo-perf-diff-files
This allows for comparing perf files generation on different hardware
platforms, (since the ticks can be very different on different hardware).
diff --git a/perf/cairo-perf-diff-files.c b/perf/cairo-perf-diff-files.c
index d72cb8d..8b6292a 100644
--- a/perf/cairo-perf-diff-files.c
+++ b/perf/cairo-perf-diff-files.c
@@ -135,6 +135,7 @@ typedef struct _cairo_perf_diff_files_ar
double min_change;
int use_utf;
int print_change_bars;
+ int use_ms;
} cairo_perf_diff_files_args_t;
/* Ad-hoc parsing, macros with a strong dependence on the calling
@@ -533,7 +534,14 @@ cairo_perf_report_diff (cairo_perf_repor
diffs[num_diffs].old = o;
diffs[num_diffs].new = n;
- diffs[num_diffs].speedup = (double) o->stats.min_ticks / n->stats.min_ticks;
+ if (args->use_ms) {
+ diffs[num_diffs].speedup =
+ (double) (o->stats.min_ticks / o->stats.ticks_per_ms)
+ / (n->stats.min_ticks / n->stats.ticks_per_ms);
+ } else {
+ diffs[num_diffs].speedup =
+ (double) o->stats.min_ticks / n->stats.min_ticks;
+ }
num_diffs++;
i_old++;
@@ -619,6 +627,9 @@ usage (const char *argv0)
"--no-utf Use ascii stars instead of utf-8 change bars.\n"
" Four stars are printed per factor of speedup.\n"
"--no-bars Don't display change bars at all.\n"
+ "--use-ms Use milliseconds to calculate differences.\n"
+ " (instead of ticks which are hardware dependant)\n"
+
);
exit(1);
}
@@ -639,6 +650,9 @@ parse_args(int argc,
else if (is_yesno_opt("bars")) {
args->print_change_bars = 0 != strncmp ("--no-", argv[i], 4);
}
+ else if (strcmp(argv[i], "--use-ms") == 0) {
+ args->use_ms = 1;
+ }
else if (!args->old_filename) {
args->old_filename = argv[i];
}
diff-tree 8354906381b2ccc3211214bad55c1f505d3dce3a (from d91d5d12f3a40beebefcd8a5d8b912f5492e112b)
Author: M Joonas Pihlaja <jpihlaja at cc.helsinki.fi>
Date: Sat Dec 16 22:21:36 2006 +0200
Make UTF-8 output from cairo-perf-diff-files optional
This patch adds options to disable the UTF-8 change bars and replace
them with ASCII '*' gfx. The motivation is that UTF-8 really does some
damage to some terminals, and some always forget to pipe stuff through
a pager to make it safe. The new options for cairo-perf-diff-files are:
--no-utf
--no-bars
diff --git a/perf/cairo-perf-diff-files.c b/perf/cairo-perf-diff-files.c
index e6bb095..d72cb8d 100644
--- a/perf/cairo-perf-diff-files.c
+++ b/perf/cairo-perf-diff-files.c
@@ -129,6 +129,14 @@ typedef enum {
TEST_REPORT_STATUS_ERROR
} test_report_status_t;
+typedef struct _cairo_perf_diff_files_args {
+ char const *old_filename;
+ char const *new_filename;
+ double min_change;
+ int use_utf;
+ int print_change_bars;
+} cairo_perf_diff_files_args_t;
+
/* Ad-hoc parsing, macros with a strong dependence on the calling
* context, and plenty of other ugliness is here. But at least it's
* not perl... */
@@ -429,46 +437,55 @@ cairo_perf_report_sort_and_compute_stats
#define CHANGE_BAR_WIDTH 70
static void
-print_change_bar (double change, double max_change)
+print_change_bar (double change, double max_change, int use_utf)
{
int units_per_cell = (int) ceil (max_change / CHANGE_BAR_WIDTH);
+ static char const *ascii_boxes[8] = {
+ "****","***" ,"***", "**",
+ "**", "*", "*", ""
+ };
+ static char const *utf_boxes[8] = {
+ "â", "â", "â", "â",
+ "â", "â", "â", "â"
+ };
+ char const **boxes = use_utf ? utf_boxes : ascii_boxes;
/* For a 1.0x speedup we want a zero-size bar to show "no
* change". */
change -= 1.0;
while (change > units_per_cell) {
- printf("â");
+ printf(boxes[0]);
change -= units_per_cell;
}
change /= units_per_cell;
if (change > 7.5/8.0)
- printf("â");
+ printf(boxes[0]);
else if (change > 6.5/8.0)
- printf("â");
+ printf(boxes[1]);
else if (change > 5.5/8.0)
- printf("â");
+ printf(boxes[2]);
else if (change > 4.5/8.0)
- printf("â");
+ printf(boxes[3]);
else if (change > 3.5/8.0)
- printf("â");
+ printf(boxes[4]);
else if (change > 2.5/8.0)
- printf("â");
+ printf(boxes[5]);
else if (change > 1.5/8.0)
- printf("â");
+ printf(boxes[6]);
else if (change > 0.5/8.0)
- printf("â");
+ printf(boxes[7]);
printf ("\n");
}
#define MAX(a,b) ((a) > (b) ? (a) : (b))
static void
-cairo_perf_report_diff (cairo_perf_report_t *old,
- cairo_perf_report_t *new,
- double min_change)
+cairo_perf_report_diff (cairo_perf_report_t *old,
+ cairo_perf_report_t *new,
+ cairo_perf_diff_files_args_t const *args)
{
int i, i_old, i_new;
test_report_t *o, *n;
@@ -476,7 +493,7 @@ cairo_perf_report_diff (cairo_perf_repor
test_diff_t *diff, *diffs;
int num_diffs = 0;
int printed_speedup = 0, printed_slowdown = 0;
- double change, max_change;
+ double min_change = args->min_change, change, max_change;
diffs = xmalloc (MAX (old->tests_count, new->tests_count) * sizeof (test_diff_t));
@@ -577,7 +594,8 @@ cairo_perf_report_diff (cairo_perf_repor
else
printf ("slowdown\n");
- print_change_bar (change, max_change);
+ if (args->print_change_bars)
+ print_change_bar (change, max_change, args->use_utf);
}
free (diffs);
@@ -586,42 +604,85 @@ cairo_perf_report_diff (cairo_perf_repor
static void
usage (const char *argv0)
{
- fprintf (stderr, "Usage: %s file1 file2 [minimum_significant_change[%%]]\n", argv0);
+ char const *basename = strrchr(argv0, '/');
+ basename = basename ? basename+1 : argv0;
+ fprintf (stderr,
+ "Usage: %s [--no-utf] [--no-bars] file1 file2 [minimum_significant_change[%%]]\n\n",
+ basename);
fprintf (stderr,
"Computes significant performance differences for cairo performance reports.\n"
"Each file should be the output of the cairo-perf program (or \"make perf\").\n"
"The third argument is used to supress all changes below some threshold.\n"
"The default value of 5%% ignores any speeedup or slowdown of 5%% or less,\n"
- "A value of 0 will cause all output to be reported.\n");
+ "A value of 0 will cause all output to be reported.\n"
+ "\n"
+ "--no-utf Use ascii stars instead of utf-8 change bars.\n"
+ " Four stars are printed per factor of speedup.\n"
+ "--no-bars Don't display change bars at all.\n"
+ );
+ exit(1);
+}
+
+static void
+parse_args(int argc,
+ char const **argv,
+ cairo_perf_diff_files_args_t *args)
+{
+#define is_yesno_opt(opt) !(strcmp ("--no-" opt, argv[i]) && strcmp ("--" opt, argv[i]))
+ int i;
+ int have_minchange = 0;
+
+ for (i=1; i<argc; i++) {
+ if (is_yesno_opt("utf")) {
+ args->use_utf = 0 != strncmp ("--no-", argv[i], 4);
+ }
+ else if (is_yesno_opt("bars")) {
+ args->print_change_bars = 0 != strncmp ("--no-", argv[i], 4);
+ }
+ else if (!args->old_filename) {
+ args->old_filename = argv[i];
+ }
+ else if (!args->new_filename) {
+ args->new_filename = argv[i];
+ }
+ else if (!have_minchange) {
+ char *end = NULL;
+ args->min_change = strtod (argv[i], &end);
+ if (*end && *end) {
+ if (0 == strcmp (end, "%")) {
+ args->min_change /= 100;
+ } else {
+ usage (argv[0]);
+ }
+ }
+ }
+ else {
+ usage (argv[0]);
+ }
+ }
+ if ( !args->old_filename || !args->new_filename )
+ usage (argv[0]);
+#undef is_yesno_opt
}
int
main (int argc, const char *argv[])
{
- const char *old_filename, *new_filename;
+ cairo_perf_diff_files_args_t args = {
+ NULL, /* old filename */
+ NULL, /* new filename */
+ 0.05, /* min change */
+ 1, /* use UTF-8? */
+ 1, /* display change bars? */
+ };
cairo_perf_report_t old, new;
- double min_change;
- char *end;
- if (argc < 3) {
- usage (argv[0]);
- return 1;
- }
-
- old_filename = argv[1];
- new_filename = argv[2];
-
- min_change = 0.05;
- if (argc >= 4) {
- min_change = strtod (argv[3], &end);
- if (*end && *end == '%')
- min_change = min_change / 100.0;
- }
+ parse_args (argc, argv, &args);
- cairo_perf_report_load (&old, old_filename);
- cairo_perf_report_load (&new, new_filename);
+ cairo_perf_report_load (&old, args.old_filename);
+ cairo_perf_report_load (&new, args.new_filename);
- cairo_perf_report_diff (&old, &new, min_change);
+ cairo_perf_report_diff (&old, &new, &args);
return 0;
}
diff-tree d91d5d12f3a40beebefcd8a5d8b912f5492e112b (from d08502d939b44956591f2865a73264713427194b)
Author: Carl Worth <cworth at cworth.org>
Date: Fri Jan 19 15:52:06 2007 -0800
Add new scale-down-source-surface-paint test
This new test case demonstrates a bug in the PDF backend, (source
surface patterns are repeated even with a pattern extend of NONE).
Thanks to Romuald <mydevel at free.fr> and Claudio Saavedra
<csaavedra at alumnos.utalca.cl> for pointing out the bug.
diff --git a/test/.gitignore b/test/.gitignore
index 75fa10c..a984f82 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -107,6 +107,7 @@ pthread-show-text
rectangle-rounding-error
rectilinear-stroke
rel-path
+scale-down-source-surface-paint
scale-source-surface-paint
select-font-face
select-font-no-show-text
diff --git a/test/Makefile.am b/test/Makefile.am
index f675a29..4f432ad 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -72,6 +72,7 @@ pixman-rotate \
random-intersections \
rectangle-rounding-error \
rectilinear-stroke \
+scale-down-source-surface-paint \
scale-source-surface-paint \
select-font-face \
select-font-no-show-text \
@@ -293,6 +294,7 @@ rectilinear-stroke-ref.png \
rel-path-ref.png \
rel-path-rgb24-ref.png \
romedalen.png \
+scale-down-source-surface-paint-ref.png \
scale-source-surface-paint-ref.png \
scale-source-surface-paint-rgb24-ref.png \
scale-source-surface-paint-pdf-argb32-ref.png \
diff --git a/test/scale-down-source-surface-paint-ref.png b/test/scale-down-source-surface-paint-ref.png
new file mode 100644
index 0000000..5c969d2
Binary files /dev/null and b/test/scale-down-source-surface-paint-ref.png differ
diff --git a/test/scale-down-source-surface-paint.c b/test/scale-down-source-surface-paint.c
new file mode 100644
index 0000000..f5effab
--- /dev/null
+++ b/test/scale-down-source-surface-paint.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright © 2005,2007 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth at cworth.org>
+ */
+
+#include "cairo-test.h"
+
+static cairo_test_draw_function_t draw;
+
+cairo_test_t test = {
+ "scale-down-source-surface-paint",
+ "Test call sequence: cairo_scale; cairo_set_source_surface; cairo_paint, with a scale < 1.0",
+ 6, 6,
+ draw
+};
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_surface_t *surface;
+ static uint32_t data[16] = {
+ 0xffffffff, 0xffffffff, 0xffff0000, 0xffff0000,
+ 0xffffffff, 0xffffffff, 0xffff0000, 0xffff0000,
+
+ 0xff00ff00, 0xff00ff00, 0xff0000ff, 0xff0000ff,
+ 0xff00ff00, 0xff00ff00, 0xff0000ff, 0xff0000ff
+ };
+
+ /* First paint opaque background (black) so we don't need separate
+ * ARGB32 and RGB24 reference images. */
+ cairo_set_source_rgb (cr, 0, 0, 0); /* black */
+ cairo_paint (cr);
+
+ surface = cairo_image_surface_create_for_data ((unsigned char *) data,
+ CAIRO_FORMAT_RGB24, 4, 4, 16);
+
+ cairo_scale (cr, 0.5, 0.5);
+
+ cairo_set_source_surface (cr, surface, 4, 4);
+ cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_NEAREST);
+ cairo_paint (cr);
+
+ cairo_surface_destroy (surface);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+ return cairo_test (&test);
+}
More information about the cairo-commit
mailing list