3 ms·
People seem to love coming into the Rust community and then saying - hey, I did this micro benchmark after just learning rust - and XYZ language is faster! Any
by jkelleyrtp 6y ago
People seem to love coming into the Rust community and then saying - hey, I did this micro benchmark after just learning rust - and XYZ language is faster!
Anyone who's been writing rust for a little bit will notice the String clone like a sore thumb. The "go-to-perf-guide" also very explicitly states than clones on String/Vec/Box etc will cause an allocation and slow down your code.
https://gist.github.com/jFransham/369a86eff00e5f280ed25121454acec1 https://gist.github.com/jFransham/369a86eff00e5f280ed2512145...
In every one of these micro benchmarks, the comments will then show that by removing the alloc, the Rust version ends up much much faster.
String cloning is one of those things you learn to avoid early on, and any time you type "clone" it should be obvious that there's a better way to write your algorithm.