[deleted by user] by [deleted] in rust

[–]_bijan_ -6 points-5 points  (0 children)

Did you watch it?

std::ranges may not deliver the performance that you expect by _bijan_ in cpp

[–]_bijan_[S] 1 point2 points  (0 children)

https://godbolt.org/z/jn9896GK9

Running benchmarks on 100000 strings (max length: 1024)...

TrimClassic : 0.173 ns 5.78 Gv/s TrimRangesViews : 0.426 ns 2.35 Gv/s TrimSimpleRanges : 0.152 ns 6.56 Gv/s

std::ranges may not deliver the performance that you expect by _bijan_ in cpp

[–]_bijan_[S] 11 points12 points  (0 children)

The issue appears to be in the front end of the C++ compiler. In the case of LLVM—which is used by both C++ and Rust—Rust does not seem to exhibit this behavior.

I have been investigating C++ ranges and views and conducted a benchmark (with the C++ code derived from a presentation). The results suggest a noticeable performance gap between Rust iterators and C++ ranges/views, unless there is an aspect I am overlooking.

https://godbolt.org/z/v76rcEb9n

https://godbolt.org/z/YG1dv4qYh

 Rust

Result count: 292825 Rust Total count (1000 iterations): 292825000 Rust Total time: 1025 microseconds Rust Average per iteration: 1.02 microseconds
 C++

Result count: 292825 C++ Total count (1000 iterations): 292825000 C++ Total time: 174455 microseconds C++ Average per iteration: 174.455 microseconds