perf: Add initial skeleton of performance monitoring suite

This commit is contained in:
Carl Worth 2006-08-31 07:19:05 -07:00
parent d1834cca19
commit e153c55dff
7 changed files with 197 additions and 0 deletions

View file

@ -12,6 +12,8 @@ recheck: all
cd test && $(MAKE) $(AM_MAKEFLAGS) recheck
check-valgrind: all
cd test && $(MAKE) $(AM_MAKEFLAGS) check-valgrind
perf: all
cd perf && $(MAKE) $(AM_MAKEFLAGS) perf
# libpng is required for our test programs
if CAIRO_HAS_PNG_FUNCTIONS

View file

@ -784,6 +784,7 @@ pixman/Makefile
pixman/src/Makefile
src/Makefile
test/Makefile
perf/Makefile
doc/Makefile
doc/public/Makefile
doc/public/version.xml

2
perf/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
cairo-perf
*-out.ps

26
perf/Makefile.am Normal file
View file

@ -0,0 +1,26 @@
SUBDIRS=../boilerplate
# We're using _GNU_SOURCE to get the prototype for asprintf. This may
# not be the most portable approach, but it is pragmatic and I'm
# willing to do something cleaner as soon as it causes someone a
# problem.
INCLUDES = \
-D_GNU_SOURCE \
-I$(srcdir) \
-I$(top_srcdir)/boilerplate \
-I$(top_srcdir)/src \
$(CAIRO_CFLAGS)
noinst_PROGRAMS = cairo-perf
cairo_perf_SOURCES = \
cairo-perf.c \
cairo-perf.h \
paint.c
LDADD = $(top_builddir)/boilerplate/libcairoboilerplate.la \
$(top_builddir)/src/libcairo.la
perf: cairo-perf
./cairo-perf

72
perf/cairo-perf.c Normal file
View file

@ -0,0 +1,72 @@
/*
* Copyright © 2006 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@cworth.org>
*/
#include "cairo-perf.h"
unsigned int iterations = 0;
typedef struct _cairo_perf {
const char *name;
cairo_perf_func_t setup;
cairo_perf_func_t run;
unsigned int min_size;
unsigned int max_size;
} cairo_perf_t;
cairo_perf_t perfs[] = {
{ "paint", paint_setup, paint, 32, 1024 },
{ "paint_alpha", paint_alpha_setup, paint, 32, 1024 },
{ NULL }
};
int
main (int argc, char *argv[])
{
int i, j;
cairo_test_target_t *target;
cairo_perf_t *perf;
cairo_surface_t *surface;
cairo_t *cr;
unsigned int size;
for (i = 0; targets[i].name; i++) {
target = &targets[i];
for (j = 0; perfs[j].name; j++) {
perf = &perfs[j];
for (size = perf->min_size; size <= perf->max_size; size *= 2) {
surface = (target->create_target_surface) (perf->name,
target->content,
size, size,
&target->closure);
cr = cairo_create (surface);
perf->setup (cr, size, size);
perf->run (cr, size, size);
}
}
}
return 0;
}

45
perf/cairo-perf.h Normal file
View file

@ -0,0 +1,45 @@
/*
* Copyright © 2006 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@cworth.org>
*/
#ifndef _CAIRO_PERF_H_
#define _CAIRO_PERF_H_
#include "cairo-boilerplate.h"
extern unsigned int iterations;
typedef void (*cairo_perf_func_t) (cairo_t *cr, int width, int height);
#define DECL_PERF_FUNC(func) void func (cairo_t *cr, int width, int height)
DECL_PERF_FUNC (paint_setup);
DECL_PERF_FUNC (paint_alpha_setup);
DECL_PERF_FUNC (paint);
/* XXX: Obviously bogus as we bring up the infrastructure. */
#define PERF_LOOP_INIT do {
#define PERF_LOOP_FINI } while (0);
#endif

49
perf/paint.c Normal file
View file

@ -0,0 +1,49 @@
/*
* Copyright © 2006 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@cworth.org>
*/
#include "cairo-perf.h"
void
paint_setup (cairo_t *cr, int width, int height)
{
cairo_set_source_rgba (cr, 1.0, 0.2, 0.6, 0.5);
}
void
paint_alpha_setup (cairo_t *cr, int width, int height)
{
cairo_set_source_rgb (cr, 0.2, 0.6, 0.9);
}
void
paint (cairo_t *cr, int width, int height)
{
PERF_LOOP_INIT;
{
cairo_paint (cr);
iterations++;
}
PERF_LOOP_FINI;
}