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