libsemigroups  v3.0.0
C++ library for semigroups and monoids
Loading...
Searching...
No Matches

Defined in runner.hpp.

This class exists to collect some values related to reporting in its derived classes. These values are:

Inheritance diagram for Reporter:
[legend]

Public Types

using nanoseconds = std::chrono::nanoseconds
 Alias for std::chrono::nanoseconds.
 
using time_point = std::chrono::high_resolution_clock::time_point
 Alias for std::chrono::high_resolution_clock::time_point.
 

Public Member Functions

 Reporter ()
 Default constructor.
 
 Reporter (Reporter &&that)
 Default move constructor.
 
 Reporter (Reporter const &that)
 Default copy constructor.
 
void emit_divider ()
 
Reporterinit ()
 Initialize an existing Reporter object.
 
time_point last_report () const noexcept
 Get the time point of the last report.
 
Reporteroperator= (Reporter &&that)
 Default move assignment operator.
 
Reporteroperator= (Reporter const &that)
 Default copy assignment operator.
 
bool report () const
 Check if it is time to report.
 
std::string const & report_divider () const noexcept
 
Reporterreport_divider (std::string const &val)
 
nanoseconds report_every () const noexcept
 Get the minimum elapsed time between reports.
 
Reporterreport_every (nanoseconds val) noexcept
 Set the minimum elapsed time between reports in nanoseconds.
 
template<typename Time>
Reporterreport_every (Time t) noexcept
 Set the minimum elapsed time between reports in a unit of time other than nanoseconds.
 
std::string const & report_prefix () const noexcept
 Get the current prefix string for reporting.
 
Reporterreport_prefix (std::string const &val)
 Set the prefix string for reporting.
 
Reporter const & reset_last_report () const
 Set the last report time point to now.
 
Reporter const & reset_start_time () const
 Reset the start time (and last report) to now.
 
time_point start_time () const noexcept
 Get the start time.
 

Related Symbols

(Note that these are not member symbols.)

static std::chrono::nanoseconds delta (std::chrono::high_resolution_clock::time_point const &t)
 The time between a given point and now.
 

Constructor & Destructor Documentation

◆ Reporter()

Reporter ( )

Default construct a Reporter object such that the following hold:

Member Function Documentation

◆ init()

Reporter & init ( )

This function puts a Reporter object back into the same state as if it had been newly default constructed.

Returns
A reference to *this.
Note
This function is not thread-safe.
See also
Reporter()

◆ last_report()

time_point last_report ( ) const
inlinenodiscardnoexcept

Returns the time point of the last report, as set by one of:

Returns
A time_point.
Exceptions
This function is noexcept and is guaranteed never to throw.
Note
This function is thread-safe.

◆ report()

bool report ( ) const
nodiscard

This function can be used to check if enough time has passed that we should report again. That is if the time between last_report() and now is greater than the value of report_every().

If true is returned, then last_report() is set to now.

Returns
A value of type bool.
Note
This function is thread-safe.
Warning
This function can be somewhat expensive, and so you should avoid invoking it too often.
See also
report_every(std::chrono::nanoseconds) and report_every(Time).

◆ report_every() [1/3]

nanoseconds report_every ( ) const
inlinenodiscardnoexcept
Returns
The number of nanoseconds between reports.
Exceptions
This function is noexcept and is guaranteed never to throw.
Note
This function is thread-safe.

◆ report_every() [2/3]

Reporter & report_every ( nanoseconds val)
inlinenoexcept

This function can be used to specify at run time the minimum elapsed time between two calls to report() that will return true. If report() returns true at time s, then report() will only return true again after at least time s + t has elapsed.

Parameters
valthe amount of time (in nanoseconds) between reports.
Returns
A reference to this.
Exceptions
This function is noexcept and is guaranteed never to throw.
Note
This function is not thread-safe.
See also
report_every(Time)

◆ report_every() [3/3]

template<typename Time>
Reporter & report_every ( Time t)
inlinenoexcept

This function converts its argument to std::chrono::nanoseconds and calls report_every(std::chrono::nanoseconds).

Template Parameters
Timethe type of the argument (should be std::chrono::something).
Parameters
tthe amount of time (in Time) between reports.
Returns
A reference to this.
Exceptions
This function is noexcept and is guaranteed never to throw.
Note
This function is not thread-safe.

◆ report_prefix() [1/2]

std::string const & report_prefix ( ) const
inlinenodiscardnoexcept

This function gets the current value of the prefix string for reporting (set via report_prefix(std::string const&)), which is typically the name of the algorithm being run at the outmost level.

Returns
A const reference to the prefix string.
Exceptions
This function is noexcept and is guaranteed never to throw.
Note
This function is thread-safe.

◆ report_prefix() [2/2]

Reporter & report_prefix ( std::string const & val)
inline

This function sets the return value of report_prefix() to (a copy of) the argument val. Typically this prefix should be the name of the algorithm being run at the outmost level.

Parameters
valthe new value of the report prefix.
Returns
A reference to this.
Note
This function is not thread-safe.

◆ reset_last_report()

Reporter const & reset_last_report ( ) const
inline

Returns the time point of the last report, as set by one of:

Returns
A const reference to this.
Note
This function is thread-safe.

◆ reset_start_time()

Reporter const & reset_start_time ( ) const
inline
Returns
A const reference to this.
Note
This function is not thread-safe.

◆ start_time()

time_point start_time ( ) const
inlinenodiscardnoexcept

This is the time point at which reset_start_time() was last called, which is also the time of construction of a Reporter instance if reset_start_time() is not explicitly called.

Returns
The time point representing the start time.
Exceptions
This function is noexcept and is guaranteed never to throw.
Note
This function is thread-safe.

Friends And Related Symbol Documentation

◆ delta()

static std::chrono::nanoseconds delta ( std::chrono::high_resolution_clock::time_point const & t)
related

The time between a given point and now.

Parameters
tthe time point.
Returns
The nanoseconds between the time point t and now.

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