#include <userver/tracing/scope_time.hpp>
Type to measure execution time of a scope.
Use tracing::Span::CreateScopeTime() to construct
Definition at line 26 of file 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().   | |
| ScopeTime (std::string scope_name) | |
| Creates a tracing::ScopeTime attached to tracing::Span::CurrentSpan() and starts measuring execution time.   | |
| 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 | 
Static Public Member Functions | |
| static std::optional< ScopeTime > | CreateOptionalScopeTime () | 
| If there exists a tracing::Span::CurrentSpan(), Creates a tracing::ScopeTime attached to that Span, otherwise return std::nullopt.  | |
| static std::optional< ScopeTime > | CreateOptionalScopeTime (std::string_view name) | 
| If there exists a tracing::Span::CurrentSpan(), Creates a tracing::ScopeTime attached to that Span and starts measuring execution time, otherwise return std::nullopt.  | |
| using tracing::ScopeTime::Duration = std::chrono::nanoseconds | 
Definition at line 28 of file scope_time.hpp.
| using tracing::ScopeTime::DurationMillis = std::chrono::duration<double, std::milli> | 
Definition at line 29 of file scope_time.hpp.
| tracing::ScopeTime::ScopeTime | ( | ) | 
Creates a tracing::ScopeTime attached to tracing::Span::CurrentSpan().
Equivalent to tracing::Span::CurrentSpan().CreateScopeTime()
      
  | 
  explicit | 
Creates a tracing::ScopeTime attached to tracing::Span::CurrentSpan() and starts measuring execution time.
Equivalent to tracing::Span::CurrentSpan().CreateScopeTime(scope_name)
      
  | 
  inline | 
Definition at line 102 of file scope_time.hpp.
| Duration tracing::ScopeTime::DurationSinceReset | ( | ) | const | 
Returns time elapsed since last reset Will return 0 if the timer is stopped
| Duration tracing::ScopeTime::DurationTotal | ( | ) | const | 
Returns total time elapsed for current scope Will return 0 if the timer is stopped
| 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
| DurationMillis tracing::ScopeTime::ElapsedSinceReset | ( | ) | const | 
Returns time elapsed since last reset, returns 0 if the timer is stopped.
Prefer using ScopeTime::DurationSinceReset()
| DurationMillis tracing::ScopeTime::ElapsedTotal | ( | ) | const | 
Returns total time elapsed for current scope Will return 0 if the timer is stopped.
Prefer using ScopeTime::DurationTotal()
| 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()