In another thread I started a discussion about Vectors and Arrays, in which I was largely playing devil\'s advocate, to push buttons. However, during the course of this, I
A simpler explanation: you're building with optimisations disabled. You want -O3
, not -o3
.
I don't have clang available to exactly reproduce your tests, but my results are as follows:
//Array run # 1
$ g++ -std=c++11 -O3 test.cpp -o b.out && time ./b.out
real 0m25.323s
user 0m25.162s
sys 0m0.148s
//Vector run #1
$ g++ -std=c++11 -O3 test.cpp -o b.out && time ./b.out
real 0m25.634s
user 0m25.486s
sys 0m0.136s