diff options
author | Andrea Grandi <agrandi@google.com> | 2022-12-27 14:24:10 -0800 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-01-03 22:20:30 +0000 |
commit | 67fbc7ef3e33933db90d427044aa97c3c56e287b (patch) | |
tree | f9d0770870372546c1407acc92087527848f52e9 /test | |
parent | a57ac79c8fba227fff843b744d0a6e5a2c5c1bd0 (diff) | |
download | chrome-ec-67fbc7ef3e33933db90d427044aa97c3c56e287b.tar.gz |
test: Add function to compare BenchmarkResults
BUG=b:263804978
TEST=test/run_device_tests.py -b bloonchipper -t benchmark
TEST=make run-benchmark
BRANCH=none
Change-Id: I042aa1aee854201a4e00a0939f2cb924af0e63f1
Signed-off-by: Andrea Grandi <agrandi@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4126544
Reviewed-by: Josie Nordrum <josienordrum@google.com>
Reviewed-by: Bobby Casey <bobbycasey@google.com>
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/benchmark.cc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/benchmark.cc b/test/benchmark.cc index ca1869a557..9b4017db3a 100644 --- a/test/benchmark.cc +++ b/test/benchmark.cc @@ -83,6 +83,28 @@ test_static int test_long_benchmark() return EC_SUCCESS; } +test_static int test_result_comparison() +{ + constexpr auto result1 = BenchmarkResult{ + .name = "implementation1", + .elapsed_time = 10000, + .average_time = 100, + .min_time = 10, + .max_time = 200, + }; + + constexpr auto result2 = BenchmarkResult{ + .name = "implementation2", + .elapsed_time = 8000, + .average_time = 80, + .min_time = 13, + .max_time = 150, + }; + + BenchmarkResult::compare(result1, result2); + return EC_SUCCESS; +} + test_static int test_empty_benchmark_name() { Benchmark benchmark; @@ -132,6 +154,7 @@ void run_test(int argc, const char **argv) RUN_TEST(test_num_iterations); RUN_TEST(test_multiple_benchmarks); RUN_TEST(test_long_benchmark); + RUN_TEST(test_result_comparison); RUN_TEST(test_too_many_runs); RUN_TEST(test_empty_benchmark_name); RUN_TEST(test_min_max_time); |