New benchmarks: - http_benchmark.lux: Minimal HTTP server for throughput testing - Use with wrk or ab for request/second measurements - Target: > 50k req/sec - json_benchmark.lux: JSON parsing performance test - Token counting simulation - Measures iterations per second These complement the existing recursive benchmarks (fib, ackermann) with web-focused performance tests. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
38 lines
1.1 KiB
Plaintext
38 lines
1.1 KiB
Plaintext
// HTTP Server Benchmark
|
|
//
|
|
// A minimal HTTP server for benchmarking request throughput.
|
|
// Run with: lux benchmarks/http_benchmark.lux
|
|
//
|
|
// Test with:
|
|
// wrk -t4 -c100 -d10s http://localhost:8080/
|
|
// OR
|
|
// ab -n 10000 -c 100 http://localhost:8080/
|
|
//
|
|
// Expected: > 50k req/sec on modern hardware
|
|
|
|
fn handleRequest(request: { method: String, path: String, body: String }): { status: Int, body: String } with {Console} = {
|
|
// Minimal JSON response for benchmarking
|
|
{ status: 200, body: "{\"status\":\"ok\"}" }
|
|
}
|
|
|
|
fn serveLoop(): Unit with {Console, HttpServer} = {
|
|
let request = HttpServer.accept()
|
|
let response = handleRequest(request)
|
|
HttpServer.respond(response.status, response.body)
|
|
serveLoop()
|
|
}
|
|
|
|
fn main(): Unit with {Console, HttpServer} = {
|
|
Console.print("HTTP Benchmark Server")
|
|
Console.print("Listening on port 8080...")
|
|
Console.print("")
|
|
Console.print("Test with:")
|
|
Console.print(" wrk -t4 -c100 -d10s http://localhost:8080/")
|
|
Console.print(" ab -n 10000 -c 100 http://localhost:8080/")
|
|
Console.print("")
|
|
HttpServer.listen(8080)
|
|
serveLoop()
|
|
}
|
|
|
|
let result = run main() with {}
|