summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2013-10-08 21:00:55 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2013-11-20 22:07:01 +0000
commit02a3208c090b489f74f4459475694f3c786f69ca (patch)
tree2a0dbd65d3120d876a99bac1517e796a25580b82
parent7a7c08b430da6310ec61138a2c565e27535dbc34 (diff)
Split screen into 16 simultaneous benchmarksHEADmaster
-rw-r--r--.gitignore1
-rw-r--r--bubble-demo.c2
-rw-r--r--chart-demo.c2
-rw-r--r--demo.c20
-rw-r--r--demo.h21
-rw-r--r--dragon-demo.c2
-rw-r--r--fish-demo.c2
-rw-r--r--flowers-demo.c2
-rw-r--r--gears-demo.c2
-rw-r--r--glx.c13
-rw-r--r--gradient-demo.c2
-rwxr-xr-xmany.sh24
-rw-r--r--maze-demo.c2
-rwxr-xr-xmulti.sh11
-rw-r--r--pythagoras-demo.c2
-rw-r--r--sierpinski-demo.c2
-rw-r--r--slideshow-demo.c58
-rw-r--r--spinner-demo.c2
-rw-r--r--spiral-demo.c2
-rw-r--r--tiger-demo.c2
-rw-r--r--waterfall-demo.c2
-rw-r--r--wave-demo.c2
-rw-r--r--ximage.c13
-rw-r--r--xlib.c13
-rw-r--r--xshm.c13
25 files changed, 177 insertions, 40 deletions
diff --git a/.gitignore b/.gitignore
index 832f713..cb57958 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+bubble-demo
chart-demo
dragon-demo
fish-demo
diff --git a/bubble-demo.c b/bubble-demo.c
index 6eaac59..5ce5747 100644
--- a/bubble-demo.c
+++ b/bubble-demo.c
@@ -367,7 +367,7 @@ int main(int argc, char **argv)
bubble_draw(cr, &bubble[n]);
cairo_destroy(cr);
- fps_finish(fb, device->name, version);
+ fps_finish(fb, device->name, version, "bubble");
fb->show (fb);
fb->destroy (fb);
pause();
diff --git a/chart-demo.c b/chart-demo.c
index cad22f4..b20df32 100644
--- a/chart-demo.c
+++ b/chart-demo.c
@@ -324,7 +324,7 @@ int main (int argc, char **argv)
chart_draw(device, cr, antialias, clip, c, 5, vertical);
cairo_destroy(cr);
- fps_finish(fb, device->name, version);
+ fps_finish(fb, device->name, version, "chart%s", vertical ? "-vertical" : "");
fb->show (fb);
fb->destroy (fb);
pause();
diff --git a/demo.c b/demo.c
index 797fa38..53fba49 100644
--- a/demo.c
+++ b/demo.c
@@ -1,6 +1,7 @@
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
+#include <stdarg.h>
#include <math.h>
#include "demo.h"
@@ -52,6 +53,8 @@ enum split device_get_split(int argc, char **argv)
split = SPLIT_BOTTOM_LEFT;
} else if (strcmp(argv[n]+8, "bottom-right") == 0) {
split = SPLIT_BOTTOM_RIGHT;
+ } else {
+ split = SPLIT_1_16 + atoi(argv[n]+8);
}
}
}
@@ -373,13 +376,16 @@ fps_draw (cairo_t *cr,
void
fps_finish (struct framebuffer *fb,
+ const char *backend,
+ const char *version,
const char *name,
- const char *version)
+ ...)
{
cairo_t *cr = cairo_create(fb->surface);
cairo_text_extents_t extents;
char buf[80];
double avg;
+ va_list ap;
if (frame_count == 0)
return;
@@ -388,10 +394,10 @@ fps_finish (struct framebuffer *fb,
if (version)
snprintf (buf, sizeof (buf), "%s (%s): %.1f fps, %d frames",
- name, version, 1. / avg, frame_count);
+ backend, version, 1. / avg, frame_count);
else
snprintf (buf, sizeof (buf), "%s: %.1f fps, %d frames",
- name, 1. / avg, frame_count);
+ backend, 1. / avg, frame_count);
cairo_set_font_size (cr, 32);
cairo_text_extents (cr, buf, &extents);
@@ -410,6 +416,14 @@ fps_finish (struct framebuffer *fb,
cairo_set_source_rgb (cr, .95, .95, .95);
cairo_show_text (cr, buf);
cairo_destroy (cr);
+
+ va_start(ap, name);
+ vfprintf (stdout, name, ap);
+ va_end(ap);
+
+ printf (": %.1f fps, %d frames, %.1f seconds\n",
+ 1. / avg, frame_count, total_duration);
+ fflush (stdout);
}
#ifndef min
diff --git a/demo.h b/demo.h
index 829586e..23855a0 100644
--- a/demo.h
+++ b/demo.h
@@ -40,6 +40,23 @@ enum split {
SPLIT_TOP_RIGHT,
SPLIT_BOTTOM_LEFT,
SPLIT_BOTTOM_RIGHT,
+
+ SPLIT_1_16 = 0x10,
+ SPLIT_2_16,
+ SPLIT_3_16,
+ SPLIT_4_16,
+ SPLIT_5_16,
+ SPLIT_6_16,
+ SPLIT_7_16,
+ SPLIT_8_16,
+ SPLIT_9_16,
+ SPLIT_10_16,
+ SPLIT_11_16,
+ SPLIT_12_16,
+ SPLIT_13_16,
+ SPLIT_14_16,
+ SPLIT_15_16,
+ SPLIT_16_16,
};
enum split device_get_split(int argc, char **argv);
@@ -123,5 +140,7 @@ fps_draw (cairo_t *cr, const char *name, const char *version,
const struct timeval *now);
void
fps_finish (struct framebuffer *fb,
+ const char *backend,
+ const char *version,
const char *name,
- const char *version);
+ ...);
diff --git a/dragon-demo.c b/dragon-demo.c
index a9dd81e..4d7b5d9 100644
--- a/dragon-demo.c
+++ b/dragon-demo.c
@@ -255,7 +255,7 @@ int main (int argc, char **argv)
dragon(cr, device->width, device->height, iterations, stroke);
cairo_destroy(cr);
- fps_finish(fb, device->name, version);
+ fps_finish(fb, device->name, version, "dragon");
fb->show (fb);
fb->destroy (fb);
pause();
diff --git a/fish-demo.c b/fish-demo.c
index d6d32bb..8376eec 100644
--- a/fish-demo.c
+++ b/fish-demo.c
@@ -302,7 +302,7 @@ int main (int argc, char **argv)
fish_draw(device, cr, &fish[n], reflection, x1, x2, strip);
cairo_destroy(cr);
- fps_finish(fb, device->name, version);
+ fps_finish(fb, device->name, version, "fish");
fb->show (fb);
fb->destroy (fb);
pause();
diff --git a/flowers-demo.c b/flowers-demo.c
index a875a10..326d684 100644
--- a/flowers-demo.c
+++ b/flowers-demo.c
@@ -457,7 +457,7 @@ int main (int argc, char **argv)
cairo_destroy(cr);
- fps_finish(fb, device->name, version);
+ fps_finish(fb, device->name, version, "flowers%s", naive ? "-naive" : "");
fb->show (fb);
fb->destroy (fb);
pause();
diff --git a/gears-demo.c b/gears-demo.c
index c7dd78e..60a2182 100644
--- a/gears-demo.c
+++ b/gears-demo.c
@@ -299,7 +299,7 @@ int main (int argc, char **argv)
cairo_destroy(cr);
- fps_finish(fb, device->name, version);
+ fps_finish(fb, device->name, version, "gears");
fb->show (fb);
fb->destroy (fb);
pause ();
diff --git a/glx.c b/glx.c
index 1f9435d..049e9bc 100644
--- a/glx.c
+++ b/glx.c
@@ -63,6 +63,7 @@ glx_open (int argc, char **argv)
Screen *scr;
int screen;
XSetWindowAttributes attr;
+ enum split split;
int i, x, y;
dpy = XOpenDisplay (NULL);
@@ -92,7 +93,7 @@ glx_open (int argc, char **argv)
device_get_size (argc, argv,
&device->base.width, &device->base.height);
x = y = 0;
- switch (device_get_split(argc, argv)) {
+ switch ((split = device_get_split(argc, argv))) {
case SPLIT_NONE:
break;
case SPLIT_LEFT:
@@ -125,6 +126,16 @@ glx_open (int argc, char **argv)
x = device->base.width /= 2;
device->base.height /= 2;
break;
+
+ case SPLIT_1_16...SPLIT_16_16:
+ split -= SPLIT_1_16;
+ x = split & 3;
+ y = (split >> 2) & 3;
+ device->base.width /= 4;
+ device->base.height /= 4;
+ x *= device->base.width;
+ y *= device->base.height;
+ break;
}
vi = glXChooseVisual (dpy, DefaultScreen (dpy), rgba_attribs);
diff --git a/gradient-demo.c b/gradient-demo.c
index d368a09..4ca4584 100644
--- a/gradient-demo.c
+++ b/gradient-demo.c
@@ -254,7 +254,7 @@ int main (int argc, char **argv)
draw(cr, device->width, device->height);
cairo_destroy(cr);
- fps_finish(fb, device->name, version);
+ fps_finish(fb, device->name, version, "gradient");
fb->show (fb);
fb->destroy (fb);
pause();
diff --git a/many.sh b/many.sh
new file mode 100755
index 0000000..44f285c
--- /dev/null
+++ b/many.sh
@@ -0,0 +1,24 @@
+#/bin/bash
+set -m
+
+./bubble-demo --split=0 $* &
+./chart-demo --split=1 $* &
+./chart-demo --vertical --split=2 $* &
+./dragon-demo --split=3 $* &
+./fish-demo --split=4 $* &
+./flowers-demo --split=5 $* &
+./gears-demo --split=6 $* &
+./gradient-demo --split=7 $* &
+./maze-demo --split=8 $* &
+./slideshow-demo --split=9 $* &
+./spinner-demo --split=10 $* &
+./spiral-demo --split=11 $* &
+./tiger-demo --split=12 $* &
+./waterfall-demo --split=13 $* &
+./wave-demo --split=14 $* &
+./flowers-demo --naive --split=15 $* &
+
+sleep 60
+kill -HUP %1 %2 %3 %4 %5 %6 %7 %8 %9 %10 %11 %12 %13 %14 %15 %16
+sleep 10
+kill %1 %2 %3 %4 %5 %6 %7 %8 %9 %10 %11 %12 %13 %14 %15 %16
diff --git a/maze-demo.c b/maze-demo.c
index 23535d6..aa1d363 100644
--- a/maze-demo.c
+++ b/maze-demo.c
@@ -392,7 +392,7 @@ int main (int argc, char **argv)
show(cr, device->width, device->height, use_mask);
cairo_destroy(cr);
- fps_finish(fb, device->name, version);
+ fps_finish(fb, device->name, version, "maze");
fb->show (fb);
fb->destroy (fb);
pause();
diff --git a/multi.sh b/multi.sh
new file mode 100755
index 0000000..e297a7d
--- /dev/null
+++ b/multi.sh
@@ -0,0 +1,11 @@
+#/bin/bash
+set -m
+
+for i in `seq 0 15`; do
+ $* --split=$i &
+done
+
+sleep 60
+kill -HUP %1 %2 %3 %4 %5 %6 %7 %8 %9 %10 %11 %12 %13 %14 %15 %16
+sleep 10
+kill %1 %2 %3 %4 %5 %6 %7 %8 %9 %10 %11 %12 %13 %14 %15 %16
diff --git a/pythagoras-demo.c b/pythagoras-demo.c
index b1b72b1..753a39f 100644
--- a/pythagoras-demo.c
+++ b/pythagoras-demo.c
@@ -173,7 +173,7 @@ int main (int argc, char **argv)
pythagoras(cr, device->width, device->height, 2048);
cairo_destroy(cr);
- fps_finish(fb, device->name, version);
+ fps_finish(fb, device->name, version, "pythagoras");
fb->show (fb);
fb->destroy (fb);
pause();
diff --git a/sierpinski-demo.c b/sierpinski-demo.c
index 9188e24..71ef078 100644
--- a/sierpinski-demo.c
+++ b/sierpinski-demo.c
@@ -151,7 +151,7 @@ int main (int argc, char **argv)
draw(cr, device->width, device->height, 2048, 0);
cairo_destroy(cr);
- fps_finish(fb, device->name, version);
+ fps_finish(fb, device->name, version, "sierpinksi");
fb->show (fb);
fb->destroy (fb);
pause();
diff --git a/slideshow-demo.c b/slideshow-demo.c
index 284a1a9..9e53001 100644
--- a/slideshow-demo.c
+++ b/slideshow-demo.c
@@ -161,18 +161,27 @@ static void load_sources(const char *path,
load_sources_file(path, device, target);
}
+static int done;
+static void signal_handler(int sig)
+{
+ done = sig;
+}
+
int main(int argc, char **argv)
{
struct device *device;
struct timeval start, last_tty, last_fps, now;
- int frames, n;
- int show_fps = 1;
+ int frame, n;
int transition = 1;
double divide = 1.;
const char *version;
+ int benchmark;
device = device_open(argc, argv);
version = device_show_version(argc, argv);
+ benchmark = device_get_benchmark(argc, argv);
+ if (benchmark == 0)
+ benchmark = 20;
g_type_init();
@@ -183,8 +192,6 @@ int main(int argc, char **argv)
prescale = 1;
} else if (strcmp (argv[n], "--no-preload") == 0) {
preload = 0;
- } else if (strcmp (argv[n], "--hide-fps") == 0) {
- show_fps = 0;
} else if (strcmp (argv[n], "--no-transition") == 0) {
transition = 0;
}
@@ -206,8 +213,10 @@ int main(int argc, char **argv)
if (num_sources == 0)
return 0;
+ signal(SIGHUP, signal_handler);
+
gettimeofday(&start, 0); now = last_tty = last_fps = start;
- n = frames = 0;
+ n = frame = 0;
do {
struct framebuffer *fb = device->get_framebuffer (device);
struct source *left = &sources[n % num_sources];
@@ -251,26 +260,41 @@ int main(int argc, char **argv)
n++;
gettimeofday(&now, NULL);
- if (show_fps) {
- if (last_fps.tv_sec)
- fps_draw(cr, device->name, version, &last_fps, &now);
- last_fps = now;
+ if (benchmark < 0 && last_fps.tv_sec) {
+ cairo_reset_clip (cr);
+ fps_draw(cr, device->name, version, &last_fps, &now);
}
+ last_fps = now;
cairo_destroy(cr);
fb->show (fb);
fb->destroy (fb);
- frames++;
- delta = now.tv_sec - last_tty.tv_sec;
- delta += (now.tv_usec - last_tty.tv_usec)*1e-6;
- if (delta > 5) {
- printf("%.2f fps\n", frames/delta);
- last_tty = now;
- frames = 0;
+ frame++;
+ if (benchmark > 0) {
+ delta = now.tv_sec - start.tv_sec;
+ delta += (now.tv_usec - start.tv_usec)*1e-6;
+ if (delta > benchmark) {
+ printf("fish: %.2f fps\n", frame / delta);
+ break;
+ }
}
- } while (1);
+ } while (!done);
+
+ if (benchmark < 0) {
+ struct framebuffer *fb = device->get_framebuffer (device);
+ cairo_t *cr = cairo_create(fb->surface);
+
+ cairo_set_source_rgb(cr, 1, 1, 1);
+ cairo_paint(cr);
+ cairo_destroy(cr);
+
+ fps_finish(fb, device->name, version, "slideshow");
+ fb->show (fb);
+ fb->destroy (fb);
+ pause();
+ }
return 0;
}
diff --git a/spinner-demo.c b/spinner-demo.c
index 95bb6c1..1cb99f7 100644
--- a/spinner-demo.c
+++ b/spinner-demo.c
@@ -249,7 +249,7 @@ int main(int argc, char **argv)
cairo_destroy(cr);
- fps_finish(fb, device->name, version);
+ fps_finish(fb, device->name, version, "spinner");
fb->show (fb);
fb->destroy (fb);
pause();
diff --git a/spiral-demo.c b/spiral-demo.c
index 7d83bae..3acdc38 100644
--- a/spiral-demo.c
+++ b/spiral-demo.c
@@ -177,7 +177,7 @@ int main (int argc, char **argv)
spiral_draw(device, cr, antialias, clip);
cairo_destroy(cr);
- fps_finish(fb, device->name, version);
+ fps_finish(fb, device->name, version, "spiral");
fb->show (fb);
fb->destroy (fb);
pause();
diff --git a/tiger-demo.c b/tiger-demo.c
index 678e8c4..72dcf68 100644
--- a/tiger-demo.c
+++ b/tiger-demo.c
@@ -161,7 +161,7 @@ int main (int argc, char **argv)
if (benchmark < 0) {
struct framebuffer *fb = device->get_framebuffer (device);
tiger (device, fb, antialias, clip, 0.5, 0);
- fps_finish(fb, device->name, version);
+ fps_finish(fb, device->name, version, "tiger");
fb->show (fb);
fb->destroy (fb);
pause();
diff --git a/waterfall-demo.c b/waterfall-demo.c
index 32da93a..0d84963 100644
--- a/waterfall-demo.c
+++ b/waterfall-demo.c
@@ -199,7 +199,7 @@ int main (int argc, char **argv)
waterfall_draw(&waterfall, cr);
cairo_destroy(cr);
- fps_finish(fb, waterfall.device->name, version);
+ fps_finish(fb, waterfall.device->name, version, "waterfall");
fb->show (fb);
fb->destroy (fb);
pause();
diff --git a/wave-demo.c b/wave-demo.c
index 0ec585b..076f0ad 100644
--- a/wave-demo.c
+++ b/wave-demo.c
@@ -191,7 +191,7 @@ int main (int argc, char **argv)
wave(cr, device->width, device->height);
cairo_destroy(cr);
- fps_finish(fb, device->name, version);
+ fps_finish(fb, device->name, version, "wave");
fb->show (fb);
fb->destroy (fb);
pause();
diff --git a/ximage.c b/ximage.c
index 7420708..afabfcf 100644
--- a/ximage.c
+++ b/ximage.c
@@ -72,6 +72,7 @@ ximage_open (int argc, char **argv)
Window win;
int screen;
XSetWindowAttributes attr;
+ enum split split;
int i, similar, map;
int x, y;
@@ -97,7 +98,7 @@ ximage_open (int argc, char **argv)
device->base.height = HeightOfScreen (scr);
device_get_size (argc, argv, &device->base.width, &device->base.height);
x = y = 0;
- switch (device_get_split(argc, argv)) {
+ switch ((split = device_get_split(argc, argv))) {
case SPLIT_NONE:
break;
case SPLIT_LEFT:
@@ -130,6 +131,16 @@ ximage_open (int argc, char **argv)
x = device->base.width /= 2;
device->base.height /= 2;
break;
+
+ case SPLIT_1_16...SPLIT_16_16:
+ split -= SPLIT_1_16;
+ x = split & 3;
+ y = (split >> 2) & 3;
+ device->base.width /= 4;
+ device->base.height /= 4;
+ x *= device->base.width;
+ y *= device->base.height;
+ break;
}
attr.override_redirect = True;
diff --git a/xlib.c b/xlib.c
index b98735b..fe1b58e 100644
--- a/xlib.c
+++ b/xlib.c
@@ -159,6 +159,7 @@ xlib_open (int argc, char **argv)
int screen;
XSetWindowAttributes attr;
int x, y;
+ enum split split;
dpy = XOpenDisplay (NULL);
if (dpy == NULL)
@@ -176,7 +177,7 @@ xlib_open (int argc, char **argv)
device->base.height = HeightOfScreen (scr);
device_get_size (argc, argv, &device->base.width, &device->base.height);
x = y = 0;
- switch (device_get_split(argc, argv)) {
+ switch ((split = device_get_split(argc, argv))) {
case SPLIT_NONE:
break;
case SPLIT_LEFT:
@@ -209,6 +210,16 @@ xlib_open (int argc, char **argv)
x = device->base.width /= 2;
device->base.height /= 2;
break;
+
+ case SPLIT_1_16...SPLIT_16_16:
+ split -= SPLIT_1_16;
+ x = split & 3;
+ y = (split >> 2) & 3;
+ device->base.width /= 4;
+ device->base.height /= 4;
+ x *= device->base.width;
+ y *= device->base.height;
+ break;
}
attr.override_redirect = True;
diff --git a/xshm.c b/xshm.c
index 27adbff..e5d9025 100644
--- a/xshm.c
+++ b/xshm.c
@@ -89,6 +89,7 @@ xshm_open (int argc, char **argv)
Screen *scr;
int screen;
XSetWindowAttributes attr;
+ enum split split;
int major, minor, has_pixmap;
int x, y;
XGCValues gcv;
@@ -113,7 +114,7 @@ xshm_open (int argc, char **argv)
device->base.height = HeightOfScreen (scr);
device_get_size (argc, argv, &device->base.width, &device->base.height);
x = y = 0;
- switch (device_get_split(argc, argv)) {
+ switch ((split = device_get_split(argc, argv))) {
case SPLIT_NONE:
break;
case SPLIT_LEFT:
@@ -146,6 +147,16 @@ xshm_open (int argc, char **argv)
x = device->base.width /= 2;
device->base.height /= 2;
break;
+
+ case SPLIT_1_16...SPLIT_16_16:
+ split -= SPLIT_1_16;
+ x = split & 3;
+ y = (split >> 2) & 3;
+ device->base.width /= 4;
+ device->base.height /= 4;
+ x *= device->base.width;
+ y *= device->base.height;
+ break;
}
attr.override_redirect = True;