Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double timeSpent = 0;
- 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"};
- static const unsigned tries = 1000000;
- for (unsigned i = 0; i < tries; ++i) {
- Vector<CString> testV = speedV;
- double before = monotonicallyIncreasingTime();
- testV.removeAll("1");
- timeSpent += (monotonicallyIncreasingTime() - before);
- }
- fprintf(stderr, "RemoveAll: %g ms\n", timeSpent * 1000.);
- timeSpent = 0;
- for (unsigned i = 0; i < tries; ++i) {
- Vector<CString> testV = speedV;
- double before = monotonicallyIncreasingTime();
- for (size_t i = 0; i < testV.size(); ++i) {
- if (testV[i] == "1") {
- testV.remove(i);
- --i;
- }
- }
- timeSpent += (monotonicallyIncreasingTime() - before);
- }
- fprintf(stderr, "Manual: %g ms\n", timeSpent * 1000.);
Advertisement
Add Comment
Please, Sign In to add comment