diff options
| author | Bryce Harrington <b.harrington@samsung.com> | 2013-10-28 12:47:58 -0700 |
|---|---|---|
| committer | Bryce Harrington <b.harrington@samsung.com> | 2013-10-28 12:48:31 -0700 |
| commit | b2356653469b7ea05cf6bcb92d4ac4dc23f2b5ab (patch) | |
| tree | 056fb1fb73c93b5d4e5000e3cd45bbe2f05699f1 /src/fill.cpp | |
| parent | 8ce2e4d7e4bdd5a0252affe02c17a1929d46bb53 (diff) | |
fill: Use test framework
Diffstat (limited to 'src/fill.cpp')
| -rw-r--r-- | src/fill.cpp | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/src/fill.cpp b/src/fill.cpp index 8996a56..3a41826 100644 --- a/src/fill.cpp +++ b/src/fill.cpp @@ -2,9 +2,7 @@ #include <stdlib.h> #include <cairo.h> -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif +#include "caskbench.h" void randomize_color(cairo_t *cr) @@ -22,20 +20,41 @@ randomize_color(cairo_t *cr) int main(int argc, char *argv[]) { int i; - int loops = 128*1024; + 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 (loops--) { - randomize_color (cr); - cairo_fill_preserve (cr); + while (iterations--) { + try { + randomize_color (cr); + cairo_fill_preserve (cr); + status = 1; + } catch (...) { + printf("Exception encountered\n"); + status = 3; + goto FINAL; + } } - cairo_destroy (cr); 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; } |