#include#include #include "Stopwatch.h" int main() { Stopwatch stop; // Code to measure for (int i = 0; i < 10000000; ++i); std::cout << "Elapsed time: " << stop.elapsed() << " ms\n"; return 0; }
#includeIn this example, the user measures the time it takes to execute two different sections of code. The reset() function is called to clear the stopwatch between runs. The Stopwatch library is not a standard library in C++. It is likely a third-party library that needs to be installed and included in the project.#include #include "Stopwatch.h" int main() { Stopwatch stop; // Code to measure for (int i = 0; i < 10000000; ++i); // Measure again std::cout << "First run: " << stop.elapsed() << " ms\n"; stop.reset(); for (int i = 0; i < 20000000; ++i); std::cout << "Second run: " << stop.elapsed() << " ms\n"; return 0; }