rippled
ripple
core
LoadEvent.h
1
//------------------------------------------------------------------------------
2
/*
3
This file is part of rippled: https://github.com/ripple/rippled
4
Copyright (c) 2012, 2013 Ripple Labs Inc.
5
6
Permission to use, copy, modify, and/or distribute this software for any
7
purpose with or without fee is hereby granted, provided that the above
8
copyright notice and this permission notice appear in all copies.
9
10
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
*/
18
//==============================================================================
19
20
#ifndef RIPPLE_CORE_LOADEVENT_H_INCLUDED
21
#define RIPPLE_CORE_LOADEVENT_H_INCLUDED
22
23
#include <
chrono
>
24
#include <
memory
>
25
#include <
string
>
26
27
namespace
ripple
{
28
29
class
LoadMonitor;
30
31
// VFALCO NOTE What is the difference between a LoadEvent and a LoadMonitor?
32
// VFALCO TODO Rename LoadEvent to ScopedLoadSample
33
//
34
// This looks like a scoped elapsed time measuring class
35
//
36
class
LoadEvent
37
{
38
public
:
39
// VFALCO TODO remove the dependency on LoadMonitor. Is that possible?
40
LoadEvent
(
LoadMonitor
& monitor,
std::string
const
&
name
,
bool
shouldStart);
41
LoadEvent
(
LoadEvent
const
&) =
delete
;
42
43
~LoadEvent
();
44
45
std::string
const
&
46
name
()
const
;
47
48
// The time spent waiting.
49
std::chrono::steady_clock::duration
50
waitTime
()
const
;
51
52
// The time spent running.
53
std::chrono::steady_clock::duration
54
runTime
()
const
;
55
56
void
57
setName
(
std::string
const
&
name
);
58
59
// Start the measurement. If already started, then
60
// restart, assigning the elapsed time to the "waiting"
61
// state.
62
void
63
start
();
64
65
// Stop the measurement and report the results. The
66
// time reported is measured from the last call to
67
// start.
68
void
69
stop
();
70
71
private
:
72
LoadMonitor
&
monitor_
;
73
74
// Represents our current state
75
bool
running_
;
76
77
// The name associated with this event, if any.
78
std::string
name_
;
79
80
// Represents the time we last transitioned states
81
std::chrono::steady_clock::time_point
mark_
;
82
83
// The time we spent waiting and running respectively
84
std::chrono::steady_clock::duration
timeWaiting_
;
85
std::chrono::steady_clock::duration
timeRunning_
;
86
};
87
88
}
// namespace ripple
89
90
#endif
ripple::LoadEvent::setName
void setName(std::string const &name)
Definition:
LoadEvent.cpp:65
std::string
STL class.
ripple::LoadEvent::timeRunning_
std::chrono::steady_clock::duration timeRunning_
Definition:
LoadEvent.h:85
ripple::LoadEvent::stop
void stop()
Definition:
LoadEvent.cpp:84
ripple::LoadEvent::running_
bool running_
Definition:
LoadEvent.h:75
ripple::LoadEvent::start
void start()
Definition:
LoadEvent.cpp:71
chrono
ripple::LoadEvent::waitTime
std::chrono::steady_clock::duration waitTime() const
Definition:
LoadEvent.cpp:53
ripple::LoadEvent::monitor_
LoadMonitor & monitor_
Definition:
LoadEvent.h:72
ripple::LoadEvent
Definition:
LoadEvent.h:36
ripple::LoadEvent::name
std::string const & name() const
Definition:
LoadEvent.cpp:47
ripple::LoadMonitor
Definition:
LoadMonitor.h:36
ripple::LoadEvent::runTime
std::chrono::steady_clock::duration runTime() const
Definition:
LoadEvent.cpp:59
memory
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition:
RCLCensorshipDetector.h:29
ripple::LoadEvent::timeWaiting_
std::chrono::steady_clock::duration timeWaiting_
Definition:
LoadEvent.h:84
ripple::LoadEvent::~LoadEvent
~LoadEvent()
Definition:
LoadEvent.cpp:40
ripple::LoadEvent::LoadEvent
LoadEvent(LoadMonitor &monitor, std::string const &name, bool shouldStart)
Definition:
LoadEvent.cpp:27
ripple::LoadEvent::mark_
std::chrono::steady_clock::time_point mark_
Definition:
LoadEvent.h:81
ripple::LoadEvent::name_
std::string name_
Definition:
LoadEvent.h:78
string
Generated by
1.8.17