From 4131af3912e1fad6d8d80d12a458052fde827ec7 Mon Sep 17 00:00:00 2001 From: Camden Dixie O'Brien Date: Sun, 10 Nov 2024 16:28:38 +0000 Subject: [PATCH] Assign match result to volatile in benchmarks This is needed to avoid the compiler eliding the call in highly-optimised builds. --- benchmarks/matching_benchmarks.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/benchmarks/matching_benchmarks.c b/benchmarks/matching_benchmarks.c index c98cc12..79a5f2d 100644 --- a/benchmarks/matching_benchmarks.c +++ b/benchmarks/matching_benchmarks.c @@ -31,9 +31,11 @@ static void matching_benchmark(const fsa_t *fsa) for (int j = 0; j < LEN; ++j) s[j] = CLAMP_CHAR(rand()); + volatile bool match; START_CLOCK(); - fsa_accepts(fsa, s, LEN); + match = fsa_accepts(fsa, s, LEN); STOP_CLOCK(); + (void)match; } int main(void)