diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-11-05 23:11:58 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-11-05 23:11:58 +0100 |
commit | 69efd3bad2c7c641b4bee1cd3609e0b3c8866db3 (patch) | |
tree | f0d8cc661386c044526df7d3c5a88706a7ea4f53 | |
parent | add benchmark program (diff) | |
download | libkeccak-69efd3bad2c7c641b4bee1cd3609e0b3c8866db3.tar.gz libkeccak-69efd3bad2c7c641b4bee1cd3609e0b3c8866db3.tar.bz2 libkeccak-69efd3bad2c7c641b4bee1cd3609e0b3c8866db3.tar.xz |
make it possible to select file to benchmark over
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r-- | src/benchmark.c | 13 |
1 files 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 <time.h> -#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) |