diff --git a/src/beast/Builds/VisualStudio2012/beast.vcxproj b/src/beast/Builds/VisualStudio2012/beast.vcxproj
index 29b8ea374..e89b435e5 100644
--- a/src/beast/Builds/VisualStudio2012/beast.vcxproj
+++ b/src/beast/Builds/VisualStudio2012/beast.vcxproj
@@ -337,7 +337,6 @@
-
@@ -1190,12 +1189,6 @@
true
true
-
- true
- true
- true
- true
-
true
true
diff --git a/src/beast/Builds/VisualStudio2012/beast.vcxproj.filters b/src/beast/Builds/VisualStudio2012/beast.vcxproj.filters
index 2d991fef4..ac32658af 100644
--- a/src/beast/Builds/VisualStudio2012/beast.vcxproj.filters
+++ b/src/beast/Builds/VisualStudio2012/beast.vcxproj.filters
@@ -1139,9 +1139,6 @@
beast_asio\async
-
- beast_core\thread
-
beast
@@ -1757,9 +1754,6 @@
beast\crypto\impl
-
- beast_core\thread
-
beast\chrono\impl
diff --git a/src/beast/beast/chrono/CPUMeter.h b/src/beast/beast/chrono/CPUMeter.h
index 4040e1382..fd728a54e 100644
--- a/src/beast/beast/chrono/CPUMeter.h
+++ b/src/beast/beast/chrono/CPUMeter.h
@@ -51,22 +51,6 @@ private:
CPUMeter* m_meter;
};
-public:
- /** The type of container that measures idle time. */
- typedef ScopedTimeInterval ScopedIdleTime;
- typedef ScopedTimeInterval ScopedActiveTime;
-
- /** Returns the fraction of time that the CPU is being used. */
- double getCpuUsage () const
- {
- SharedState::ConstAccess state (m_state);
- double const seconds (state->usage.seconds());
- if (seconds > 0)
- return (state->usage.active.inSeconds() / seconds);
- return 0;
- }
-
-private:
enum
{
// The amount of time an aggregate must accrue before a swap
@@ -152,6 +136,21 @@ private:
state->front().active += interval;
state->update();
}
+
+public:
+ /** The type of container that measures idle time. */
+ typedef ScopedTimeInterval ScopedIdleTime;
+ typedef ScopedTimeInterval ScopedActiveTime;
+
+ /** Returns the fraction of time that the CPU is being used. */
+ double getUtilizaton () const
+ {
+ SharedState::ConstAccess state (m_state);
+ double const seconds (state->usage.seconds());
+ if (seconds > 0)
+ return (state->usage.active.inSeconds() / seconds);
+ return 0;
+ }
};
}
diff --git a/src/beast/beast/chrono/ScopedTimeInterval.h b/src/beast/beast/chrono/ScopedTimeInterval.h
index af3672870..53b85b742 100644
--- a/src/beast/beast/chrono/ScopedTimeInterval.h
+++ b/src/beast/beast/chrono/ScopedTimeInterval.h
@@ -41,7 +41,7 @@ public:
/** Create the measurement with UnaryFunction constructed from one argument. */
template
- explicit ScopedTimeInterval (Arg arg)
+ explicit ScopedTimeInterval (Arg& arg)
: m_func (arg)
, m_start (RelativeTime::fromStartup ())
{
diff --git a/src/beast/beast/thread/ServiceQueue.h b/src/beast/beast/thread/ServiceQueue.h
index 1f5454051..a9f337ec1 100644
--- a/src/beast/beast/thread/ServiceQueue.h
+++ b/src/beast/beast/thread/ServiceQueue.h
@@ -20,6 +20,7 @@
#ifndef BEAST_THREAD_SERVICEQUEUE_H_INCLUDED
#define BEAST_THREAD_SERVICEQUEUE_H_INCLUDED
+#include "../chrono/CPUMeter.h"
#include "../intrusive/List.h"
#include "../intrusive/LockFreeStack.h"
#include "SharedData.h"
@@ -390,6 +391,7 @@ protected:
typedef SharedData SharedState;
SharedState m_state;
+ CPUMeter m_cpuMeter;
Atomic m_stopped;
static ThreadLocalValue s_service;
@@ -459,6 +461,10 @@ public:
}
}
+ /** Returns the percentage of time the queue is using the CPU. */
+ double getUtilizaton () const
+ { return m_cpuMeter.getUtilizaton(); }
+
/** Returns the allocator associated with the container. */
allocator_type get_allocator() const
{
diff --git a/src/beast/beast/thread/impl/ServiceQueue.cpp b/src/beast/beast/thread/impl/ServiceQueue.cpp
index ddf9bd4f0..f82368c49 100644
--- a/src/beast/beast/thread/impl/ServiceQueue.cpp
+++ b/src/beast/beast/thread/impl/ServiceQueue.cpp
@@ -57,6 +57,8 @@ ServiceQueueBase::~ServiceQueueBase()
std::size_t ServiceQueueBase::poll ()
{
+ CPUMeter::ScopedActiveTime interval (m_cpuMeter);
+
std::size_t total (0);
ScopedServiceThread thread (this);
for (;;)
@@ -71,6 +73,8 @@ std::size_t ServiceQueueBase::poll ()
std::size_t ServiceQueueBase::poll_one ()
{
+ CPUMeter::ScopedActiveTime interval (m_cpuMeter);
+
ScopedServiceThread thread (this);
return dequeue();
}
@@ -81,8 +85,15 @@ std::size_t ServiceQueueBase::run ()
ScopedServiceThread thread (this);
while (! stopped())
{
- total += poll ();
- wait ();
+ {
+ CPUMeter::ScopedActiveTime interval (m_cpuMeter);
+ total += poll ();
+ }
+
+ {
+ CPUMeter::ScopedIdleTime interval (m_cpuMeter);
+ wait ();
+ }
}
return total;
}
@@ -93,10 +104,17 @@ std::size_t ServiceQueueBase::run_one ()
ScopedServiceThread (this);
for (;;)
{
- n = poll_one();
- if (n != 0)
- break;
- wait();
+ {
+ CPUMeter::ScopedActiveTime interval (m_cpuMeter);
+ n = poll_one();
+ if (n != 0)
+ break;
+ }
+
+ {
+ CPUMeter::ScopedIdleTime interval (m_cpuMeter);
+ wait();
+ }
}
return n;
}
diff --git a/src/ripple/validators/impl/Logic.h b/src/ripple/validators/impl/Logic.h
index 5e54411f5..626bb0c88 100644
--- a/src/ripple/validators/impl/Logic.h
+++ b/src/ripple/validators/impl/Logic.h
@@ -412,12 +412,13 @@ public:
//
// Return the current ChosenList as JSON
- Json::Value rpcPrint (Json::Value const& args)
+ Json::Value rpcPrint (Json::Value const& args, int cpuPercent)
{
Json::Value results (Json::objectValue);
Json::Value entries (Json::arrayValue);
{
+ results ["cpu"] = cpuPercent;
results ["count"] = int(m_validators.size());
for (ValidatorTable::const_iterator iter (m_validators.begin());
iter != m_validators.end(); ++iter)
diff --git a/src/ripple/validators/impl/Manager.cpp b/src/ripple/validators/impl/Manager.cpp
index c0a1d04b9..bd480e30a 100644
--- a/src/ripple/validators/impl/Manager.cpp
+++ b/src/ripple/validators/impl/Manager.cpp
@@ -147,7 +147,8 @@ public:
Json::Value rpcPrint (Json::Value const& args)
{
- return m_logic.rpcPrint (args);
+ int const cpuPercent (std::ceil (m_queue.getUtilizaton() * 100));
+ return m_logic.rpcPrint (args, cpuPercent);
}
Json::Value rpcRebuild (Json::Value const& args)