#include unsigned t0, t1; t0=clock() // Code to execute t1 = clock(); double time = (double(t1-t0)/CLOCKS_PER_SEC); cout << "Execution Time: " << time << endl;
Here is what the above code is Doing:
1. We include the
2. We declare two unsigned integer variables, t0 and t1.
3. We assign the value of the clock() function to t0.
4. We execute the code we want to time.
5. We assign the value of the clock() function to t1.
6. We calculate the difference between t1 and t0 and divide it by the CLOCKS_PER_SEC constant.
7. We print the result to the console.