Skip to content

Latest commit

 

History

History
56 lines (40 loc) · 796 Bytes

README.md

File metadata and controls

56 lines (40 loc) · 796 Bytes

timer_util::timer

A C++ utility for recording and formatting time point data.

Usage

To use in project just include the header file timer.hpp.

To record a time point:

timer_util::timer timer;
timer.add_tag("tag name");

To get a formated string:

std::cout << timer.to_string();

Example

#include <iostream> // std::cout
#ifdef _WIN32
#include <Windows.h> // sleep
#else
#include <unistd.h> // sleep
#endif

#include "timer.hpp"

int main()
{
    timer_util::timer timer;

    timer.add_tag("tag 1");
    sleep(2);
    timer.add_tag("tag 2");
    sleep(1);
    timer.add_tag("tag 3");

    std::cout << timer.to_string();

    return 0;
}

Which will print something similar to:

tag 1: 0.000000ms
tag 2: 2000.100213ms
tag 3: 1000.100112ms