Add test013: Filling circles

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
diff --git a/Makefile b/Makefile
index 9a0a7ad..5041f6c 100644
--- a/Makefile
+++ b/Makefile
@@ -7,6 +7,7 @@
 
 LIBS += tests/tests.a drawops/drawops.a fonts/fonts.a images/images.a \
 	visops/visops.a
+LIBS += -lm
 
 include $(TOPDIR)/Rules.make
 
diff --git a/include/test.h b/include/test.h
index c8d4ebb..06592c4 100644
--- a/include/test.h
+++ b/include/test.h
@@ -66,6 +66,7 @@
 extern const struct test test010;
 extern const struct test test011;
 extern const struct test test012;
+extern const struct test test013;
 
 
     /*
diff --git a/tests.c b/tests.c
index 70a885b..6f6f818 100644
--- a/tests.c
+++ b/tests.c
@@ -32,6 +32,7 @@
     &test010,
     &test011,
     &test012,
+    &test013,
     NULL
 };
 
diff --git a/tests/test013.c b/tests/test013.c
new file mode 100644
index 0000000..96fc1cd
--- /dev/null
+++ b/tests/test013.c
@@ -0,0 +1,84 @@
+
+/*
+ *  Test013
+ *
+ *  (C) Copyright 2019 Geert Uytterhoeven
+ *
+ *  This file is subject to the terms and conditions of the GNU General Public
+ *  License. See the file COPYING in the main directory of this archive for
+ *  more details.
+ */
+
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "types.h"
+#include "fb.h"
+#include "drawops.h"
+#include "visual.h"
+#include "test.h"
+#include "util.h"
+
+
+struct param {
+    u32 xrange;
+    u32 yrange;
+    u32 size;
+    pixel_t pixelmask;
+};
+
+static void fill_circles(unsigned long n, void *data)
+{
+    struct param *param = data;
+
+    while (n--)
+	fill_circle(param->size + lrand48() % param->xrange,
+		    param->size + lrand48() % param->yrange,
+		    param->size, lrand48() & param->pixelmask);
+}
+
+static void benchmark_circles(u32 size)
+{
+    struct param param;
+    double rate;
+
+    param.xrange = fb_var.xres_virtual-2*size;
+    param.yrange = fb_var.yres_virtual-2*size;
+    param.size = size;
+    param.pixelmask = (1ULL << fb_var.bits_per_pixel)-1;
+
+    rate = benchmark(fill_circles, &param);
+    if (rate < 0)
+	return;
+
+    printf("R%u circles: %.2f Mpixels/s\n", size, rate*size*size*M_PI/1e6);
+}
+
+static enum test_res test013_func(void)
+{
+    unsigned int i;
+    u32 sizes[3] = { 10, 20, 50 };
+    u32 size;
+
+    while (1)
+	for (i = 0; i < sizeof(sizes)/sizeof(*sizes); i++) {
+	    size = sizes[i];
+	    if (size > fb_var.xres_virtual || size > fb_var.yres_virtual)
+		goto out;
+	    benchmark_circles(size/2);
+	    sizes[i] *= 10;
+	}
+
+out:
+    wait_for_key(10);
+    return TEST_OK;
+}
+
+const struct test test013 = {
+    .name =	"test013",
+    .desc =	"Filling circles",
+    .visual =	VISUAL_GENERIC,
+    .func =	test013_func,
+};
+