- Add nix flake commands: bench, bench-poop, bench-quick - Add hyperfine and poop to devShell - Document benchmark results with hyperfine/poop output - Explain why Lux matches C (gcc's recursion optimization) - Add HTTP server benchmark files (C, Rust, Zig) - Add Zig versions of all benchmarks Key findings: - Lux (compiled): 28.1ms - fastest - C (gcc -O3): 29.0ms - 1.03x slower - Rust: 41.2ms - 1.47x slower - Zig: 47.0ms - 1.67x slower The performance comes from gcc's aggressive recursion-to-loop transformation, which LLVM (Rust/Zig) doesn't perform as aggressively. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
17 lines
326 B
Zig
17 lines
326 B
Zig
// Sum loop benchmark - tight numeric loop
|
|
const std = @import("std");
|
|
|
|
fn sumTo(n: i64) i64 {
|
|
var sum: i64 = 0;
|
|
var i: i64 = 1;
|
|
while (i <= n) : (i += 1) {
|
|
sum += i;
|
|
}
|
|
return sum;
|
|
}
|
|
|
|
pub fn main() void {
|
|
const result = sumTo(10000000);
|
|
std.debug.print("Sum 1 to 10M: {d}\n", .{result});
|
|
}
|