ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
Acts::ScopedTimer Class Reference

A RAII timer class for measuring execution time of code blocks. More...

#include <Acts/Utilities/ScopedTimer.hpp>

Public Types

using clock_type = std::chrono::high_resolution_clock
 Type alias for high resolution clock used for timing.

Public Member Functions

 ScopedTimer (const ScopedTimer &)=delete
 ScopedTimer (const std::string &name, const Logger &logger, Logging::Level lvl=Logging::Level::INFO)
 Construct a new Scoped Timer.
 ScopedTimer (ScopedTimer &&)=delete
 ~ScopedTimer ()
 Destructor that logs the execution time.
ScopedTimeroperator= (const ScopedTimer &)=delete
ScopedTimeroperator= (ScopedTimer &&)=delete

Detailed Description

A RAII timer class for measuring execution time of code blocks.

ScopedTimer provides automatic timing of code blocks using RAII principles. It starts timing when constructed and automatically logs the duration when destroyed. This makes it ideal for measuring execution time of functions or code blocks without manual start/stop calls.

Example usage:

{
ScopedTimer timer("myFunction");
// ... code to measure ...
} // Timer automatically logs duration when block ends
ScopedTimer(const std::string &name, const Logger &logger, Logging::Level lvl=Logging::Level::INFO)
Construct a new Scoped Timer.

Member Typedef Documentation

◆ clock_type

using Acts::ScopedTimer::clock_type = std::chrono::high_resolution_clock

Type alias for high resolution clock used for timing.

Constructor & Destructor Documentation

◆ ScopedTimer() [1/3]

Acts::ScopedTimer::ScopedTimer ( const std::string & name,
const Logger & logger,
Logging::Level lvl = Logging::Level::INFO )
explicit

Construct a new Scoped Timer.

Parameters
nameIdentifier for the timed block
loggerLogger instance to use for output
lvlLogging level for the timing output

◆ ~ScopedTimer()

Acts::ScopedTimer::~ScopedTimer ( )

Destructor that logs the execution time.

Automatically calculates and logs the duration between construction and destruction using the specified logger and level.

◆ ScopedTimer() [2/3]

Acts::ScopedTimer::ScopedTimer ( const ScopedTimer & )
delete

◆ ScopedTimer() [3/3]

Acts::ScopedTimer::ScopedTimer ( ScopedTimer && )
delete

Member Function Documentation

◆ operator=() [1/2]

ScopedTimer & Acts::ScopedTimer::operator= ( const ScopedTimer & )
delete

◆ operator=() [2/2]

ScopedTimer & Acts::ScopedTimer::operator= ( ScopedTimer && )
delete