From 69efd3bad2c7c641b4bee1cd3609e0b3c8866db3 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 5 Nov 2014 23:11:58 +0100 Subject: make it possible to select file to benchmark over MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/benchmark.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/benchmark.c b/src/benchmark.c index 119f6ed..4090b68 100644 --- a/src/benchmark.c +++ b/src/benchmark.c @@ -25,7 +25,14 @@ #include -#define MESSAGE_LEN 34520 /* The size of the file LICENSE. */ +#ifndef MESSAGE_FILE +# define MESSAGE_FILE "LICENSE" +#endif +#ifndef MESSAGE_LEN +# define MESSAGE_LEN 34520 +#endif + + #ifndef BITRATE # define BITRATE 1024 #endif @@ -69,12 +76,12 @@ int main(void) struct timespec start, end; long i, r; - /* Fill message with connent from the file LICENSE. */ + /* Fill message with content from the file. */ { int fd; ssize_t got; size_t ptr; - if (fd = open("LICENSE", O_RDONLY), fd < 0) + if (fd = open(MESSAGE_FILE, O_RDONLY), fd < 0) return perror("open"), 1; for (ptr = 0; ptr < MESSAGE_LEN; ptr += (size_t)got) if (got = read(fd, message, MESSAGE_LEN - ptr), got <= 0) -- cgit v1.2.3-70-g09d2