summaryrefslogtreecommitdiff
path: root/ini/bench.c
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2026-07-18 13:34:49 -0400
committerAndrew Opalach <andrew@akon.city> 2026-07-18 13:45:01 -0400
commit72f5ec3ce777fc05150856f1841e60b0f5c9f8f7 (patch)
tree9b26fd3b314bcf3a2259704c076d819212f172f0 /ini/bench.c
parente6b1631d27f9fe54f3cdd3d7ee1e65d726927e3c (diff)
downloadcetris-72f5ec3ce777fc05150856f1841e60b0f5c9f8f7.tar.gz
cetris-72f5ec3ce777fc05150856f1841e60b0f5c9f8f7.tar.bz2
cetris-72f5ec3ce777fc05150856f1841e60b0f5c9f8f7.zip
restore old frontends as they were
Minimal changes, just enough to get them building and running. Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'ini/bench.c')
-rw-r--r--ini/bench.c52
1 files changed, 52 insertions, 0 deletions
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 <time.h>
+#include <stdio.h>
+
+#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;
+}