Guest User

Untitled

a guest
Apr 18th, 2016
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #pragma GCC optimize "-O3"
  2.  
  3. #include <iostream>
  4. #include <vector>
  5. #include <chrono>
  6.  
  7. using namespace std;
  8. using namespace std::chrono;
  9.  
  10. int main() {
  11.     high_resolution_clock::time_point roundStart = high_resolution_clock::now();
  12.  
  13.     int vec[1000000];
  14.  
  15.     for (int i = 0; i < 1000000; ++i) {
  16.         vec[i] = i + 1;
  17.     }
  18.  
  19.     for (int i = 0; i < 1000000; ++i) {
  20.         int a = vec[i];
  21.     }
  22.  
  23.     high_resolution_clock::time_point end = high_resolution_clock::now();
  24.     duration<double> time_span = duration_cast<duration<double>>(end - roundStart);
  25.  
  26.     cout << (time_span.count() * 1000) << "ms" << endl;
  27. }
Add Comment
Please, Sign In to add comment