Are there any compilation time benchmarks of Rust vs. G++ vs. Clang++?

Looks like if I want a benchmark, I have to do it myself :wink: Luckily I have a peculiar hobby of writing a ray tracer in any language I learn.

So

cppraytracer
rustraytracer

I believe that at this point both programs are pretty similar: 1200 lines of code, same features, same run time no external dependencies.

-> % rustc --version
rustc 1.8.0-nightly (fae516277 2016-02-13)

-> % clang++ --version                                            
Ubuntu clang version 3.6.2-1 (tags/RELEASE_362/final) (based on LLVM 3.6.2)
Target: x86_64-pc-linux-gnu
Thread model: posix

Full dev build

-> % time cargo build
   Compiling rustraytracer v0.1.0 (file:///home/user/trash/rustraytracer)
cargo build
2.91s user 0.15s system 99% cpu 3.065 total

-> % time clang++ -std=c++14 -O0 -g -Wall -Wextra **/*.cpp -I ./src -o ray
clang++ -std=c++14 -O0 -g -Wall -Wextra **/*.cpp -I ./src -o ray
8.48s user 0.48s system 97% cpu 9.187 total

Full release build

-> % time cargo build --release
   Compiling rustraytracer v0.1.0 (file:///home/user/trash/rustraytracer)
cargo build --release
5.97s user 0.15s system 99% cpu 6.128 total


-> % time clang++ -std=c++14 -O3 -flto -Wall -Wextra **/*.cpp -I ./src -o ray -B /usr/lib/gold-ld
clang++ -std=c++14 -O3 -flto -Wall -Wextra **/*.cpp -I ./src -o ray -B
9.79s user 0.28s system 97% cpu 10.283 total

UPDATE: see the latter post about the impact of -flto on compile time.

Runtime :slight_smile:

-> % time ./target/release/rustraytracer
./target/release/rustraytracer
10.50s user 0.01s system 100% cpu 10.514 total

-> % time ./ray > out.ppm
time: 13
./ray > out.ppm
12.36s user 0.01s system 99% cpu 12.377 total

Teapots :slight_smile:

9 Likes