From b17726fe51a1c7c1eccaef2e90cbab7ee022557f Mon Sep 17 00:00:00 2001 From: Mitya Selivanov Date: Sun, 26 Mar 2023 18:55:32 +0200 Subject: [benchmarks] DO_NOT_OPTIMIZE macro --- source/test/unittests/foo.bench.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'source/test/unittests') diff --git a/source/test/unittests/foo.bench.c b/source/test/unittests/foo.bench.c index 531f1d8..a3d5c18 100644 --- a/source/test/unittests/foo.bench.c +++ b/source/test/unittests/foo.bench.c @@ -1,11 +1,23 @@ #define KIT_BENCH_FILE foo #include "../../kit_test/bench.h" +struct test_foo_ { + double f; +}; + BENCHMARK("foo") { BENCHMARK_BEGIN; { - volatile int x = 0; - for (int i = 0; i < 200000; i++) x++; + int x = 0; + struct test_foo_ f = { 0. }; + + for (int i = 0; i < 100000; i++) { + x += (1 << 1); + x ^= i; + f.f += 0.1; + } + DO_NOT_OPTIMIZE(x); + DO_NOT_OPTIMIZE(f); } BENCHMARK_END; } -- cgit v1.2.3