- 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>
22 lines
730 B
Rust
22 lines
730 B
Rust
// Minimal HTTP server benchmark - Rust version (single-threaded)
|
|
// Compile: rustc -C opt-level=3 -o http_rust http_server.rs
|
|
// Test: wrk -t2 -c50 -d5s http://localhost:8081/
|
|
|
|
use std::io::{Read, Write};
|
|
use std::net::TcpListener;
|
|
|
|
const RESPONSE: &[u8] = b"HTTP/1.1 200 OK\r\nContent-Type: application/json\r\nContent-Length: 15\r\n\r\n{\"status\":\"ok\"}";
|
|
|
|
fn main() {
|
|
let listener = TcpListener::bind("0.0.0.0:8081").unwrap();
|
|
println!("Rust HTTP server listening on port 8081");
|
|
|
|
for stream in listener.incoming() {
|
|
if let Ok(mut stream) = stream {
|
|
let mut buffer = [0u8; 1024];
|
|
let _ = stream.read(&mut buffer);
|
|
let _ = stream.write_all(RESPONSE);
|
|
}
|
|
}
|
|
}
|