From 23d1cb35814321125a72fc8198d9a2058def167c Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 18 Sep 2021 20:00:45 -0400 Subject: Simplify benchmark main function --- benchmark/dict_bench.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'benchmark/dict_bench.c') diff --git a/benchmark/dict_bench.c b/benchmark/dict_bench.c index 30f485f..50ac10e 100644 --- a/benchmark/dict_bench.c +++ b/benchmark/dict_bench.c @@ -69,18 +69,8 @@ test_fail(const char* fmt, ...) } int -main(int argc, char** argv) +run(FILE* const fd) { - if (argc != 2) { - return test_fail("Usage: %s INPUT_FILE\n", argv[0]); - } - - const char* file = argv[1]; - FILE* fd = fopen(file, "r"); - if (!fd) { - return test_fail("Failed to open file %s\n", file); - } - size_t max_n_strings = 1u << 20u; /* Read input strings */ @@ -192,6 +182,21 @@ main(int argc, char** argv) fclose(search_dat); fprintf(stderr, "Wrote dict_insert.txt dict_search.txt\n"); - return 0; } + +int +main(int argc, char** argv) +{ + if (argc != 2) { + return test_fail("Usage: %s INPUT_FILE\n", argv[0]); + } + + const char* file = argv[1]; + FILE* fd = fopen(file, "r"); + if (!fd) { + return test_fail("Failed to open file %s\n", file); + } + + return run(fd); +} -- cgit v1.2.1