Tested on my Macbook Air (OS X 10.10, 1.7GHz i5, g++, -O3):
average of 100 runs :
each push_back() 1,000,000 times,
then pop_back() 1,000,000 times,
item size 64-bit.
deque performance : 95 ms
vector performance : 50 ms
cout << "scheduler TB" << endl;
Event e;
deque<Event> eb;
//vector<Event> eb;
cout << "size = " << eb.size() << endl;
for (j=0; j<100; j++) {
gettimeofday(&t0, NULL);
for (i=0; i<1000000; i++)
eb.push_back(e);
for (i=0; i<1000000; i++) {
e = eb.back();
eb.pop_back();
}
gettimeofday(&t1, NULL);
t_d += (t1.tv_sec - t0.tv_sec) * 1000000 + (t1.tv_usec - t0.tv_usec);
}
cout << "size = " << eb.size() << endl;
cout << "INFO: TB finished in " << t_d/100 << " us" << endl;
eb.clear();
No comments:
Post a Comment