by panic · 9y ago · 0 comments
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
Never trust a benchmark you didn't falsify yourself.
printf("x[0][0]=%f\n", x[0][0]);
at the end of main fixes this.Benchmarking is hard.