|
|

楼主 |
发表于 2008-2-25 14:30:34
|
显示全部楼层
实际测试了一下
分别用
1. -Wall -O2 -march=pentium-m -pipe -fomit-frame-pointer -msse2 -mmmx -mfpmath=sse
2. -Wall -O3 -march=pentium-m -pipe -fomit-frame-pointer -msse2 -mmmx -mfpmath=sse
3. -march=native -O2 -pipe -fomit-frame-pointer
4. -march=native -O3 -pipe -fomit-frame-pointer
发现1 > 2 > 4 > 3
以下是
- [feng@enlightenment tmp]$ g++ -c ran.cc -Wall -O2 -march=pentium-m -pipe -fomit-frame-pointer -msse2 -mmmx -mfpmath=sse
- [feng@enlightenment tmp]$ g++ -c test.cc -Wall -O2 -march=pentium-m -pipe -fomit-frame-pointer -msse2 -mmmx -mfpmath=sse
- [feng@enlightenment tmp]$ g++ -o test -Wall -O2 -march=pentium-m -pipe -fomit-frame-pointer -msse2 -mmmx -mfpmath=sse test.o ran.o
- [feng@enlightenment tmp]$ ./test
- It costs 9.76 second(s) to generate 100000000 random numbers.
- Sum of them is 4.99976e+07
- [feng@enlightenment tmp]$ g++ -c -Wall -O3 -march=pentium-m -pipe -fomit-frame-pointer -msse2 -mmmx -mfpmath=sse ran.cc
- [feng@enlightenment tmp]$ g++ -c -Wall -O3 -march=pentium-m -pipe -fomit-frame-pointer -msse2 -mmmx -mfpmath=sse test.cc
- [feng@enlightenment tmp]$ g++ -o test -Wall -O3 -march=pentium-m -pipe -fomit-frame-pointer -msse2 -mmmx -mfpmath=sse test.o ran.o
- [feng@enlightenment tmp]$ ./test
- It costs 9.82 second(s) to generate 100000000 random numbers.
- Sum of them is 4.99989e+07
- [feng@enlightenment tmp]$ g++ -c -march=native -O2 -pipe -fomit-frame-pointer ran.cc
- [feng@enlightenment tmp]$ g++ -c -march=native -O2 -pipe -fomit-frame-pointer test.cc
- [feng@enlightenment tmp]$ g++ -o test -march=native -O2 -pipe -fomit-frame-pointer test.o ran.o
- [feng@enlightenment tmp]$ ./test
- It costs 9.98 second(s) to generate 100000000 random numbers.
- Sum of them is 4.99979e+07
- [feng@enlightenment tmp]$ g++ -c -march=native -O3 -pipe -fomit-frame-pointer ran.cc
- [feng@enlightenment tmp]$ g++ -c -march=native -O3 -pipe -fomit-frame-pointer test.cc
- [feng@enlightenment tmp]$ g++ -o test -march=native -O3 -pipe -fomit-frame-pointer test.o ran.o
- [feng@enlightenment tmp]$ ./test
- It costs 9.96 second(s) to generate 100000000 random numbers.
- Sum of them is 4.99988e+07
复制代码 |
|