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

A timer class that measures and averages execution times of multiple samples. More...

#include <Acts/Utilities/ScopedTimer.hpp>

Classes

class  Sample
 RAII wrapper class for measuring individual timing samples. More...

Public Types

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

Public Member Functions

 AveragingScopedTimer (AveragingScopedTimer &&)=delete
 AveragingScopedTimer (const AveragingScopedTimer &)=delete
 AveragingScopedTimer (const std::string &name, const Logger &logger, Logging::Level lvl=Logging::Level::INFO)
 Construct a new AveragingScopedTimer.
 ~AveragingScopedTimer () noexcept
 Destroy the AveragingScopedTimer and log statistics.
AveragingScopedTimer & operator= (AveragingScopedTimer &&)=delete
AveragingScopedTimer & operator= (const AveragingScopedTimer &)=delete
Sample sample ()
 Create a new timing sample.

Detailed Description

A timer class that measures and averages execution times of multiple samples.

This class provides functionality to measure execution times of code blocks and calculate statistics (mean, standard deviation) across multiple samples. It uses RAII through the Sample class to automatically record timing information.

All samples must be destroyed before this timer. When recording samples on other threads, synchronize their completion (for example, by joining the threads) before destroying the timer.

Constructor & Destructor Documentation

◆ AveragingScopedTimer()

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

Construct a new AveragingScopedTimer.

Parameters
nameName of the timer for logging
loggerLogger instance to use for output
lvlLogging level for timing output

◆ ~AveragingScopedTimer()

Acts::AveragingScopedTimer::~AveragingScopedTimer ( )
noexcept

Destroy the AveragingScopedTimer and log statistics.

Outputs total duration and per-sample statistics (mean ± stddev) if logging is enabled at the configured level. Exceptions from formatting or logging terminate the process.

Member Function Documentation

◆ sample()

Sample Acts::AveragingScopedTimer::sample ( )

Create a new timing sample.

Returns
Sample RAII wrapper for measuring a single timing sample