RSTools 3.1.0
Versatile C++20 utility library
Loading...
Searching...
No Matches
RST::Log::ScopedTimer Class Reference

Logs the time spent in a scope when destroyed, usually through RST_LOG_SCOPE_TIME(). More...

#include <RST/log/ScopedTimer.hpp>

Public Types

using Clock = std::chrono::steady_clock
 
using Duration = std::chrono::milliseconds
 

Public Member Functions

 ScopedTimer (std::string name, std::shared_ptr< Logger > logger=nullptr, Duration warnThreshold=Duration(-1), LogLevel level=LogLevel::Debug, SourceLocation source={})
 Starts timing; logger defaults to the default logger and a negative warnThreshold disables the warning.
 
 ~ScopedTimer ()
 
 ScopedTimer (const ScopedTimer &)=delete
 
ScopedTimer & operator= (const ScopedTimer &)=delete
 
Duration elapsed () const
 

Detailed Description

Logs the time spent in a scope when destroyed, usually through RST_LOG_SCOPE_TIME().

The time is logged at level, or as a [SLOW] warning once warnThreshold is reached.

Member Typedef Documentation

◆ Clock

using RST::Log::ScopedTimer::Clock = std::chrono::steady_clock

◆ Duration

using RST::Log::ScopedTimer::Duration = std::chrono::milliseconds

Constructor & Destructor Documentation

◆ ScopedTimer() [1/2]

RST::Log::ScopedTimer::ScopedTimer ( std::string  name,
std::shared_ptr< Logger >  logger = nullptr,
Duration  warnThreshold = Duration(-1),
LogLevel  level = LogLevel::Debug,
SourceLocation  source = {} 
)
inline

Starts timing; logger defaults to the default logger and a negative warnThreshold disables the warning.

◆ ~ScopedTimer()

RST::Log::ScopedTimer::~ScopedTimer ( )
inline

◆ ScopedTimer() [2/2]

RST::Log::ScopedTimer::ScopedTimer ( const ScopedTimer &  )
delete

Member Function Documentation

◆ operator=()

ScopedTimer & RST::Log::ScopedTimer::operator= ( const ScopedTimer &  )
delete

◆ elapsed()

Duration RST::Log::ScopedTimer::elapsed ( ) const
inline

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