Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <chrono> // for high_resolution_clock
- using namespace std;
- int main()
- {
- // Record start time
- int b = 1;
- string a = "1";
- auto start = chrono::high_resolution_clock::now();
- // Portion of code to be timed
- for(int i = 0; i < 100000000; i++) {
- if(!(a == "hello")) b++;
- }
- // Record end time
- auto finish = chrono::high_resolution_clock::now();
- chrono::duration<double> elapsed = finish - start;
- cout << "Elapsed time: " << elapsed.count() << " s\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement