g++ --std=c++11 solve.cpp -o puzzle real 0m19,68s user 0m19,05s sys 0m0,60s g++ --std=c++11 -O1 solve.cpp -o puzzle real 0m3,52s user 0m2,39s sys 0m1,13s g++ --std=c++11 -O2 solve.cpp -o puzzle real 0m3,13s user 0m2,01s sys 0m1,14s g++ --std=c++11 -O3 solve.cpp -o puzzle real 0m2,08s user 0m0,90s sys 0m1,20s g++ --std=c++11 -O3 -fprofile-use solve.cpp -o puzzle real 0m2,02s user 0m0,94s sys 0m1,11s clang++ --std=c++11 solve.cpp -o puzzle real 0m18,57s user 0m18,01s sys 0m0,55s clang++ --std=c++11 -O1 solve.cpp -o puzzle real 0m8,59s user 0m8,11s sys 0m0,47s clang++ --std=c++11 -O2 solve.cpp -o puzzle real 0m2,14s user 0m1,00s sys 0m1,15s clang++ --std=c++11 -O3 solve.cpp -o puzzle real 0m2,11s user 0m0,96s sys 0m1,16s ===================================================== created with: #!/bin/ksh93 times=1000 function bench { echo "$1" $1 time for i in {1..$times}; do; ./puzzle 1>/dev/null; done } bench "g++ --std=c++11 solve.cpp -o puzzle" #bench "g++ --std=c++11 -O0 solve.cpp -o puzzle" bench "g++ --std=c++11 -O1 solve.cpp -o puzzle" bench "g++ --std=c++11 -O2 solve.cpp -o puzzle" bench "g++ --std=c++11 -O3 solve.cpp -o puzzle" g++ --std=c++11 -O3 -fprofile-generate solve.cpp -o puzzle ./puzzle 1>/dev/null bench "g++ --std=c++11 -O3 -fprofile-use solve.cpp -o puzzle" bench "clang++ --std=c++11 solve.cpp -o puzzle" bench "clang++ --std=c++11 -O1 solve.cpp -o puzzle" bench "clang++ --std=c++11 -O2 solve.cpp -o puzzle" bench "clang++ --std=c++11 -O3 solve.cpp -o puzzle" #bench "clang++ --std=c++11 -O4 solve.cpp -o puzzle" #/usr/bin/ld: /usr/bin/../lib/LLVMgold.so: error loading plugin: /usr/bin/../lib/LLVMgold.so: cannot open shared object file: No such file or directory #clang: error: linker command failed with exit code 1 (use -v to see invocation) ===================================================== compilers: trigen@Firefly21:/home/trigen> g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.8.1-10ubuntu9' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.8.1 (Ubuntu/Linaro 4.8.1-10ubuntu9) trigen@Firefly21:/home/trigen> clang++ -v Ubuntu clang version 3.4-1ubuntu1 (trunk) (based on LLVM 3.4) Target: x86_64-pc-linux-gnu Thread model: posix trigen@Firefly21:/home/trigen>