MTH4300 Home

Class SimpleTimer

The following code should be placed in a file SimpleTimer.cpp. The file should be in the same folder as the source file containing main function. The class SimpleTimer can be used if the directive #include "SimpleTimer.cpp" is placed in the source just below #include<iostream>.

This is how the class can be used to test the speed of a function or a block of code:

SimpleTimer tm;
//Block of code 
//whose speed we want to test
std::cout << "The time it took to execute the block is: ";
std::cout << tm.getTime() << "\n";