Compare commits

..

4 Commits

Author SHA1 Message Date
601829bd29 Increase length of benchmark strings 2024-11-10 16:29:44 +00:00
4131af3912 Assign match result to volatile in benchmarks
This is needed to avoid the compiler eliding the call in
highly-optimised builds.
2024-11-10 16:28:38 +00:00
97529fdd2b Write some matching benchmarks 2024-11-10 15:22:28 +00:00
e4d3b08bf2 Create benchmarking library 2024-11-10 15:22:28 +00:00
2 changed files with 5 additions and 3 deletions

View File

@@ -6,7 +6,7 @@ function(add_benchmark_suite source)
string(REGEX REPLACE ".c$" "" name ${source})
add_executable(${name} ${source})
set_default_target_options(${name})
target_link_libraries(${name} PRIVATE lib benchmarking)
target_link_libraries(${name} PRIVATE lib benchmarking m)
endfunction()
function(add_benchmark_suites)

View File

@@ -11,7 +11,7 @@
#include <string.h>
#include <sys/time.h>
#define LEN 100
#define LEN 1000
#define RANGE_FIRST 'a'
#define RANGE_LAST 'z'
@@ -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)