cli11
Loading...
Searching...
No Matches
cli::auto_timer_t Class Referenceexport
module cli11

A timer_t that reports to std::cout when it goes out of scope. More...

Inheritance diagram for cli::auto_timer_t:
cli::timer_t

Public Member Functions

 auto_timer_t (std::string title="Timer", time_print_t time_print=simple)
 Starts a timer that reports on destruction.
 auto_timer_t (const auto_timer_t &)=delete
 auto_timer_t (auto_timer_t &&)=delete
auto operator= (const auto_timer_t &) -> auto_timer_t &=delete
auto operator= (auto_timer_t &&) -> auto_timer_t &=delete
 ~auto_timer_t ()
 Writes the measurement to std::cout.
Public Member Functions inherited from cli::timer_t
 timer_t (std::string title="Timer", time_print_t time_print=simple)
 Starts a timer.
template<std::invocable F>
auto time_it (F &&f, double target_time=1.0) -> std::string
 Repeatedly invokes f until target_time has elapsed.
auto make_time_str () const -> std::string
 Formats the time elapsed since construction, divided by the cycle count.
auto make_time_str (double time) const -> std::string
 Formats a duration, choosing a unit that keeps the value readable.
auto to_string () const -> std::string
 Renders the measurement through the configured print callable.
auto operator/ (std::size_t val) -> timer_t &
 Sets the divisor applied to the measured interval.

Additional Inherited Members

Static Public Member Functions inherited from cli::timer_t
static auto simple (std::string title, std::string time) -> std::string
 Renders a measurement as "title: time".
static auto big (std::string title, std::string time) -> std::string
 Renders a measurement inside a full-width banner.
Protected Types inherited from cli::timer_t
using clock_t = std::chrono::steady_clock
 The clock used for all measurements.
using time_point_t = std::chrono::time_point<clock_t>
 A point in time as reported by clock_t.
using time_print_t = std::function<std::string(std::string, std::string)>
 Renders a finished measurement given a title and a formatted duration.
Protected Attributes inherited from cli::timer_t
std::string title_
 Label reported alongside the measurement.
time_print_t time_print_
 Callable used to render the finished measurement.
time_point_t start_
 The instant this timer started measuring.
std::size_t cycles_ {1}
 Number of cycles the measured interval is divided by.

Detailed Description

A timer_t that reports to std::cout when it goes out of scope.

Copying or moving one of these would report the same interval more than once, so both are deleted.

Constructor & Destructor Documentation

◆ auto_timer_t()

cli::auto_timer_t::auto_timer_t ( std::string title = "Timer",
time_print_t time_print = simple )
inlineexplicit

Starts a timer that reports on destruction.

Parameters
titleLabel reported alongside the measurement.
time_printCallable used to render the finished measurement.

The documentation for this class was generated from the following file:
  • /home/mccakit/desktop/repositories/cli11/src/timer.cpp