add benchmark to app. TODO: test benchmark.

This commit is contained in:
TXuian 2022-12-07 16:32:43 +08:00
parent fed2304578
commit 8e634991f7
1 changed files with 13 additions and 11 deletions

View File

@ -41,7 +41,7 @@ BenchmarkPair bmh_list[] = {
// {.handle = &md5_handle, .name = "md5sum", .time = 0}, // // {.handle = &md5_handle, .name = "md5sum", .time = 0}, //
{.handle = &cubic_handle, .name = "cubic", .time = 0}, // {.handle = &cubic_handle, .name = "cubic", .time = 0}, //
{.handle = &edn_handle, .name = "edn", .time = 0}, // {.handle = &edn_handle, .name = "edn", .time = 0}, //
// {.handle = &huffbench_handle, .name = "huffbench", .time = 0}, // {.handle = &huffbench_handle, .name = "huffbench", .time = 0}, //
{.handle = &matmult_int_handle, .name = "matmult-int", .time = 0}, // {.handle = &matmult_int_handle, .name = "matmult-int", .time = 0}, //
{.handle = &libminver_handle, .name = "libminver", .time = 0}, // {.handle = &libminver_handle, .name = "libminver", .time = 0}, //
{.handle = &nobody_handle, .name = "nbody", .time = 0}, // {.handle = &nobody_handle, .name = "nbody", .time = 0}, //
@ -53,11 +53,11 @@ BenchmarkPair bmh_list[] = {
// {.handle = &qrtest_handle, .name = "qrtest", .time = 0}, // // {.handle = &qrtest_handle, .name = "qrtest", .time = 0}, //
// {.handle = &combined_handle, .name = "combined", .time = 0}, // // {.handle = &combined_handle, .name = "combined", .time = 0}, //
{.handle = &slre_handle, .name = "slre", .time = 0}, // {.handle = &slre_handle, .name = "slre", .time = 0}, //
{.handle = &libst_handle, .name = "libst", .time = 0}, // // {.handle = &libst_handle, .name = "libst", .time = 0}, //
{.handle = &statemate_handle, .name = "statemate", .time = 0}, // // {.handle = &statemate_handle, .name = "statemate", .time = 0}, //
{.handle = &tarfind_handle, .name = "tarfind", .time = 0}, // // {.handle = &tarfind_handle, .name = "tarfind", .time = 0}, //
{.handle = &libud_handle, .name = "libud", .time = 0}, // // {.handle = &libud_handle, .name = "libud", .time = 0}, //
{.handle = &libwikisort_handle, .name = "libwikisort", .time = 0}, // // {.handle = &libwikisort_handle, .name = "libwikisort", .time = 0}, //
{.handle = NULL, .name = "", .time = 0}, // {.handle = NULL, .name = "", .time = 0}, //
}; };
@ -88,6 +88,8 @@ void organize_result(const benchmark_handle *handle) {
if (bmh_list[i].handle == handle) { if (bmh_list[i].handle == handle) {
bmh_list[i].time = tmp_diff; bmh_list[i].time = tmp_diff;
break; break;
printf("[BENCHMARK] Time Cost: %-15s %.4f\n", bmh_list[i].name,
bmh_list[i].time);
} }
i++; i++;
} }
@ -134,7 +136,7 @@ int run_benchmark() {
cur_handle = cur_handle->next; cur_handle = cur_handle->next;
} }
print_result(); // print_result();
return (!correct); return (!correct);
} }