// // compiled with: // g++ test.cc -o test -O3 -mfpmath=387 -march=k8 -m64 // time ./test // 5.23449e+09, 8.72415e+09, 1.30862e+10 // // real 0m5.908s // user 0m5.872s // sys 0m0.028s // // // g++ test.cc -o test -O3 -mfpmath=sse -msse -msse2 -march=k8 -m64 // time ./test // 5.23449e+09, 8.72415e+09, 1.30862e+10 // // real 0m5.951s // user 0m5.888s // sys 0m0.024s #include template struct Vector { Vector(float_t _x, float_t _y, float_t _z) : x(_x), y(_y), z(_z) {} float_t x, y, z; Vector operator*(const float_t f) { return Vector(x*f, y*f, z*f); } Vector& operator+=(const Vector& v) { x += v.x; y += v.y; z += v.z; return *this; } }; typedef Vector vec3; int main(int argc, char** argv) { vec3 v1(1.2, 2.0, 3.0); vec3 v2(2.0, 2.0, 1.4); double a = 4.0f; for( int i = 0; i < 0x40FFFFFF; ++i ) { v2 += v1 * a; } std::cout << v2.x << ", " << v2.y << ", " << v2.z << std::endl; return 0; }