Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Comparing the performance of Rust and C, is this a problem with the compilation process?

While looking for data comparing Rust and C, I went to the benchmarkgame site and tried it myself, and it turned out different from the specified results.(rust vs c clang)

https://benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/rust-clang.html

Each source code is as follows, and it was executed through the compile command shown at the bottom of the source code.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

The stated result table of "rust vs clang"

However, Rust ran the cargo in the nightly version.

Below is the result of the compiled result measured by time on my pc.

rust vs c clang time checking

The reason for this result is that I compile incorrectly? Or is it normal for these results to come out in the first place?

I am using intel i7 10700k, 16gb ram.

>Solution :

The screenshot shows that Rust is being compiled in debug mode, which will make for a poor benchmark. Use --release to build it with full optimizations.

time cargo run --release 21

Better yet, use the same build command they did in case the other options are important:

/opt/src/rust-1.55.0/bin/rustc -C opt-level=3 -C target-cpu=ivybridge --C codegen-units=1 -L /opt/src/rust-libs binarytrees.rs -o binarytrees.rust-5.rust_run
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading