Skip to content

Latest commit

 

History

History
61 lines (45 loc) · 1.2 KB

File metadata and controls

61 lines (45 loc) · 1.2 KB

Scoped Timers

CI

A simple C++ library providing RAII-style scoped timers for performance measurement.

Usage

#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();
}

Building

mkdir build
cd build
cmake ..
cmake --build .

Testing

Tests are built using Catch2 and can be run with:

cd build
ctest --output-on-failure

License

MIT