Github   Telegram
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
tracing::ScopeTime Class Reference

Type to measure execution time of a scope. More...

#include <userver/tracing/scope_time.hpp>

Public Types

using Duration = std::chrono::nanoseconds
 
using DurationMillis = std::chrono::duration< double, std::milli >
 

Public Member Functions

 ScopeTime ()
 Creates a tracing::ScopeTime attached to tracing::Span::CurrentSpan(). More...
 
 ScopeTime (std::string scope_name)
 Creates a tracing::ScopeTime attached to tracing::Span::CurrentSpan() and starts measuring execution time. More...
 
 ScopeTime (const ScopeTime &)=delete
 
 ScopeTime (ScopeTime &&)=default
 
Duration Reset ()
 Records the current scope time if the name is set, and stops the timer.
 
Duration Reset (std::string scope_name)
 Records the current scope time if the name is set, and starts a new one.
 
void Discard ()
 Stops the timer without recording its value.
 
Duration DurationSinceReset () const
 
Duration DurationTotal (const std::string &scope_name) const
 
Duration DurationTotal () const
 
DurationMillis ElapsedSinceReset () const
 
DurationMillis ElapsedTotal (const std::string &scope_name) const
 
DurationMillis ElapsedTotal () const
 
const std::string & CurrentScope () const
 

Detailed Description

Type to measure execution time of a scope.

Use tracing::Span::CreateScopeTime() to construct

Definition at line 26 of file scope_time.hpp.

Member Typedef Documentation

◆ Duration

using tracing::ScopeTime::Duration = std::chrono::nanoseconds

Definition at line 28 of file scope_time.hpp.

◆ DurationMillis

using tracing::ScopeTime::DurationMillis = std::chrono::duration<double, std::milli>

Definition at line 29 of file scope_time.hpp.

Constructor & Destructor Documentation

◆ ScopeTime() [1/2]

tracing::ScopeTime::ScopeTime ( )

Creates a tracing::ScopeTime attached to tracing::Span::CurrentSpan().

Equivalent to tracing::Span::CurrentSpan().CreateScopeTime()

◆ ScopeTime() [2/2]

tracing::ScopeTime::ScopeTime ( std::string  scope_name)
explicit

Creates a tracing::ScopeTime attached to tracing::Span::CurrentSpan() and starts measuring execution time.

Equivalent to tracing::Span::CurrentSpan().CreateScopeTime(scope_name)

Member Function Documentation

◆ CurrentScope()

const std::string & tracing::ScopeTime::CurrentScope ( ) const
inline

Definition at line 91 of file scope_time.hpp.

◆ DurationSinceReset()

Duration tracing::ScopeTime::DurationSinceReset ( ) const

Returns time elapsed since last reset Will return 0 if the timer is stopped

◆ DurationTotal() [1/2]

Duration tracing::ScopeTime::DurationTotal ( ) const

Returns total time elapsed for current scope Will return 0 if the timer is stopped

◆ DurationTotal() [2/2]

Duration tracing::ScopeTime::DurationTotal ( const std::string &  scope_name) const

Returns total time elapsed for a certain scope. If there is no record for the scope, returns 0

◆ ElapsedSinceReset()

DurationMillis tracing::ScopeTime::ElapsedSinceReset ( ) const

Returns time elapsed since last reset, returns 0 if the timer is stopped.

Prefer using ScopeTime::DurationSinceReset()

◆ ElapsedTotal() [1/2]

DurationMillis tracing::ScopeTime::ElapsedTotal ( ) const

Returns total time elapsed for current scope Will return 0 if the timer is stopped.

Prefer using ScopeTime::DurationTotal()

◆ ElapsedTotal() [2/2]

DurationMillis tracing::ScopeTime::ElapsedTotal ( const std::string &  scope_name) const

Returns total time elapsed for a certain scope. If there is no record for the scope, returns 0.

Prefer using ScopeTime::DurationTotal()


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