Class LoggingTimer

Inheritance Relationships

Base Type

Class Documentation

class LoggingTimer : public Aux::Timer

A timer for running time measurements within a scope.

Same as Timer but automatically starts on construction and report on destruction.

{
   Aux::ScopedTimer("Algorithm A"); // WRONG; will directly report without measuring the scope
   Aux::ScopedTimer someName("Algorithm B"); // OK: the named instance is valid until the end of
the scope
   // some expensive operations


} // <- Report time since creation of the timer object via Aux::Log

Warning

As the timer exploits RAII, it requires a named instance to extend its life time until the end of the current scope. In the example above “someName” is used. If the time measured seems too short, make you created a named instances.

Public Functions

explicit LoggingTimer(std::string_view label = "", Aux::Log::LogLevel level = Aux::Log::LogLevel::DEBUG)
Parameters:
  • label – The label printed out next to the measurement

  • level – Only measure if logging at the provided LogLevel is enabled during runtime. If logging at the given level is disable the Timer is very cheap to construct. If logging is disabled during construction or destruction, no message is shown.

~LoggingTimer()