fork download
  1. #include <iostream>
  2. #include <ctime>
  3. #include <set>
  4. #include <tr1/unordered_set>
  5. #include <cstdlib>
  6.  
  7. int main()
  8. {
  9. std::set<int> a;
  10. std::tr1::unordered_set<int> b;
  11. clock_t c0 = clock();
  12. for (int i = 0; i < 20000000; i++)
  13. a.insert(rand() % 20);
  14. clock_t c1 = clock();
  15. for (int i = 0; i < 20000000; i++)
  16. b.insert(rand() % 20);
  17. clock_t c2 = clock();
  18. std::cout << "a/b = "
  19. << static_cast<double>(c1 - c0) / CLOCKS_PER_SEC
  20. << "/"
  21. << static_cast<double>(c2 - c1) / CLOCKS_PER_SEC
  22. << std::endl;
  23. return 0;
  24. }
Success #stdin #stdout 2.01s 2860KB
stdin
Standard input is empty
stdout
a/b = 1.21/0.79