[perf] Match directory names

In order to handle 'cairo-perf-trace benchmark', we need to perform the
can_run? test on the directory name as opposed to the individual trace
names. Make it so.
This commit is contained in:
Chris Wilson 2009-08-22 18:59:01 +01:00
parent 77c1109616
commit bdd3c5ba69
28 changed files with 68 additions and 39 deletions

View file

@ -94,7 +94,7 @@ box_outline_fill (cairo_t *cr, int width, int height, int loops)
void
box_outline (cairo_perf_t *perf, cairo_t *cr, int width, int height)
{
if (! cairo_perf_can_run (perf, "box-outline"))
if (! cairo_perf_can_run (perf, "box-outline", NULL))
return;
cairo_perf_run (perf, "box-outline-stroke", box_outline_stroke);

View file

@ -124,14 +124,21 @@ target_is_measurable (const cairo_boilerplate_target_t *target)
cairo_bool_t
cairo_perf_can_run (cairo_perf_t *perf,
const char *name)
const char *name,
cairo_bool_t *is_explicit)
{
unsigned int i;
char *copy, *dot;
cairo_bool_t ret;
if (perf->exact_names)
if (is_explicit)
*is_explicit = FALSE;
if (perf->exact_names) {
if (is_explicit)
*is_explicit = TRUE;
return TRUE;
}
if (perf->num_names == 0 && perf->num_exclude_names == 0)
return TRUE;
@ -144,8 +151,11 @@ cairo_perf_can_run (cairo_perf_t *perf,
if (perf->num_names) {
ret = TRUE;
for (i = 0; i < perf->num_names; i++)
if (strstr (copy, perf->names[i]))
if (strstr (copy, perf->names[i])) {
if (is_explicit)
*is_explicit = strcmp (copy, perf->names[i]) == 0;
goto check_exclude;
}
ret = FALSE;
goto done;
@ -155,8 +165,11 @@ check_exclude:
if (perf->num_exclude_names) {
ret = FALSE;
for (i = 0; i < perf->num_exclude_names; i++)
if (strstr (copy, perf->exclude_names[i]))
if (strstr (copy, perf->exclude_names[i])) {
if (is_explicit)
*is_explicit = strcmp (copy, perf->exclude_names[i]) == 0;
goto done;
}
ret = TRUE;
goto done;
@ -315,8 +328,8 @@ execute (cairo_perf_t *perf,
name);
fprintf (perf->summary,
"%#8.3f %#8.3f %#6.2f%% %4d/%d",
stats.min_ticks / (double) cairo_perf_ticks_per_second (),
stats.median_ticks / (double) cairo_perf_ticks_per_second (),
(double) stats.min_ticks / cairo_perf_ticks_per_second (),
(double) stats.median_ticks / cairo_perf_ticks_per_second (),
stats.std_dev * 100.0,
stats.iterations, i+1);
fflush (perf->summary);
@ -335,8 +348,8 @@ execute (cairo_perf_t *perf,
}
fprintf (perf->summary,
"%#8.3f %#8.3f %#6.2f%% %4d/%d\n",
stats.min_ticks / (double) cairo_perf_ticks_per_second (),
stats.median_ticks / (double) cairo_perf_ticks_per_second (),
(double) stats.min_ticks / cairo_perf_ticks_per_second (),
(double) stats.median_ticks / cairo_perf_ticks_per_second (),
stats.std_dev * 100.0,
stats.iterations, i);
fflush (perf->summary);
@ -623,11 +636,17 @@ cairo_perf_trace_dir (cairo_perf_t *perf,
DIR *dir;
struct dirent *de;
int num_traces = 0;
cairo_bool_t force;
cairo_bool_t is_explicit;
dir = opendir (dirname);
if (dir == NULL)
return 0;
force = FALSE;
if (cairo_perf_can_run (perf, dirname, &is_explicit))
force = is_explicit;
while ((de = readdir (dir)) != NULL) {
char *trace;
struct stat st;
@ -651,7 +670,7 @@ cairo_perf_trace_dir (cairo_perf_t *perf,
goto next;
num_traces++;
if (! cairo_perf_can_run (perf, de->d_name))
if (!force && ! cairo_perf_can_run (perf, de->d_name, NULL))
goto next;
cairo_perf_trace (perf, target, trace);

View file

@ -153,16 +153,24 @@ cairo_perf_has_similar (cairo_perf_t *perf)
cairo_bool_t
cairo_perf_can_run (cairo_perf_t *perf,
const char *name)
const char *name,
cairo_bool_t *is_explicit)
{
unsigned int i;
if (is_explicit)
*is_explicit = FALSE;
if (perf->num_names == 0)
return TRUE;
for (i = 0; i < perf->num_names; i++)
if (strstr (name, perf->names[i]))
for (i = 0; i < perf->num_names; i++) {
if (strstr (name, perf->names[i])) {
if (is_explicit)
*is_explicit = FALSE;
return TRUE;
}
}
return FALSE;
}

View file

@ -98,7 +98,8 @@ typedef cairo_perf_ticks_t
cairo_bool_t
cairo_perf_can_run (cairo_perf_t *perf,
const char *name);
const char *name,
cairo_bool_t *is_explicit);
void
cairo_perf_run (cairo_perf_t *perf,

View file

@ -83,7 +83,7 @@ composite_checker (cairo_perf_t *perf,
{
cairo_surface_t *image;
if (! cairo_perf_can_run (perf, "composite-checker"))
if (! cairo_perf_can_run (perf, "composite-checker", NULL))
return;
/* Create the checker pattern. We don't actually need to draw

View file

@ -72,6 +72,7 @@ path (cairo_t *cr, int step, int dir, int iterations)
int i;
switch (dir) {
default:
case 0: dx = step; dy = 0; break;
case 1: dx = -step; dy = 0; break;
case 2: dx = 0; dy = step; break;
@ -237,7 +238,7 @@ do_dragon_solid_circle_clip (cairo_t *cr, int width, int height, int loops)
void
dragon (cairo_perf_t *perf, cairo_t *cr, int width, int height)
{
if (! cairo_perf_can_run (perf, "dragon"))
if (! cairo_perf_can_run (perf, "dragon", NULL))
return;
cairo_perf_run (perf, "dragon-solid", do_dragon_solid);

View file

@ -110,7 +110,7 @@ do_fill_eo_noaa (cairo_t *cr, int width, int height, int loops)
void
fill (cairo_perf_t *perf, cairo_t *cr, int width, int height)
{
if (! cairo_perf_can_run (perf, "fill"))
if (! cairo_perf_can_run (perf, "fill", NULL))
return;
cairo_perf_cover_sources_and_operators (perf, "fill", do_fill);

View file

@ -92,7 +92,7 @@ out:
void
glyphs (cairo_perf_t *perf, cairo_t *cr, int width, int height)
{
if (! cairo_perf_can_run (perf, "glyphs"))
if (! cairo_perf_can_run (perf, "glyphs", NULL))
return;
cairo_perf_cover_sources_and_operators (perf, "glyphs", do_glyphs);

View file

@ -146,7 +146,7 @@ random_curve_nz (cairo_t *cr, int width, int height, int loops)
void
intersections (cairo_perf_t *perf, cairo_t *cr, int width, int height)
{
if (! cairo_perf_can_run (perf, "intersections"))
if (! cairo_perf_can_run (perf, "intersections", NULL))
return;
cairo_perf_run (perf, "intersections-nz-fill", random_nz);

View file

@ -64,7 +64,7 @@ do_long_dashed_lines (cairo_t *cr, int width, int height, int loops)
void
long_dashed_lines (cairo_perf_t *perf, cairo_t *cr, int width, int height)
{
if (! cairo_perf_can_run (perf, "long-dashed-lines"))
if (! cairo_perf_can_run (perf, "long-dashed-lines", NULL))
return;
cairo_perf_run (perf, "long-dashed-lines", do_long_dashed_lines);

View file

@ -135,7 +135,7 @@ long_lines_cropped_once (cairo_t *cr, int width, int height, int loops)
void
long_lines (cairo_perf_t *perf, cairo_t *cr, int width, int height)
{
if (! cairo_perf_can_run (perf, "long-lines"))
if (! cairo_perf_can_run (perf, "long-lines", NULL))
return;
cairo_perf_run (perf, "long-lines-uncropped", long_lines_uncropped);

View file

@ -275,7 +275,7 @@ do_mask_radial (cairo_t *cr, int width, int height, int loops)
void
mask (cairo_perf_t *perf, cairo_t *cr, int width, int height)
{
if (! cairo_perf_can_run (perf, "mask"))
if (! cairo_perf_can_run (perf, "mask", NULL))
return;
cairo_perf_cover_sources_and_operators (perf, "mask-solid",

View file

@ -163,7 +163,7 @@ mosaic_tessellate_curves (cairo_t *cr, int width, int height, int loops)
void
mosaic (cairo_perf_t *perf, cairo_t *cr, int width, int height)
{
if (! cairo_perf_can_run (perf, "mosaic"))
if (! cairo_perf_can_run (perf, "mosaic", NULL))
return;
cairo_perf_run (perf, "mosaic-fill-curves", mosaic_fill_curves);

View file

@ -41,7 +41,7 @@ do_paint_with_alpha (cairo_t *cr, int width, int height, int loops)
void
paint_with_alpha (cairo_perf_t *perf, cairo_t *cr, int width, int height)
{
if (! cairo_perf_can_run (perf, "paint-with-alpha"))
if (! cairo_perf_can_run (perf, "paint-with-alpha", NULL))
return;
cairo_perf_cover_sources_and_operators (perf, "paint-with-alpha",

View file

@ -41,7 +41,7 @@ do_paint (cairo_t *cr, int width, int height, int loops)
void
paint (cairo_perf_t *perf, cairo_t *cr, int width, int height)
{
if (! cairo_perf_can_run (perf, "paint"))
if (! cairo_perf_can_run (perf, "paint", NULL))
return;
cairo_perf_cover_sources_and_operators (perf, "paint", do_paint);

View file

@ -84,7 +84,7 @@ pattern_create_radial (cairo_perf_t *perf, cairo_t *cr, int width, int height)
{
int i;
if (! cairo_perf_can_run (perf, "pattern-create-radial"))
if (! cairo_perf_can_run (perf, "pattern-create-radial", NULL))
return;
srand (time (0));

View file

@ -84,8 +84,8 @@ do_pythagoras_tree (cairo_t *cr, int width, int height, int loops)
void
pythagoras_tree (cairo_perf_t *perf, cairo_t *cr, int width, int height)
{
if (! cairo_perf_can_run (perf, "pythagoras-tree"))
if (! cairo_perf_can_run (perf, "pythagoras-tree", NULL))
return;
cairo_perf_run (perf, "pythagoras_tree", do_pythagoras_tree);
cairo_perf_run (perf, "pythagoras-tree", do_pythagoras_tree);
}

View file

@ -100,7 +100,7 @@ rectangles (cairo_perf_t *perf, cairo_t *cr, int width, int height)
{
int i;
if (! cairo_perf_can_run (perf, "rectangles"))
if (! cairo_perf_can_run (perf, "rectangles", NULL))
return;
srand (8478232);

View file

@ -124,7 +124,7 @@ rounded_rectangles (cairo_perf_t *perf, cairo_t *cr, int width, int height)
{
int i;
if (! cairo_perf_can_run (perf, "rounded-rectangles"))
if (! cairo_perf_can_run (perf, "rounded-rectangles", NULL))
return;
srand (8478232);

View file

@ -329,7 +329,7 @@ draw_spiral_stroke_na (cairo_t *cr, int width, int height, int loops)
void
spiral (cairo_perf_t *perf, cairo_t *cr, int width, int height)
{
if (! cairo_perf_can_run (perf, "spiral"))
if (! cairo_perf_can_run (perf, "spiral", NULL))
return;
cairo_perf_run (perf, "spiral-box-nonalign-evenodd-fill", draw_spiral_eo_na_box);

View file

@ -89,7 +89,7 @@ do_strokes (cairo_t *cr, int width, int height, int loops)
void
stroke (cairo_perf_t *perf, cairo_t *cr, int width, int height)
{
if (! cairo_perf_can_run (perf, "stroke"))
if (! cairo_perf_can_run (perf, "stroke", NULL))
return;
cairo_perf_cover_sources_and_operators (perf, "stroke", do_stroke);

View file

@ -58,7 +58,7 @@ subimage_copy (cairo_perf_t *perf, cairo_t *cr, int width, int height)
cairo_surface_t *image;
cairo_t *cr2;
if (! cairo_perf_can_run (perf, "subimage-copy"))
if (! cairo_perf_can_run (perf, "subimage-copy", NULL))
return;
cairo_set_source_rgb (cr, 0, 0, 1); /* blue */

View file

@ -144,7 +144,7 @@ tessellate_256 (cairo_t *cr, int width, int height, int loops)
void
tessellate (cairo_perf_t *perf, cairo_t *cr, int width, int height)
{
if (! cairo_perf_can_run (perf, "tessellate"))
if (! cairo_perf_can_run (perf, "tessellate", NULL))
return;
cairo_perf_run (perf, "tessellate-16", tessellate_16);

View file

@ -59,7 +59,7 @@ do_text (cairo_t *cr, int width, int height, int loops)
void
text (cairo_perf_t *perf, cairo_t *cr, int width, int height)
{
if (! cairo_perf_can_run (perf, "text"))
if (! cairo_perf_can_run (perf, "text", NULL))
return;
cairo_perf_cover_sources_and_operators (perf, "text", do_text);

View file

@ -49,7 +49,7 @@ twin (cairo_perf_t *perf,
int width,
int height)
{
if (! cairo_perf_can_run (perf, "twin"))
if (! cairo_perf_can_run (perf, "twin", NULL))
return;
cairo_perf_run (perf, "twin", do_twin);

View file

@ -63,7 +63,7 @@ do_unaligned_clip (cairo_t *cr, int width, int height, int loops)
void
unaligned_clip (cairo_perf_t *perf, cairo_t *cr, int width, int height)
{
if (! cairo_perf_can_run (perf, "unaligned-clip"))
if (! cairo_perf_can_run (perf, "unaligned-clip", NULL))
return;
cairo_perf_run (perf, "unaligned-clip", do_unaligned_clip);

View file

@ -109,7 +109,7 @@ do_world_map (cairo_t *cr, int width, int height, int loops)
void
world_map (cairo_perf_t *perf, cairo_t *cr, int width, int height)
{
if (! cairo_perf_can_run (perf, "world-map"))
if (! cairo_perf_can_run (perf, "world-map", NULL))
return;
cairo_perf_run (perf, "world-map", do_world_map);

View file

@ -87,7 +87,7 @@ zrusin_another_fill (cairo_t *cr, int width, int height, int loops)
void
zrusin (cairo_perf_t *perf, cairo_t *cr, int width, int height)
{
if (! cairo_perf_can_run (perf, "zrusin"))
if (! cairo_perf_can_run (perf, "zrusin", NULL))
return;
cairo_perf_run (perf, "zrusin-another-tessellate", zrusin_another_tessellate);