From 53695d66a3be79f9bfa3fd130e5ec8cc475a1473 Mon Sep 17 00:00:00 2001 From: jpekkila Date: Tue, 26 Nov 2019 16:26:31 +0200 Subject: [PATCH] Benchmarking now prints out also percentiles --- src/standalone/benchmark.cc | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/standalone/benchmark.cc b/src/standalone/benchmark.cc index 39a1e4d..f8dcdf2 100644 --- a/src/standalone/benchmark.cc +++ b/src/standalone/benchmark.cc @@ -40,6 +40,12 @@ #include #include +static bool +smaller_than(const double& a, const double& b) +{ + return a < b; +} + int run_benchmark(const char* config_path) { @@ -59,21 +65,37 @@ run_benchmark(const char* config_path) acInit(mesh_info); acLoad(*mesh); + std::vector results; + results.reserve(num_iters); + // Warmup for (int i = 0; i < 10; ++i) { acIntegrate(0); } + acSynchronize(); + const AcReal dt = FLT_EPSILON; Timer total_time; timer_reset(&total_time); + + Timer step_time; for (int i = 0; i < num_iters; ++i) { - const AcReal dt = FLT_EPSILON; + timer_reset(&step_time); + acIntegrate(dt); + acSynchronize(); + + results.push_back(timer_diff_nsec(step_time) / 1e6); } - acSynchronizeStream(STREAM_ALL); - const double ms_elapsed = timer_diff_nsec(total_time) / 1e6; + acSynchronize(); + const double ms_elapsed = timer_diff_nsec(total_time) / 1e6; + const double nth_percentile = 0.95; + std::sort(results.begin(), results.end(), smaller_than); + printf("vertices: %d^3, iterations: %d\n", nn, num_iters); printf("Total time: %f ms\n", ms_elapsed); + printf("%dth percentile per step: %f ms\n", int(100 * nth_percentile), + results[int(nth_percentile * num_iters)]); acQuit(); acmesh_destroy(mesh);