Advertisement
Guest User

Untitled

a guest
Dec 13th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <iostream>
  2. #include <chrono>  // for high_resolution_clock
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     // Record start time
  8.     int b = 1;
  9.     string a = "1";
  10.     auto start = chrono::high_resolution_clock::now();
  11.    
  12.     // Portion of code to be timed
  13.     for(int i = 0; i < 100000000; i++) {
  14.         if(!(a == "hello")) b++;
  15.     }
  16.  
  17.     // Record end time
  18.     auto finish = chrono::high_resolution_clock::now();
  19.  
  20.     chrono::duration<double> elapsed = finish - start;
  21.     cout << "Elapsed time: " << elapsed.count() << " s\n";
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement