Guest User

Untitled

a guest
Feb 3rd, 2015
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.21 KB | None | 0 0
  1.     double timeSpent = 0;
  2.     Vector<CString> speedV = {"3", "1", "2", "1", "2", "1", "2", "2", "1", "1", "1", "3", "3", "1", "2", "1", "2", "1", "2", "2", "1", "1", "1", "3", "3", "1", "2", "1", "2", "1", "2", "2", "1", "1", "1", "3", "3", "1", "2", "1", "2", "1", "2", "2", "1", "1", "1", "3", "3", "1", "2", "1", "2", "1", "2", "2", "1", "1", "1", "3", "3", "1", "2", "1", "2", "1", "2", "2", "1", "1", "1", "3"};
  3.     static const unsigned tries = 1000000;
  4.     for (unsigned i = 0; i < tries; ++i) {
  5.         Vector<CString> testV = speedV;
  6.         double before = monotonicallyIncreasingTime();
  7.         testV.removeAll("1");
  8.         timeSpent += (monotonicallyIncreasingTime() - before);
  9.     }
  10.     fprintf(stderr, "RemoveAll: %g ms\n", timeSpent * 1000.);
  11.  
  12.  
  13.     timeSpent = 0;
  14.     for (unsigned i = 0; i < tries; ++i) {
  15.         Vector<CString> testV = speedV;
  16.         double before = monotonicallyIncreasingTime();
  17.         for (size_t i = 0; i < testV.size(); ++i) {
  18.             if (testV[i] == "1") {
  19.                 testV.remove(i);
  20.                 --i;
  21.             }
  22.         }
  23.         timeSpent += (monotonicallyIncreasingTime() - before);
  24.     }
  25.     fprintf(stderr, "Manual: %g ms\n", timeSpent * 1000.);
Advertisement
Add Comment
Please, Sign In to add comment