3 ms·
For me, clang -O3 optimizes the main function into this single loop: LBB3_1: addsd %xmm1, %xmm0 addsd %xmm1, %xmm0 ucomisd %xmm0, %
by panic 10y ago
For me, clang -O3 optimizes the main function into this single loop:
LBB3_1:
addsd %xmm1, %xmm0
addsd %xmm1, %xmm0
ucomisd %xmm0, %xmm2
jae LBB3_1
%xmm0 begins at 0, %xmm1 is 0.04, and %xmm2 is 3.6525E+8.
In other words, it's measuring how long it takes to count to 3.6525E+8 by adding 0.04 repeatedly. LLVM (which both Rust and clang use as a backend) optimizes away the actual work of the program.
GCC doesn't seem to optimize things out as aggressively, so that probably explains the difference: https://godbolt.org/g/lBRIIW https://godbolt.org/g/lBRIIW
- gpderetta 10y agoI.e the program has no side effects so it can be completely optimized away. Never trust a benchmark you didn't falsify yourself.
- michaf 10y agogcc seems to do something similar for -Ofast. Adding something like printf("x[0][0]=%f\n", x[0][0]); at the end of main fixes this. Benchmarking is hard.