summaryrefslogtreecommitdiffstats
path: root/meta/packages/cairo/cairo-1.2.4/0003-Add-new-perf-test-pattern_create_radial.diff
diff options
context:
space:
mode:
Diffstat (limited to 'meta/packages/cairo/cairo-1.2.4/0003-Add-new-perf-test-pattern_create_radial.diff')
-rw-r--r--meta/packages/cairo/cairo-1.2.4/0003-Add-new-perf-test-pattern_create_radial.diff164
1 files changed, 164 insertions, 0 deletions
diff --git a/meta/packages/cairo/cairo-1.2.4/0003-Add-new-perf-test-pattern_create_radial.diff b/meta/packages/cairo/cairo-1.2.4/0003-Add-new-perf-test-pattern_create_radial.diff
new file mode 100644
index 0000000000..c2b47deb7f
--- /dev/null
+++ b/meta/packages/cairo/cairo-1.2.4/0003-Add-new-perf-test-pattern_create_radial.diff
@@ -0,0 +1,164 @@
1From nobody Mon Sep 17 00:00:00 2001
2From: Dan Amelang <dan@amelang.net>
3Date: Tue Oct 31 23:47:35 2006 -0800
4Subject: [PATCH] Add new perf test "pattern_create_radial"
5
6This test is really just for hammering the double to fixed-point conversion
7(in _cairo_fixed_from_double) that happens as doubles from API calls gets
8translated into internal cairo fixed-point numbers.
9
10Because it's not generally useful, I don't recommend that it become part of
11the main cairo performance test. But hey, it might come in handy for someone
12else.
13
14---
15
16 perf/Makefile.am | 1
17 perf/cairo-perf.c | 1
18 perf/cairo-perf.h | 1
19 perf/pattern_create_radial.c | 98 ++++++++++++++++++++++++++++++++++++++++++
20 4 files changed, 101 insertions(+), 0 deletions(-)
21 create mode 100644 perf/pattern_create_radial.c
22
23977383b86c68d0523c899efcba3cf8d36e94d2a7
24diff --git a/perf/Makefile.am b/perf/Makefile.am
25index 419a998..e1cfdc7 100644
26--- a/perf/Makefile.am
27+++ b/perf/Makefile.am
28@@ -21,6 +21,7 @@ cairo_perf_SOURCES = \
29 stroke.c \
30 subimage_copy.c \
31 tessellate.c \
32+ pattern_create_radial.c \
33 text.c
34
35 if CAIRO_HAS_WIN32_SURFACE
36diff --git a/perf/cairo-perf.c b/perf/cairo-perf.c
37index d9734c4..0707433 100644
38--- a/perf/cairo-perf.c
39+++ b/perf/cairo-perf.c
40@@ -256,5 +256,6 @@ cairo_perf_case_t perf_cases[] = {
41 { text, 64, 256},
42 { tessellate, 100, 100},
43 { subimage_copy, 16, 512},
44+ { pattern_create_radial, 16, 16},
45 { NULL }
46 };
47diff --git a/perf/cairo-perf.h b/perf/cairo-perf.h
48index 560ba64..faacff9 100644
49--- a/perf/cairo-perf.h
50+++ b/perf/cairo-perf.h
51@@ -88,5 +88,6 @@ CAIRO_PERF_DECL (stroke);
52 CAIRO_PERF_DECL (subimage_copy);
53 CAIRO_PERF_DECL (tessellate);
54 CAIRO_PERF_DECL (text);
55+CAIRO_PERF_DECL (pattern_create_radial);
56
57 #endif
58diff --git a/perf/pattern_create_radial.c b/perf/pattern_create_radial.c
59new file mode 100644
60index 0000000..d793b7d
61--- /dev/null
62+++ b/perf/pattern_create_radial.c
63@@ -0,0 +1,98 @@
64+/*
65+ * Copyright © 2006 Dan Amelang
66+ *
67+ * Permission to use, copy, modify, distribute, and sell this software
68+ * and its documentation for any purpose is hereby granted without
69+ * fee, provided that the above copyright notice appear in all copies
70+ * and that both that copyright notice and this permission notice
71+ * appear in supporting documentation, and that the name of
72+ * the authors not be used in advertising or publicity pertaining to
73+ * distribution of the software without specific, written prior
74+ * permission. The authors make no representations about the
75+ * suitability of this software for any purpose. It is provided "as
76+ * is" without express or implied warranty.
77+ *
78+ * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
79+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
80+ * FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL,
81+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
82+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
83+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
84+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
85+ *
86+ * Authors: Dan Amelang <dan@amelang.net>
87+ *
88+ * This test was originally created to test _cairo_fixed_from_double.
89+ * cairo_pattern_create_radial was selected as the entry point into
90+ * cairo as it makes several calls to _cairo_fixed_from_double and
91+ * presents a somewhat realistic use-case (although the RADIALS_COUNT
92+ * isn't very realistic).
93+ */
94+#include <time.h>
95+#include "cairo-perf.h"
96+
97+#define RADIALS_COUNT (100000)
98+
99+static struct
100+{
101+ double cx0;
102+ double cy0;
103+ double radius0;
104+ double cx1;
105+ double cy1;
106+ double radius1;
107+} radials[RADIALS_COUNT];
108+
109+static double
110+generate_double_in_range (double min, double max)
111+{
112+ double d;
113+
114+ d = rand () / (double) RAND_MAX;
115+ d *= max - min;
116+ d += min;
117+
118+ return d;
119+}
120+
121+static cairo_perf_ticks_t
122+do_pattern_create_radial (cairo_t *cr, int width, int height)
123+{
124+ int i;
125+ cairo_pattern_t *pattern;
126+
127+ cairo_perf_timer_start ();
128+
129+ for (i = 0; i < RADIALS_COUNT; i++)
130+ {
131+ pattern = cairo_pattern_create_radial (radials[i].cx0, radials[i].cy0,
132+ radials[i].radius0,
133+ radials[i].cx1, radials[i].cy1,
134+ radials[i].radius1);
135+ cairo_pattern_destroy (pattern);
136+ }
137+
138+ cairo_perf_timer_stop ();
139+
140+ return cairo_perf_timer_elapsed ();
141+}
142+
143+void
144+pattern_create_radial (cairo_perf_t *perf, cairo_t *cr, int width, int height)
145+{
146+ int i;
147+
148+ srand (time (0));
149+ for (i = 0; i < RADIALS_COUNT; i++)
150+ {
151+ radials[i].cx0 = generate_double_in_range (-50000.0, 50000.0);
152+ radials[i].cy0 = generate_double_in_range (-50000.0, 50000.0);
153+ radials[i].radius0 = generate_double_in_range (0.0, 1000.0);
154+ radials[i].cx1 = generate_double_in_range (-50000.0, 50000.0);
155+ radials[i].cy1 = generate_double_in_range (-50000.0, 50000.0);
156+ radials[i].radius1 = generate_double_in_range (0.0, 1000.0);
157+ }
158+
159+ cairo_perf_run (perf, "pattern_create_radial",
160+ do_pattern_create_radial);
161+}
162--
1631.2.6
164