userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
scope_time.hpp
Go to the documentation of this file.
1
#pragma once
2
5
6
#include <atomic>
7
#include <chrono>
8
#include <optional>
9
#include <string>
10
11
#include <
userver/logging/log_extra.hpp
>
12
13
USERVER_NAMESPACE_BEGIN
14
15
namespace
tracing
{
16
17
namespace
impl {
18
19
class
TimeStorage;
20
21
}
// namespace impl
22
26
class
ScopeTime
{
27
public
:
28
using
Duration = std::chrono::nanoseconds;
29
using
DurationMillis = std::chrono::duration<double, std::milli>;
30
35
ScopeTime
();
36
45
explicit
ScopeTime
(std::string scope_name);
46
50
static
std::optional<ScopeTime>
CreateOptionalScopeTime
();
51
55
static
std::optional<ScopeTime>
CreateOptionalScopeTime
(std::string_view name);
56
58
// Constructors for internal use
59
explicit
ScopeTime
(impl::TimeStorage& ts);
60
ScopeTime
(impl::TimeStorage& ts, std::string scope_name);
62
63
ScopeTime
(
const
ScopeTime
&) =
delete
;
64
ScopeTime
(
ScopeTime
&&) =
default
;
65
~ScopeTime
();
66
68
Duration
Reset
();
69
71
Duration
Reset
(std::string scope_name);
72
74
void
Discard
();
75
78
Duration
DurationSinceReset
()
const
;
79
82
Duration
DurationTotal
(std::string_view scope_name)
const
;
83
86
Duration
DurationTotal
()
const
;
87
91
DurationMillis
ElapsedSinceReset
()
const
;
92
97
DurationMillis
ElapsedTotal
(std::string_view scope_name)
const
;
98
103
DurationMillis
ElapsedTotal
()
const
;
104
105
const
std::string& CurrentScope()
const
{
return
scope_name_; }
106
107
private
:
108
impl::TimeStorage& ts_;
109
std::chrono::steady_clock::time_point start_;
110
std::string scope_name_;
111
};
112
113
}
// namespace tracing
114
115
USERVER_NAMESPACE_END
userver
tracing
scope_time.hpp
Generated on
for userver by
Doxygen
1.17.0