A simple C++ library providing RAII-style scoped timers for performance measurement.
#include "scoped_timers/scoped_timers.hpp"
#include "scoped_timers/utils.hpp" // For printing utility functions
#include <chrono>
#include <iostream>
#include <thread>
int main()
{
for (int i = 0; i < 300; ++i) {
{
ScopedTimers::Timer timer("Timers/First");
std::this_thread::sleep_for(std::chrono::duration<double>(0.00723));
}
{
ScopedTimers::Timer timer("Timers/Second");
std::this_thread::sleep_for(std::chrono::duration<double>(0.00234));
}
{
ScopedTimers::Timer timer("Timers/Third");
std::this_thread::sleep_for(std::chrono::duration<double>(0.000345));
}
}
// Print timer statistics
std::cout << ScopedTimers::Registry::getTimingTable();
}mkdir build
cd build
cmake ..
cmake --build .Tests are built using Catch2 and can be run with:
cd build
ctest --output-on-failureMIT