Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ctime>
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <stack>
- #include <map>
- #include "boost/container/flat_map.hpp"
- using namespace std;
- namespace {
- template <class S> void time_copy_test(size_t np, const S& s)
- {
- const clock_t start = clock();
- for(size_t i=0;i<np;++i)
- S temp = s;
- cout << static_cast<double>(clock()-start)/CLOCKS_PER_SEC << endl;
- }
- }
- int main(void)
- {
- const size_t np = 100000000;
- cout << "stl map: ";
- time_copy_test(np,std::map<size_t,double>());
- cout << "stl vector: ";
- time_copy_test(np,vector<double>());
- cout << "boost flat map: ";
- time_copy_test(np,boost::container::flat_map<size_t,double>());
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement