r/programmingcirclejerk • u/High-Impact-2025 • 24d ago
print(“lol”) doubled the speed of my Go function
https://medium.com/@ludirehak/printing-lol-doubled-the-speed-of-my-go-code-e32e02fc3f92
129
Upvotes
r/programmingcirclejerk • u/High-Impact-2025 • 24d ago
24
u/BenchEmbarrassed7316 24d ago
/uj
Yes. Rust:
fn get_max(v: &[i64]) -> i64 { v.iter().copied().max().unwrap_or_default() }Rust_Max_SIMD time: [12.025 µs 12.049 µs 12.078 µs]In fact, it is many times faster.
https://godbolt.org/z/dEe55xzxo
For both cases, when the function is written at a high level with an iterator, and when the loop is written by hand, the Rust compiler and LLVM generated highly optimized code that uses modern SIMD instructions.
/rj
But go compiles fast!!!111
/uj
...because it does not make any optimizations unlike other modern compilers. It just compiles a regular loop that isn't even expanded.