summaryrefslogtreecommitdiffstatsci
path: root/src/fill.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/fill.cpp')
-rw-r--r--src/fill.cpp35
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;
}