标签:ubunt lazy lang class time return include 理解 ast
话不多说,先贴图:
环境:
WSL Ubuntu 18.04LTS
sweepy@DESKTOP-M79ULPC:/mnt/c/Users/zljzl/desktop$ g++ file.cpp -o file.out
sweepy@DESKTOP-M79ULPC:/mnt/c/Users/zljzl/desktop$ vi ./file.cpp
sweepy@DESKTOP-M79ULPC:/mnt/c/Users/zljzl/desktop$ time ./file.out
real 0m0.063s
user 0m0.047s
sys 0m0.016s
sweepy@DESKTOP-M79ULPC:/mnt/c/Users/zljzl/desktop$ g++ file.cpp -o file.out -O2
sweepy@DESKTOP-M79ULPC:/mnt/c/Users/zljzl/desktop$ time ./file.out
real 0m0.013s
user 0m0.000s
sys 0m0.000s
sweepy@DESKTOP-M79ULPC:/mnt/c/Users/zljzl/desktop$ g++ file.cpp -o file.out -O3
sweepy@DESKTOP-M79ULPC:/mnt/c/Users/zljzl/desktop$ time ./file.out
real 0m0.016s
user 0m0.016s
sys 0m0.000s
sweepy@DESKTOP-M79ULPC:/mnt/c/Users/zljzl/desktop$ g++ file.cpp -o file.out -Ofast
sweepy@DESKTOP-M79ULPC:/mnt/c/Users/zljzl/desktop$ time ./file.out
real 0m0.012s
user 0m0.000s
sys 0m0.016s
源代码是这样的(计算1~10000000的平方和)
#include<iostream>
using namespace std;
int main(){
int ans=0;
for(int i=0;i<10000000;i++){
ans+=i*i;
}
return 0;
}
总而言之,\(O(fast)\)真的很快
标签:ubunt lazy lang class time return include 理解 ast
原文地址:https://www.cnblogs.com/sweepy/p/13360615.html