CLI11 2.2.0
Loading...
Searching...
No Matches
CLI::Timer Class Reference

This is a simple timer with pretty printing. Creating the timer starts counting. More...

#include <Timer.hpp>

Inheritance diagram for CLI::Timer:
Collaboration diagram for CLI::Timer:

Public Member Functions

 Timer (std::string title="Timer", time_print_t time_print=Simple)
 Standard constructor, can set title and print function.
 
std::string time_it (std::function< void()> f, double target_time=1)
 Time a function by running it multiple times. Target time is the len to target.
 
std::string make_time_str () const
 This formats the numerical value for the time string.
 
std::string make_time_str (double time) const
 This prints out a time string from a time.
 
std::string to_string () const
 This is the main function, it creates a string.
 
Timeroperator/ (std::size_t val)
 Division sets the number of cycles to divide by (no graphical change)
 

Static Public Member Functions

static std::string Simple (std::string title, std::string time)
 Standard print function, this one is set by default.
 
static std::string Big (std::string title, std::string time)
 This is a fancy print function with — headers.
 

Protected Types

using clock = std::chrono::steady_clock
 This is a typedef to make clocks easier to use.
 
using time_point = std::chrono::time_point<clock>
 This typedef is for points in time.
 
using time_print_t = std::function<std::string(std::string, std::string)>
 This is the type of a printing function, you can make your own.
 

Protected Attributes

std::string title_
 This is the title of the timer.
 
time_print_t time_print_
 This is the function that is used to format most of the timing message.
 
time_point start_
 This is the starting point (when the timer was created)
 
std::size_t cycles {1}
 This is the number of times cycles (print divides by this number)
 

Detailed Description

This is a simple timer with pretty printing. Creating the timer starts counting.

Member Typedef Documentation

◆ clock

using CLI::Timer::clock = std::chrono::steady_clock
protected

This is a typedef to make clocks easier to use.

◆ time_point

using CLI::Timer::time_point = std::chrono::time_point<clock>
protected

This typedef is for points in time.

◆ time_print_t

using CLI::Timer::time_print_t = std::function<std::string(std::string, std::string)>
protected

This is the type of a printing function, you can make your own.

Constructor & Destructor Documentation

◆ Timer()

CLI::Timer::Timer ( std::string title = "Timer",
time_print_t time_print = Simple )
inlineexplicit

Standard constructor, can set title and print function.

Member Function Documentation

◆ Big()

static std::string CLI::Timer::Big ( std::string title,
std::string time )
inlinestatic

This is a fancy print function with — headers.

◆ make_time_str() [1/2]

std::string CLI::Timer::make_time_str ( ) const
inline

This formats the numerical value for the time string.

◆ make_time_str() [2/2]

std::string CLI::Timer::make_time_str ( double time) const
inline

This prints out a time string from a time.

◆ operator/()

Timer & CLI::Timer::operator/ ( std::size_t val)
inline

Division sets the number of cycles to divide by (no graphical change)

◆ Simple()

static std::string CLI::Timer::Simple ( std::string title,
std::string time )
inlinestatic

Standard print function, this one is set by default.

◆ time_it()

std::string CLI::Timer::time_it ( std::function< void()> f,
double target_time = 1 )
inline

Time a function by running it multiple times. Target time is the len to target.

◆ to_string()

std::string CLI::Timer::to_string ( ) const
inline

This is the main function, it creates a string.

Member Data Documentation

◆ cycles

std::size_t CLI::Timer::cycles {1}
protected

This is the number of times cycles (print divides by this number)

◆ start_

time_point CLI::Timer::start_
protected

This is the starting point (when the timer was created)

◆ time_print_

time_print_t CLI::Timer::time_print_
protected

This is the function that is used to format most of the timing message.

◆ title_

std::string CLI::Timer::title_
protected

This is the title of the timer.


The documentation for this class was generated from the following file: