From 770f1cc88b3b35c90e505470753b70b95a326b91 Mon Sep 17 00:00:00 2001 From: Christian Heinrich Date: Wed, 5 Apr 2017 14:32:55 +0200 Subject: [PATCH] [PLUGINS] Added HostLoad::getAverageLoad() to the HostLoad plugin This functions returns the average load since the last reset --- src/surf/plugins/host_load.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/surf/plugins/host_load.cpp b/src/surf/plugins/host_load.cpp index 5225633b55..dcf86a2a9c 100644 --- a/src/surf/plugins/host_load.cpp +++ b/src/surf/plugins/host_load.cpp @@ -41,6 +41,7 @@ public: private: simgrid::s4u::Host* host = nullptr; double last_updated = 0; + double last_reset = 0; double current_flops = 0; double computed_flops = 0; }; @@ -48,7 +49,10 @@ private: simgrid::xbt::Extension HostLoad::EXTENSION_ID; HostLoad::HostLoad(simgrid::s4u::Host* ptr) - : host(ptr), last_updated(surf_get_clock()), current_flops(lmm_constraint_get_usage(host->pimpl_cpu->constraint())) + : host(ptr) + , last_updated(surf_get_clock()) + , last_reset(surf_get_clock()) + , current_flops(lmm_constraint_get_usage(host->pimpl_cpu->constraint())) { } @@ -73,6 +77,11 @@ double HostLoad::getCurrentLoad() return current_flops / (host->speed() * host->coreCount()); } +double HostLoad::getAverageLoad() +{ + return getComputedFlops() / (host->speed() * host->coreCount() * (surf_get_clock() - last_reset)) +} + double HostLoad::getComputedFlops() { update(); @@ -86,6 +95,7 @@ double HostLoad::getComputedFlops() void HostLoad::reset() { last_updated = surf_get_clock(); + last_reset = surf_get_clock(); computed_flops = 0; } } -- 2.20.1