diff options
author | Joshua Haberman <joshua@reverberate.org> | 2009-08-04 10:12:41 -0700 |
---|---|---|
committer | Joshua Haberman <joshua@reverberate.org> | 2009-08-04 10:12:41 -0700 |
commit | 7eb16a55503855d65c49b0a7e356a317c1325515 (patch) | |
tree | fc49ede3045ca98385d3cc6a2615320d2489e621 /benchmark/main.c | |
parent | 946dcf4a5d9e35046eb4c2bd4c31e2d4633199e0 (diff) |
Beginnings of a more extensive benchmarking suite.
Diffstat (limited to 'benchmark/main.c')
-rw-r--r-- | benchmark/main.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/benchmark/main.c b/benchmark/main.c new file mode 100644 index 0000000..c038287 --- /dev/null +++ b/benchmark/main.c @@ -0,0 +1,32 @@ + +#include <stdbool.h> +#include <time.h> +#include <stdio.h> + +static bool initialize(); +static void cleanup(); +static size_t run(); + +int main (int argc, char *argv[]) +{ + if(!initialize()) { + fprintf(stderr, "%s: failed to initialize\n", argv[0]); + return 1; + } + + size_t total_bytes = 0; + clock_t before = clock(); + for(int i = 0; true; i++) { + if((i & 0xFF) == 0 && (clock() - before > CLOCKS_PER_SEC)) break; + size_t bytes = run(); + if(bytes == 0) { + fprintf(stderr, "%s: failed.\n", argv[0]); + return 2; + } + total_bytes += bytes; + } + double elapsed = ((double)clock() - before) / CLOCKS_PER_SEC; + printf("%s: %d\n", argv[0], (int)(total_bytes / elapsed / (1 << 20))); + cleanup(); + return 0; +} |