rippled
Loading...
Searching...
No Matches
LoadEvent.h
1#ifndef XRPL_CORE_LOADEVENT_H_INCLUDED
2#define XRPL_CORE_LOADEVENT_H_INCLUDED
3
4#include <chrono>
5#include <string>
6
7namespace ripple {
8
9class LoadMonitor;
10
11// VFALCO NOTE What is the difference between a LoadEvent and a LoadMonitor?
12// VFALCO TODO Rename LoadEvent to ScopedLoadSample
13//
14// This looks like a scoped elapsed time measuring class
15//
17{
18public:
19 // VFALCO TODO remove the dependency on LoadMonitor. Is that possible?
20 LoadEvent(LoadMonitor& monitor, std::string const& name, bool shouldStart);
21 LoadEvent(LoadEvent const&) = delete;
22
23 ~LoadEvent();
24
25 std::string const&
26 name() const;
27
28 // The time spent waiting.
29 std::chrono::steady_clock::duration
30 waitTime() const;
31
32 // The time spent running.
33 std::chrono::steady_clock::duration
34 runTime() const;
35
36 void
37 setName(std::string const& name);
38
39 // Start the measurement. If already started, then
40 // restart, assigning the elapsed time to the "waiting"
41 // state.
42 void
43 start();
44
45 // Stop the measurement and report the results. The
46 // time reported is measured from the last call to
47 // start.
48 void
49 stop();
50
51private:
53
54 // Represents our current state
56
57 // The name associated with this event, if any.
59
60 // Represents the time we last transitioned states
61 std::chrono::steady_clock::time_point mark_;
62
63 // The time we spent waiting and running respectively
64 std::chrono::steady_clock::duration timeWaiting_;
65 std::chrono::steady_clock::duration timeRunning_;
66};
67
68} // namespace ripple
69
70#endif
LoadMonitor & monitor_
Definition LoadEvent.h:52
std::chrono::steady_clock::duration timeRunning_
Definition LoadEvent.h:65
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
LoadEvent(LoadEvent const &)=delete
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
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6