summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fwbench.c55
-rwxr-xr-xfwbench.sh2
2 files changed, 44 insertions, 13 deletions
diff --git a/fwbench.c b/fwbench.c
index 01a879b..90072f8 100644
--- a/fwbench.c
+++ b/fwbench.c
@@ -21,6 +21,7 @@
#include "config.h"
//#define USE_FIFO
+#define WRITE_RANDOM "/dev/frandom"
#define WRITE_INTERVAL 1
#define WRITE_SUMMARY 5
#define DELTA_TOLERANCE 5
@@ -34,6 +35,7 @@
const char *fifo_name = ".fifo";
struct setup_s {
+ size_t uc;
size_t width;
size_t height;
size_t bpp;
@@ -81,6 +83,7 @@ typedef enum {
OPT_FPF = 'f',
OPT_MISSING = 'm',
OPT_QUIET = 'q',
+ OPT_UC = 'u',
OPT_HELP = 'h'
} options_t;
@@ -111,7 +114,8 @@ void Usage(int argc, char* const argv[], const char *format, ...) {
" -n frames - Number of frames to write\n"
" -g <width>x<height> - Geometry [1024]\n"
" -g <pixels> - Number of megapixels [0.7]\n"
-" -m <percent> - Tolerable missing frames [100%%]\n"
+" -m <percent> - Tolerable missing frames [100%%]\n"
+" -u <size> - Use uncompressable data, repeating block (MB)\n"
" -q - Quiete\n"
" -h - Help\n"
"\n\n",
@@ -184,6 +188,9 @@ static void set_fail_tolerance(setup_t *setup, double fail_rate) {
setup->tolerance = fail_rate;
}
+static void request_uncompressable_data(setup_t *setup, size_t uc) {
+ setup->uc = uc;
+}
static int callback(setup_t *s, size_t result, void *buffer);
@@ -230,28 +237,46 @@ static void *run(setup_t *setup) {
size_t i;
struct timeval tv;
size_t size = setup->width * setup->height * setup->bpp;
- char buffer[size];
+ size_t pos = 0, mult = setup->uc / size;
+ char *buffer = malloc((mult + 1) * size);
double interval = 1000000. / setup->fps, nextus;
ssize_t tmp;
size_t nexts;
+ g_assert(buffer);
+
+ if (!mult) mult = 1;
+
+# ifdef WRITE_RANDOM
+ if (setup->uc) {
+ printf("Generating %zu MB of randomness...\n", mult * size / 1024 / 1024);
+ int rfd = open(WRITE_RANDOM, O_RDONLY);
+ g_assert(rfd >= 0);
+ read(rfd, buffer, mult * size);
+ close(rfd);
+ }
+# endif /* WRITE_RANDOM */
+
setup->run_started = 1;
-#ifdef USE_FIFO
+# ifdef USE_FIFO
int fd = open(fifo_name, O_WRONLY);
g_assert(fd >= 0);
-#endif /* USE_FIFO */
+# endif /* USE_FIFO */
+
gettimeofday(&tv, NULL);
nexts = tv.tv_sec;
nextus = tv.tv_usec + interval;
for (i = 0; i < setup->iters; i++) {
-#ifdef USE_FIFO
- ssize_t res = write(fd, buffer, size);
+# ifdef USE_FIFO
+ ssize_t res = write(fd, buffer + pos * size, size);
g_assert(res == size);
-#else /* USE_FIFO */
- callback(setup, size, buffer);
-#endif /* USE_FIFO */
+# else /* USE_FIFO */
+ callback(setup, size, buffer + pos * size);
+# endif /* USE_FIFO */
+ if ((++pos) == mult) pos = 0;
+
tmp = ((size_t)round(nextus)) / 1000000;
nexts += tmp;
nextus -= tmp * 1000000;
@@ -263,10 +288,11 @@ static void *run(setup_t *setup) {
nextus += interval;
}
-#ifdef USE_FIFO
+# ifdef USE_FIFO
close(fd);
-#endif /* USE_FIFO */
+# endif /* USE_FIFO */
+ free(buffer);
#endif /* USE_UFO_GENERATOR */
return NULL;
@@ -400,6 +426,7 @@ int main(int argc, char* const argv[])
size_t height = 768;
size_t speed = 850;
size_t size = 0;
+ size_t uc = 0;
size_t run_time = 0;
size_t iters = 0x7FFFFFFF;
size_t fw_buffer = 0;
@@ -418,7 +445,7 @@ int main(int argc, char* const argv[])
- while ((c = getopt(argc, argv, "hqo:s:t:r:n:g:f:m:b:")) != (unsigned char)-1) {
+ while ((c = getopt(argc, argv, "hqo:s:u:t:r:n:g:f:m:b:")) != (unsigned char)-1) {
switch (c) {
case OPT_OUTPUT:
out = optarg;
@@ -429,6 +456,9 @@ int main(int argc, char* const argv[])
case OPT_SIZE:
size = atol(optarg);
break;
+ case OPT_UC:
+ uc = atol(optarg);
+ break;
case OPT_TIME:
run_time = atol(optarg);
break;
@@ -484,6 +514,7 @@ int main(int argc, char* const argv[])
set_fail_tolerance(&setup, fail_rate);
set_frames_per_file(&setup, fpf);
+ request_uncompressable_data(&setup, uc * 1024 * 1024);
setup.fw = fastwriter_init(setup.fs, FASTWRITER_FLAGS_OVERWRITE);
g_assert(setup.fw);
diff --git a/fwbench.sh b/fwbench.sh
index c5b4e49..efe0cb2 100755
--- a/fwbench.sh
+++ b/fwbench.sh
@@ -34,7 +34,7 @@ speed=$((speed + 50))
res=1
while [ $res -ne 0 ]; do
speed=$((speed - 50))
- fwbench -b 1024 -m 0 -r $speed -s $size -o $out
+ fwbench -b 1024 -m 0 -u 512 -r $speed -s $size -o $out
res=$?
usleep 500000
done