From 72f5ec3ce777fc05150856f1841e60b0f5c9f8f7 Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Sat, 18 Jul 2026 13:34:49 -0400 Subject: restore old frontends as they were Minimal changes, just enough to get them building and running. Signed-off-by: Andrew Opalach --- ini/bench.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 ini/bench.c (limited to 'ini/bench.c') diff --git a/ini/bench.c b/ini/bench.c new file mode 100644 index 0000000..00dc170 --- /dev/null +++ b/ini/bench.c @@ -0,0 +1,52 @@ +#include +#include + +#include "ini.h" + +ini_parser parser; + +#define TEST_FILE "test.ini" + +__attribute__((optimize("unroll-loops"))) +double run_bench(int count) { + clock_t start, end; + start = clock(); + + for (int i = 0; i < count; i++) { + get_ini_value(&parser, "Test1", "Test"); + get_ini_value(&parser, "Test1", "String"); + get_ini_value(&parser, "Test1", "Int"); + get_ini_value(&parser, "Test2", "Test"); + get_ini_value(&parser, "Test2", "String"); + get_ini_value(&parser, "Test2", "Int"); + } + + end = clock(); + + return ((double) (end - start)) / CLOCKS_PER_SEC; +} + +int main(void) { + if (!load_ini_file(&parser, TEST_FILE)) { + printf("failed to load file\n"); + } + + printf("Test results:\n"); + + printf("'%s'\n", get_ini_value(&parser, "Test1", "Test")); + printf("'%s'\n", get_ini_value(&parser, "Test1", "String")); + printf("'%s'\n", get_ini_value(&parser, "Test1", "Int")); + printf("'%s'\n", get_ini_value(&parser, "Test2", "Test")); + printf("'%s'\n", get_ini_value(&parser, "Test2", "String")); + printf("'%s'\n", get_ini_value(&parser, "Test2", "Int")); + + printf("Test on file '%s' took %f seconds for 60 queries\n", TEST_FILE, run_bench(10)); + printf("Test on file '%s' took %f seconds for 600 queries\n", TEST_FILE, run_bench(100)); + printf("Test on file '%s' took %f seconds for 6000 queries\n", TEST_FILE, run_bench(1000)); + printf("Test on file '%s' took %f seconds for 60000 queries\n", TEST_FILE, run_bench(10000)); + printf("Test on file '%s' took %f seconds for 600000 queries\n", TEST_FILE, run_bench(100000)); + + unload_ini_file(&parser); + + return 0; +} -- cgit v1.2.3-101-g0448