summaryrefslogtreecommitdiff
path: root/source/test/unittests
diff options
context:
space:
mode:
authorMitya Selivanov <automainint@guattari.tech>2023-03-27 10:02:38 +0200
committerMitya Selivanov <automainint@guattari.tech>2023-03-27 10:02:38 +0200
commit4eca708d8e693438d4e643dff7283f3cfb79d360 (patch)
tree4ffc2a6b8632a88e33617a152e657e2e522f5f6a /source/test/unittests
parentfc820c883938e7daa257820c818a5c6b609f755f (diff)
downloadkit-4eca708d8e693438d4e643dff7283f3cfb79d360.zip
Benchmark multiple cycles
Diffstat (limited to 'source/test/unittests')
-rw-r--r--source/test/unittests/foo.bench.c20
1 files changed, 18 insertions, 2 deletions
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") { }