commit 39e19cd3d58ab5c8fce7845c50ada8140ac9b321
parent fc82de5655e14add4985435073ddca56898c4fb4
Author: Plat <plat@stellar-nexus.ru>
Date: Thu, 6 Nov 2025 22:09:58 +0000
Fixed optimizations removing the loop
Diffstat:
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/config.mk b/config.mk
@@ -1,3 +1,3 @@
CC = cc
-CFLAGS = -O3 -pipe
+CFLAGS = -Os -pipe
LDFLAGS = -static
diff --git a/rb.c b/rb.c
@@ -1,6 +1,7 @@
#include <ctype.h>
#include <limits.h>
#include <stdio.h>
+#include <stdint.h>
#include <stdlib.h>
#include <time.h>
@@ -137,11 +138,11 @@ main(int argc, char *argv[])
SET_COLOR(root, BLACK);
}
- /* Searching for every possible value */
+ volatile uintptr_t checksum = 0; /* to avoid optimization */
clock_t start_time, end_time;
start_time = clock();
for (int i = 0; i < TESTNUMBER; ++i)
- search(root, arr[i]);
+ checksum = (uintptr_t)search(root, arr[i]);
end_time = clock();
printf("%f\n", (double)(end_time-start_time)/CLOCKS_PER_SEC);
}