xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
include
xrpl
core
LoadEvent.h
1
#pragma once
2
3
#include <
chrono
>
4
#include <
string
>
5
6
namespace
xrpl
{
7
8
class
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
//
15
class
LoadEvent
16
{
17
public
:
18
// VFALCO TODO remove the dependency on LoadMonitor. Is that possible?
19
LoadEvent
(
LoadMonitor
& monitor,
std::string
name
,
bool
shouldStart);
20
LoadEvent
(
LoadEvent
const
&) =
delete
;
21
22
~LoadEvent
();
23
24
[[nodiscard]]
std::string
const
&
25
name
()
const
;
26
27
// The time spent waiting.
28
[[nodiscard]] std::chrono::steady_clock::duration
29
waitTime
()
const
;
30
31
// The time spent running.
32
[[nodiscard]] 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
50
private
:
51
LoadMonitor
&
monitor_
;
52
53
// Represents our current state
54
bool
running_
;
55
56
// The name associated with this event, if any.
57
std::string
name_
;
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
std::string
chrono
xrpl::LoadEvent::LoadEvent
LoadEvent(LoadEvent const &)=delete
xrpl::LoadEvent::timeRunning_
std::chrono::steady_clock::duration timeRunning_
Definition
LoadEvent.h:64
xrpl::LoadEvent::running_
bool running_
Definition
LoadEvent.h:54
xrpl::LoadEvent::mark_
std::chrono::steady_clock::time_point mark_
Definition
LoadEvent.h:60
xrpl::LoadEvent::LoadEvent
LoadEvent(LoadMonitor &monitor, std::string name, bool shouldStart)
Definition
LoadEvent.cpp:12
xrpl::LoadEvent::monitor_
LoadMonitor & monitor_
Definition
LoadEvent.h:51
xrpl::LoadEvent::waitTime
std::chrono::steady_clock::duration waitTime() const
Definition
LoadEvent.cpp:35
xrpl::LoadEvent::~LoadEvent
~LoadEvent()
Definition
LoadEvent.cpp:22
xrpl::LoadEvent::setName
void setName(std::string const &name)
Definition
LoadEvent.cpp:47
xrpl::LoadEvent::name_
std::string name_
Definition
LoadEvent.h:57
xrpl::LoadEvent::stop
void stop()
Definition
LoadEvent.cpp:66
xrpl::LoadEvent::start
void start()
Definition
LoadEvent.cpp:53
xrpl::LoadEvent::timeWaiting_
std::chrono::steady_clock::duration timeWaiting_
Definition
LoadEvent.h:63
xrpl::LoadEvent::runTime
std::chrono::steady_clock::duration runTime() const
Definition
LoadEvent.cpp:41
xrpl::LoadEvent::name
std::string const & name() const
Definition
LoadEvent.cpp:29
xrpl::LoadMonitor
Definition
LoadMonitor.h:19
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:5
string
Generated by
1.17.0