Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



Why not read the source code? :-)

I wrote comments explaining things: https://github.com/benhoyt/countwords/blob/8553c8f600c40a462...


Most 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).


The naive implementation is slower mostly because of the DOS resistant hasher in the Rust stdlib, and the smallish buffer a line represents.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: