Files
lux/benchmarks/quicksort.rs
Brandon Lucas 42fef80a47 feat: add comprehensive benchmark suite with multi-language comparison
Add benchmarks comparing Lux against 7 languages:
- Rust, C, Go (compiled)
- Node.js, Bun (JavaScript JIT)
- Python (interpreted)

Benchmarks:
- Fibonacci (fib 35): recursive function calls
- Prime counting (10k): loops and conditionals
- Sum loop (10M): tight numeric loops
- Ackermann (3,10): deep recursion
- Selection sort (1k): sorting algorithm
- List operations (10k): map/filter/fold with closures

Results show Lux:
- Matches C and Rust performance
- 2-5x faster than Go
- 7-15x faster than Node.js
- 10-285x faster than Python

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-14 16:17:06 -05:00

19 lines
645 B
Rust

// Quicksort benchmark - sorting algorithm
fn quicksort(arr: Vec<i64>) -> Vec<i64> {
if arr.len() <= 1 { return arr; }
let pivot = arr[0];
let rest: Vec<i64> = arr[1..].to_vec();
let less: Vec<i64> = rest.iter().filter(|&&x| x < pivot).cloned().collect();
let greater: Vec<i64> = rest.iter().filter(|&&x| x >= pivot).cloned().collect();
let mut result = quicksort(less);
result.push(pivot);
result.extend(quicksort(greater));
result
}
fn main() {
let nums: Vec<i64> = (0..1000).map(|i| (i * 7 + 13) % 1000).collect();
let sorted = quicksort(nums);
println!("Sorted {} elements", sorted.len());
}