diff options
Diffstat (limited to 'src/fill.cpp')
| -rw-r--r-- | src/fill.cpp | 62 |
1 files changed, 13 insertions, 49 deletions
diff --git a/src/fill.cpp b/src/fill.cpp index 3a41826..c3c81b2 100644 --- a/src/fill.cpp +++ b/src/fill.cpp @@ -4,58 +4,22 @@ #include "caskbench.h" -void -randomize_color(cairo_t *cr) +int +setup_fill(cairo_t *cr) { - double red, green, blue, alpha; - - red = (double)rand()/RAND_MAX; - green = (double)rand()/RAND_MAX; - blue = (double)rand()/RAND_MAX; - alpha = (double)rand()/RAND_MAX; + cairo_arc (cr, 40, 40, 30, 0, 2*M_PI); + return 1; +} - cairo_set_source_rgba (cr, red, green, blue, alpha); +void +teardown_fill(void) +{ } int -main(int argc, char *argv[]) { - int i; - int iterations_requested = 16*1024; - int iterations = iterations_requested; - cairo_surface_t *surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 800, 80); - cairo_t *cr = cairo_create (surface); - int status = 0; - - srand(0xdeadbeef); - cairo_arc (cr, 40, 40, 30, 0, 2*M_PI); - - while (iterations--) { - try { - randomize_color (cr); - cairo_fill_preserve (cr); - status = 1; - } catch (...) { - printf("Exception encountered\n"); - status = 3; - goto FINAL; - } - } - - cairo_surface_write_to_png (surface, "fill.png"); - - FINAL: - printf(" {\n"); - printf(" \"case\": \"fill\",\n"); - printf(" \"iterations\": %d,\n", iterations_requested - iterations); - printf(" \"minimum run time (s)\": %f,\n", 40.123); - printf(" \"median run time (s)\": %f,\n", 42.123); - printf(" \"standard deviation (%%)\": %f,\n", 42.123); - printf(" \"status\": \"%d\"\n", status); - printf(" }"); - printf("\n"); - - cairo_destroy (cr); - cairo_surface_destroy (surface); - return 0; +test_fill(cairo_t *cr) +{ + randomize_color (cr); + cairo_fill_preserve (cr); + return 1; } - |