4 ms·
I'm curious why go is faster than rust in the benchmarks. My best theory is that the program doesn't run long enough to trigger a GC, so rust is paying the cost
by thayne 4y ago
I'm curious why go is faster than rust in the benchmarks. My best theory is that the program doesn't run long enough to trigger a GC, so rust is paying the cost of freeing memory, but go isn't. (Using an arena allocator in rust would probably produce similar behavior).
Or maybe the difference is just noise? It's hard to tell without more details on how the benchmarks were run.
- nestorD 4y agoMost of the time you see Rust lose on that kind of benchmark due to it not using buffered algorithm in the standard library (buffers are available and easy to use but they are an option you have to think about and search for).
- mustache_kimono 4y agoThe naive implementation is slower mostly because of the DOS resistant hasher in the Rust stdlib, and the smallish buffer a line represents.
- burntsushi 4y agoWhy not read the source code? :-) I wrote comments explaining things: https://github.com/benhoyt/countwords/blob/8553c8f600c40a4626e966bc7e7e804097e6e2f4/rust/simple/main.rs#L1-L16 https://github.com/benhoyt/countwords/blob/8553c8f600c40a462...