Constructs
Raw Struct Race · Identity construct versus inline pair
A local Range construct whose unobservable identity is eliminated versus optimized inline 32-bit C, C++, Rust, Go, and Swift valuesRaw Struct Race
Identity construct versus inline pair
A local Range construct whose unobservable identity is eliminated versus optimized inline 32-bit C, C++, Rust, Go, and Swift values
C 133.6 msabsolute best
Range 133.6 ms
C++ 133.8 ms
Rust 134.2 ms
Swift 134.7 ms
Go 156.4 ms
Test code
#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
typedef struct { int32_t x; int32_t y; } Pair;
int main(int argc, char **argv) {
int32_t n = argc > 1 ? (int32_t)atoi(argv[1]) : 40000000;
int32_t acc = 0;
for (int32_t i = 0; i < n; i++) {
Pair pair = (Pair){i, i + 1};
acc = (acc + pair.x + pair.y) % 1000003;
}
printf("%" PRId32 "\n", acc);
}construct Pair {
let x: Int
let y: Int
}
@main {
let n: Int(40000000)
state i: Int(0)
state acc: Int(0)
while i < n {
let pair: Pair(x: i, y: i + 1)
acc: (acc + pair.x + pair.y) % 1000003
i: i + 1
}
return acc % 251
}Measurements
Range passed
| Language | Wall | CPU | Peak memory | Relative | Output |
|---|---|---|---|---|---|
| C | 133.6 ms | 131.3 ms | 1.6 MB | 1.00× | 14400 |
| Range | 133.6 ms | 131.6 ms | 1.6 MB | 1.00× | exit:93 |
| C++ | 133.8 ms | 131.6 ms | 1.6 MB | 1.00× | 14400 |
| Rust | 134.2 ms | 131.9 ms | 1.8 MB | 1.00× | 14400 |
| Swift | 134.7 ms | 132.2 ms | 2.0 MB | 1.01× | 14400 |
| Go | 156.4 ms | 154.1 ms | 4.1 MB | 1.17× | 14400 |
Run procedure
01Generated sourceisolated case directory
02 · optimized builds
- Ccc · O3
- C++c++ · O3
- Rustrustc · opt 3
- Gogo build
- Swiftswiftc · Ounchecked
- RangeLLVM · clang O3
03Rotating run order30 measured runs
04Validate outputexit code + identical result
05Median resultswall · CPU · peak RSS
Commands and notes
N=<base-iterations> RUNS=<sample-count> npm run benchmarkscc -O3 -mcpu=native main.c -o speed-c
./speed-c <iterations>RangeCompiler emit-llvm Playground.range Main.ll
clang -O3 -mcpu=native -Wno-override-module Main.ll <runtime-sources> -o speed-range
./speed-range- The workload count is specialized per leaf; some leaves intentionally scale it down to keep total work comparable.
- Wall time includes process execution but excludes source generation and compilation.
- A result is published only when output remains stable across every measured run.
- Bun and TypeScript rows are omitted when their local toolchains are unavailable.