From 4eca708d8e693438d4e643dff7283f3cfb79d360 Mon Sep 17 00:00:00 2001 From: Mitya Selivanov Date: Mon, 27 Mar 2023 10:02:38 +0200 Subject: Benchmark multiple cycles --- source/test/unittests/foo.bench.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'source/test') diff --git a/source/test/unittests/foo.bench.c b/source/test/unittests/foo.bench.c index a3d5c18..ac1e0b5 100644 --- a/source/test/unittests/foo.bench.c +++ b/source/test/unittests/foo.bench.c @@ -1,4 +1,4 @@ -#define KIT_BENCH_FILE foo +#define KIT_TEST_FILE foo #include "../../kit_test/bench.h" struct test_foo_ { @@ -6,8 +6,15 @@ struct test_foo_ { }; BENCHMARK("foo") { + + /* Benchmark setup. + */ + BENCHMARK_BEGIN; { + /* Measured code snippet. + */ + int x = 0; struct test_foo_ f = { 0. }; @@ -16,10 +23,19 @@ BENCHMARK("foo") { x ^= i; f.f += 0.1; } + DO_NOT_OPTIMIZE(x); DO_NOT_OPTIMIZE(f); } BENCHMARK_END; } -BENCHMARK("bar") { } +BENCHMARK("bar") { + BENCHMARK_REPEAT(10); + BENCHMARK_REPEAT(100); + + BENCHMARK_BEGIN; + BENCHMARK_END; +} + +BENCHMARK("empty") { } -- cgit v1.2.3