@@ -7,59 +7,70 @@ Benchmark comparing C (GCC and Clang, C17 and C23 standards) and Zig implementat
77
88## Compiler Versions (Local)
99
10- | Compiler | Version |
11- | ----------| ---------|
10+
11+ | Compiler | Version |
12+ | ----------- | -------------------------------------------- |
1213| GCC (macOS) | Apple Clang 17.0.0 (gcc is aliased to clang) |
13- | Clang | Homebrew Clang 21.1.8 |
14- | Zig | 0.15.2 |
14+ | Clang | Homebrew Clang 21.1.8 |
15+ | Zig | 0.15.2 |
16+
1517
1618## Runtime Results
1719
18- | Version | Execution Time | Relative |
19- | ---------| ---------------| ----------|
20- | GCC C17 | 228ms | 2.23x |
21- | GCC C23 | 102ms | 1.00x (fastest) |
22- | Clang C17 | 107ms | 1.04x |
23- | Clang C23 | 106ms | 1.03x |
24- | Zig | 628ms | 6.15x |
20+
21+ | Version | Execution Time | Relative |
22+ | --------- | -------------- | --------------- |
23+ | GCC C17 | 228ms | 2.23x |
24+ | GCC C23 | 102ms | 1.00x (fastest) |
25+ | Clang C17 | 107ms | 1.04x |
26+ | Clang C23 | 106ms | 1.03x |
27+ | Zig | 628ms | 6.15x |
28+
2529
2630## Binary Sizes
2731
28- | Version | Size |
29- | ---------| ------|
30- | GCC C17 | 33K |
31- | GCC C23 | 33K |
32- | Clang C17 | 33K |
33- | Clang C23 | 33K |
34- | Zig | 1.3M |
32+
33+ | Version | Size |
34+ | --------- | ---- |
35+ | GCC C17 | 33K |
36+ | GCC C23 | 33K |
37+ | Clang C17 | 33K |
38+ | Clang C23 | 33K |
39+ | Zig | 1.3M |
40+
3541
3642## Analysis
3743
3844### C Compilers
45+
3946- ** GCC C23** was fastest in this run (times vary between runs)
4047- ** Clang** produces consistently fast binaries across C17/C23
4148- On macOS, ` gcc ` is actually Apple Clang; real GCC is tested on CI (Ubuntu)
4249
4350### Zig
51+
4452- Slower due to:
4553 - GeneralPurposeAllocator overhead vs C's stack allocation
4654 - Zig 0.15 buffered I/O system overhead
4755 - Additional runtime safety checks
4856- Much larger binary (embeds stdlib, no libc dependency)
4957
5058### Binary Size
59+
5160- All C versions: 33K (links against system libc)
52- - Zig: 1.3M (self-contained, no external dependencies)
61+ - Zig: 1.3M (self-contained, no external dependencies)
5362
5463## Build Configuration
5564
56- | Compiler | Flags |
57- | ----------| -------|
58- | GCC C17 | ` gcc -std=c17 -Wall -Wextra -pedantic ` |
59- | GCC C23 | ` gcc -std=c23 -Wall -Wextra -pedantic ` |
65+
66+ | Compiler | Flags |
67+ | --------- | ---------------------------------------- |
68+ | GCC C17 | ` gcc -std=c17 -Wall -Wextra -pedantic ` |
69+ | GCC C23 | ` gcc -std=c23 -Wall -Wextra -pedantic ` |
6070| Clang C17 | ` clang -std=c17 -Wall -Wextra -pedantic ` |
6171| Clang C23 | ` clang -std=c23 -Wall -Wextra -pedantic ` |
62- | Zig | ` zig build ` (debug mode) |
72+ | Zig | ` zig build ` (debug mode) |
73+
6374
6475## Notes
6576
@@ -80,3 +91,4 @@ Benchmark comparing C (GCC and Clang, C17 and C23 standards) and Zig implementat
8091# Show detected compilers
8192cd c && make info
8293```
94+
0 commit comments