5 ms·
I'm increasingly intrigued by Rust. Can anyone recommend a good analysis / benchmarking of Rust compared to C/C++ code? Curious how it fares on a performance ba
by lordleft 7y ago
I'm increasingly intrigued by Rust. Can anyone recommend a good analysis / benchmarking of Rust compared to C/C++ code? Curious how it fares on a performance basis.
- bluejekyll 7y agoThis is by no means scientific, but it’s a fun benchmark, there’s some debate about the fastest Rust options submitted (ie I believe there were faster than C versions that were rejected). C: https://benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/rust.html https://benchmarksgame-team.pages.debian.net/benchmarksgame/... Clang (for common llvm backend between rust and c): https://benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/rust-clang.html https://benchmarksgame-team.pages.debian.net/benchmarksgame/... C++: https://benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/rust-gpp.html https://benchmarksgame-team.pages.debian.net/benchmarksgame/... Rust is pretty much on par with both C and C++.
- rumanator 7y ago> This is by no means scientific, It's actually very scientific (testing hypothesis, measuring results, etc) but might not be generalizable.
- tasubotadas 7y agoWhat's missing in these tests is that they do not capture the required knowledge by the developer to achieve those results. If anybody has actually checked C/C++ examples, one could see that they use non-trivial techniques/libraries to achieve superior performance. What would be REALLY interesting to see is breakdown of the performance by the years of experience of people that submitted working code examples. I have a feeling that a developer with one year of experience in Java, will probably beat developers with two years of experience in C/C++.
- igouy 7y agoDo you have an example of program performance measurements that do "capture the required knowledge by the developer" ? How can you tell that the knowledge was actually "required" rather than incidental ? Wouldn't it depend exactly what experience they gained in that one year and how relevant it was to the task at hand?
- igouy 7y ago> I believe there were faster than C versions that were rejected Believe but do not know? Shade?
- pkolaczk 7y agoOn par is an understatement. It beats C++ in 8 benchmarks and loses in 2. Quite impressive. Rust has more potential for better optimisation than C++ because the compiler has full information on pointer aliasing.
- igouy 7y agoAlways look at the source code (or even the CPU load). One of those C++ comparisons is currently multi-core vs sequential. Several C++ programs were recently removed, which upends things. You might say — "there were faster than [Rust] versions that were rejected".
- pkolaczk 7y agoOne is multicore, but the other 7 winning have the same parallelism. As for that one winning by parallelism - maybe it was just easier to provide a correct parallel solution in Rust than in C++? This game didn't appear there yesterday and C++ developers had much more time to play it. If that's the case, that benchmark still counts.
- igouy 7y agoMaybe it was just that I contacted the Rust programmer and suggested they might like to update their program :-) (The changes were in the last month or two.)
- damnyou 7y agoYou can expect it to be in the same ballpark as C or C++ for single-threaded code, especially if you use idiomatic Rust (combinators instead of manual iteration). Where Rust shines is that it often takes jaut a few minutes to turn a single-threaded program into a multithreaded program — and the type system guarantees that the program won't have data races.
- pornel 7y agoTechnically it's about the same speed, but idiomatic Rust programs are structured differently, which has its ups and downs. I wrote an overview of Rust's performance characteristics: https://kornel.ski/rust-c-speed https://kornel.ski/rust-c-speed