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
;
46 cairo_perf_timer_start (void);
49 cairo_perf_timer_stop (void);
52 (*cairo_perf_timer_synchronize_t
) (void *closure
);
55 cairo_perf_timer_set_synchronize (cairo_perf_timer_synchronize_t synchronize
,
59 cairo_perf_timer_elapsed (void);
62 cairo_perf_ticks_per_second (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
;
75 cairo_bool_t list_only
;
77 unsigned int num_names
;
79 /* Stuff used internally */
80 cairo_perf_ticks_t
*times
;
81 cairo_boilerplate_target_t
**targets
;
83 cairo_boilerplate_target_t
*target
;
84 unsigned int test_number
;
89 typedef cairo_perf_ticks_t
90 (*cairo_perf_func_t
) (cairo_t
*cr
, int width
, int height
);
93 cairo_perf_run (cairo_perf_t
*perf
,
95 cairo_perf_func_t perf_func
);
98 cairo_perf_cover_sources_and_operators (cairo_perf_t
*perf
,
100 cairo_perf_func_t perf_func
);
102 /* reporter convenience routines */
104 typedef struct _test_report
{
106 const char *configuration
;
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. */
123 typedef struct _test_diff
{
124 test_report_t
**tests
;
131 typedef struct _cairo_perf_report
{
134 test_report_t
*tests
;
137 } cairo_perf_report_t
;
140 TEST_REPORT_STATUS_SUCCESS
,
141 TEST_REPORT_STATUS_COMMENT
,
142 TEST_REPORT_STATUS_ERROR
143 } test_report_status_t
;
146 cairo_perf_report_load (cairo_perf_report_t
*report
,
147 const char *filename
);
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
);