测一下变量申请的速度

下面是测试用的代码:

 1 #include <bits/stdc++.h>
 2 
 3 using namespace std;
 4 
 5 int main(){
 6     cout<<"(Type)"<<endl;
 7     for(int i=1;i<=5e7;i++){
 8         (Type) a;
 9     }
10 }

 结果:

int
-----------------------------------------
Runing Time:    104.599ms
-----------------------------------------
long long
-----------------------------------------
Runing Time:    104.540ms
-----------------------------------------
vector<int>
-----------------------------------------
Runing Time:   1749.897ms
-----------------------------------------
deque<int>
-----------------------------------------
Runing Time:  14822.420ms
-----------------------------------------
queue<int>
-----------------------------------------
Runing Time:  38413.759ms
-----------------------------------------
map<int,int>
-----------------------------------------
Runing Time:   1571.477ms
-----------------------------------------
set<int>
-----------------------------------------
Runing Time:   1570.402ms
-----------------------------------------
list<int>
-----------------------------------------
Runing Time:   1482.101ms
-----------------------------------------

猜你喜欢

转载自www.cnblogs.com/marmot-cage/p/11391168.html