Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <list>
- #include <vector>
- #include <iostream>
- #include <chrono>
- #include <cstdlib>
- #include <cmath>
- using namespace std;
- using namespace std::chrono;
- int main(int argc, char **argv)
- {
- size_t N = pow(10, atoi(argv[1]));
- cout << " size: " << N << endl;
- {
- vector<int> v;
- auto start = high_resolution_clock::now();
- for(size_t i = 0; i < N; i++)
- v.push_back(42);
- auto end = high_resolution_clock::now();
- cout << "vector: " << duration_cast<microseconds>(end - start).count() << " us" << endl;
- }
- {
- list<int> l;
- auto start = high_resolution_clock::now();
- for(size_t i = 0; i < N; i++)
- l.push_back(42);
- auto end = high_resolution_clock::now();
- cout << " list: " << duration_cast<microseconds>(end - start).count() << " us" << endl;
- }
- cout << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement