2
我運行過程中出現在OS X 10.9.3的2.4 GHz英特爾酷睿i5,8 GB DDR3構建載體<int>大尺寸
a.cpp
int main() {
vector<int> expectation(10e8, -1.0);
cout << "size()=" << expectation.size() << endl;
return 0;
}
b.cpp
下面的代碼int main() {
vector<int> expectation(10e9, -1.0);
cout << "size()=" << expectation.size() << endl;
return 0;
}
-
$ time ./a.out
size()=1000000000
real 0m3.935s
user 0m1.530s
sys 0m2.103s
$ time ./b.out
size()=10000000000
real 4m49.853s
user 0m16.186s
sys 0m22.966s
在b.pp中,我們有10倍大的向量。
我想知道,爲什麼b案例變得比案件大約100倍大a?
UPD
我發現了,我在哪裏丟了!
10E8 = 10^9個整數= 4 GB
10E9 = 10^10個整數= 40 GB
沒有。對於10^8 int,我們需要400MB和10^9 - 4GB – Temak 2014-10-03 13:29:23
@Enor:請參見最後一句。你的測試是10^9和10^10的整數。 – 2014-10-03 13:31:28