diff options
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 49 |
1 files changed, 36 insertions, 13 deletions
@@ -17,6 +17,7 @@ static struct settings settings = {0, 0, 0, NULL, NULL, mode_normal, array, cached}; +static int bench (struct stream * const in, struct stream * const out); static int parseargs(int argc, char **argv, struct settings * settings); static int load_io_functions(struct settings const * const s, struct stream * const in); static void printhelp(const char * const name); @@ -29,8 +30,6 @@ static struct stream file_in = stream_blank; static struct stream file_out = stream_blank; static struct stream file_tmp = stream_blank; -static struct rin_bench_result bongholio; - int main(int argc, char **argv) { int ret = 0; @@ -75,19 +74,9 @@ int main(int argc, char **argv) try_s((ret = cache_transfer(&file_in, &file_out)), out); break; case mode_normal: - - /* BENCHMARK STARTS HERE */ - rin_bench_start(); - try_s((ret = merge_sort(&file_in, &file_tmp)), out); - rin_bench_stop(&bongholio); - /* BENCHMARK ENDS HERE */ - rin_info("wall: %lus %3lums %3luµs", bongholio.wall.tv_sec, bongholio.wall.tv_nsec / (1000 * 1000), (bongholio.wall.tv_nsec / 1000) % 1000); - rin_info("system: %lus %3lums %3luµs", bongholio.system.tv_sec, bongholio.system.tv_usec / 1000, bongholio.system.tv_usec % 1000); - rin_info("user: %lus %3lums %3luµs", bongholio.user.tv_sec, bongholio.user.tv_usec / 1000, bongholio.user.tv_usec % 1000); - rin_info("total: %lus %3lums %3luµs", bongholio.total.tv_sec, bongholio.total.tv_usec / 1000, bongholio.total.tv_usec % 1000); + bench(&file_in, &file_tmp); try_s((ret = cache_transfer(&file_tmp, &file_out)), out); } - } else { /* uncached */ /* TODO */ } @@ -108,6 +97,40 @@ early_out: return ret; } +static int bench(struct stream * const in, struct stream * const out) +{ + int ret; + struct rin_bench_result bongholio; + + /* BENCHMARK STARTS HERE */ + rin_bench_start(); + + try_s((ret = merge_sort(in, out)), err); + + /* BENCHMARK ENDS HERE */ + rin_bench_stop(&bongholio); + + rin_info("wall: %lus %3lums %3luµs", + bongholio.wall.tv_sec, + bongholio.wall.tv_nsec / (1000 * 1000), + (bongholio.wall.tv_nsec / 1000) % 1000); + rin_info("system: %lus %3lums %3luµs", + bongholio.system.tv_sec, + bongholio.system.tv_usec / 1000, + bongholio.system.tv_usec % 1000); + rin_info("user: %lus %3lums %3luµs", + bongholio.user.tv_sec, + bongholio.user.tv_usec / 1000, + bongholio.user.tv_usec % 1000); + rin_info("total: %lus %3lums %3luµs", + bongholio.total.tv_sec, + bongholio.total.tv_usec / 1000, + bongholio.total.tv_usec % 1000); + +err: + return ret; +} + static int parseargs(int argc, char **argv, struct settings * settings) { struct settings s = {0}; |