rippled
Loading...
Searching...
No Matches
LoadEvent.cpp
1#include <xrpld/core/LoadEvent.h>
2#include <xrpld/core/LoadMonitor.h>
3
4#include <xrpl/beast/utility/instrumentation.h>
5
6namespace ripple {
7
9 LoadMonitor& monitor,
10 std::string const& name,
11 bool shouldStart)
12 : monitor_(monitor)
13 , running_(shouldStart)
14 , name_(name)
15 , mark_{std::chrono::steady_clock::now()}
16 , timeWaiting_{}
17 , timeRunning_{}
18{
19}
20
22{
23 if (running_)
24 stop();
25}
26
27std::string const&
29{
30 return name_;
31}
32
33std::chrono::steady_clock::duration
35{
36 return timeWaiting_;
37}
38
39std::chrono::steady_clock::duration
41{
42 return timeRunning_;
43}
44
45void
47{
48 name_ = name;
49}
50
51void
53{
54 auto const now = std::chrono::steady_clock::now();
55
56 // If we had already called start, this call will
57 // replace the previous one. Any time accumulated will
58 // be counted as "waiting".
59 timeWaiting_ += now - mark_;
60 mark_ = now;
61 running_ = true;
62}
63
64void
66{
67 XRPL_ASSERT(running_, "ripple::LoadEvent::stop : is running");
68
69 auto const now = std::chrono::steady_clock::now();
70
71 timeRunning_ += now - mark_;
72 mark_ = now;
73 running_ = false;
74
76}
77
78} // namespace ripple
LoadMonitor & monitor_
Definition LoadEvent.h:52
std::chrono::steady_clock::duration timeRunning_
Definition LoadEvent.h:65
LoadEvent(LoadMonitor &monitor, std::string const &name, bool shouldStart)
Definition LoadEvent.cpp:8
std::chrono::steady_clock::duration timeWaiting_
Definition LoadEvent.h:64
std::string const & name() const
Definition LoadEvent.cpp:28
std::chrono::steady_clock::duration waitTime() const
Definition LoadEvent.cpp:34
std::chrono::steady_clock::duration runTime() const
Definition LoadEvent.cpp:40
std::chrono::steady_clock::time_point mark_
Definition LoadEvent.h:61
void setName(std::string const &name)
Definition LoadEvent.cpp:46
std::string name_
Definition LoadEvent.h:58
void addLoadSample(LoadEvent const &sample)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
STL namespace.