Files
lux/benchmarks/fib.zig
Brandon Lucas 49ab70829a feat: add comprehensive benchmark suite with flake commands
- 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>
2026-02-16 05:53:10 -05:00

13 lines
267 B
Zig

// Fibonacci benchmark - recursive implementation
const std = @import("std");
fn fib(n: i64) i64 {
if (n <= 1) return n;
return fib(n - 1) + fib(n - 2);
}
pub fn main() void {
const result = fib(35);
std.debug.print("fib(35) = {d}\n", .{result});
}