2009-12-07 Rolf Bjarne Kvinge <RKvinge@novell.com>
[moon.git] / cairo / perf / cairo-perf.h
blob57fe85f113e4a417e2ed1f78cded3c9130a670cf
1 /*
2 * Copyright © 2006 Mozilla Corporation
3 * Copyright © 2006 Red Hat, Inc.
5 * Permission to use, copy, modify, distribute, and sell this software
6 * and its documentation for any purpose is hereby granted without
7 * fee, provided that the above copyright notice appear in all copies
8 * and that both that copyright notice and this permission notice
9 * appear in supporting documentation, and that the name of
10 * the authors not be used in advertising or publicity pertaining to
11 * distribution of the software without specific, written prior
12 * permission. The authors make no representations about the
13 * suitability of this software for any purpose. It is provided "as
14 * is" without express or implied warranty.
16 * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
17 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
18 * FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL,
19 * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
20 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
21 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
22 * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24 * Authors: Vladimir Vukicevic <vladimir@pobox.com>
25 * Carl Worth <cworth@cworth.org>
28 #ifndef _CAIRO_PERF_H_
29 #define _CAIRO_PERF_H_
31 #include "cairo-boilerplate.h"
33 typedef uint64_t cairo_perf_ticks_t;
35 typedef struct _cairo_stats {
36 cairo_perf_ticks_t min_ticks;
37 cairo_perf_ticks_t median_ticks;
38 double ticks_per_ms;
39 double std_dev;
40 int iterations;
41 } cairo_stats_t;
43 /* timers */
45 void
46 cairo_perf_timer_start (void);
48 void
49 cairo_perf_timer_stop (void);
51 typedef void
52 (*cairo_perf_timer_synchronize_t) (void *closure);
54 void
55 cairo_perf_timer_set_synchronize (cairo_perf_timer_synchronize_t synchronize,
56 void *closure);
58 cairo_perf_ticks_t
59 cairo_perf_timer_elapsed (void);
61 cairo_perf_ticks_t
62 cairo_perf_ticks_per_second (void);
64 /* yield */
66 void
67 cairo_perf_yield (void);
69 /* running a test case */
70 typedef struct _cairo_perf {
71 /* Options from command-line */
72 unsigned int iterations;
73 cairo_bool_t exact_iterations;
74 cairo_bool_t raw;
75 cairo_bool_t list_only;
76 char **names;
77 unsigned int num_names;
79 /* Stuff used internally */
80 cairo_perf_ticks_t *times;
81 cairo_boilerplate_target_t **targets;
82 int num_targets;
83 cairo_boilerplate_target_t *target;
84 unsigned int test_number;
85 unsigned int size;
86 cairo_t *cr;
87 } cairo_perf_t;
89 typedef cairo_perf_ticks_t
90 (*cairo_perf_func_t) (cairo_t *cr, int width, int height);
92 void
93 cairo_perf_run (cairo_perf_t *perf,
94 const char *name,
95 cairo_perf_func_t perf_func);
97 void
98 cairo_perf_cover_sources_and_operators (cairo_perf_t *perf,
99 const char *name,
100 cairo_perf_func_t perf_func);
102 /* reporter convenience routines */
104 typedef struct _test_report {
105 int id;
106 const char *configuration;
107 char *backend;
108 char *content;
109 char *name;
110 int size;
112 /* The samples only exists for "raw" reports */
113 cairo_perf_ticks_t *samples;
114 unsigned int samples_size;
115 unsigned int samples_count;
117 /* The stats are either read directly or computed from samples.
118 * If the stats have not yet been computed from samples, then
119 * iterations will be 0. */
120 cairo_stats_t stats;
121 } test_report_t;
123 typedef struct _test_diff {
124 test_report_t **tests;
125 int num_tests;
126 double min;
127 double max;
128 double change;
129 } test_diff_t;
131 typedef struct _cairo_perf_report {
132 char *configuration;
133 const char *name;
134 test_report_t *tests;
135 int tests_size;
136 int tests_count;
137 } cairo_perf_report_t;
139 typedef enum {
140 TEST_REPORT_STATUS_SUCCESS,
141 TEST_REPORT_STATUS_COMMENT,
142 TEST_REPORT_STATUS_ERROR
143 } test_report_status_t;
145 void
146 cairo_perf_report_load (cairo_perf_report_t *report,
147 const char *filename);
149 void
150 cairo_perf_report_sort_and_compute_stats (cairo_perf_report_t *report);
153 test_report_cmp_backend_then_name (const void *a, const void *b);
155 #define CAIRO_PERF_DECL(func) void (func) (cairo_perf_t *perf, cairo_t *cr, int width, int height)
157 CAIRO_PERF_DECL (fill);
158 CAIRO_PERF_DECL (paint);
159 CAIRO_PERF_DECL (paint_with_alpha);
160 CAIRO_PERF_DECL (stroke);
161 CAIRO_PERF_DECL (subimage_copy);
162 CAIRO_PERF_DECL (tessellate);
163 CAIRO_PERF_DECL (text);
164 CAIRO_PERF_DECL (pattern_create_radial);
165 CAIRO_PERF_DECL (zrusin);
166 CAIRO_PERF_DECL (world_map);
167 CAIRO_PERF_DECL (box_outline);
168 CAIRO_PERF_DECL (mosaic);
169 CAIRO_PERF_DECL (long_lines);
170 CAIRO_PERF_DECL (unaligned_clip);
171 CAIRO_PERF_DECL (rectangles);
172 CAIRO_PERF_DECL (rounded_rectangles);
173 CAIRO_PERF_DECL (long_dashed_lines);
174 CAIRO_PERF_DECL (composite_checker);
176 #endif