fork download
  1. #include <iostream>
  2. #include <map>
  3.  
  4. #include <time.h>
  5.  
  6. int main ()
  7. {
  8. std::map<int, int> foo;
  9. int i;
  10.  
  11. for (i = 0; i < 1000000; ++i) {
  12. foo[i] = i;
  13. }
  14.  
  15. clock_t start = clock();
  16. for (i = 0; i < 1000000; ++i) {
  17. std::map<int, int>::iterator j = foo.find(-1);
  18. }
  19. clock_t finish = clock();
  20. double secs = (finish - start)/(double)CLOCKS_PER_SEC;
  21. std::cout << " total: " << secs << std::endl;
  22. std::cout << "per call: " << secs/1000000 << std::endl;
  23. }
Success #stdin #stdout 0.6s 34184KB
stdin
Standard input is empty
stdout
   total: 0.15
per call: 1.5e-07