fork(2) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. vector<int> a;
  6. list<int> b;
  7. for(int i(0); i < 1000; ++i) {
  8. a.push_back(i);
  9. b.push_back(i);
  10. }
  11.  
  12. auto beginV = chrono::high_resolution_clock::now();
  13. a.erase(find(a.begin(), a.end(), 500));
  14. auto endV = chrono::high_resolution_clock::now();
  15.  
  16. auto beginL = chrono::high_resolution_clock::now();
  17. b.erase(find(b.begin(), b.end(), 500));
  18. auto endL = chrono::high_resolution_clock::now();
  19.  
  20. cout << "Viktors " << chrono::duration_cast<chrono::nanoseconds>(endV-beginV).count() << "ns" << endl;
  21. cout << "Lists " << chrono::duration_cast<chrono::nanoseconds>(endL-beginL).count() << "ns" << endl;
  22. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
Viktors 369ns
Lists 1229ns