X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/131ea969cf91c332bd533b7e9d67c729149e9b4d..a020daf9661ce4855865f8a8c522484a34c1743f:/src/plugins/host_energy.cpp diff --git a/src/plugins/host_energy.cpp b/src/plugins/host_energy.cpp index 1f4ba650f1..0b1ed29b96 100644 --- a/src/plugins/host_energy.cpp +++ b/src/plugins/host_energy.cpp @@ -512,15 +512,13 @@ static void on_host_destruction(simgrid::s4u::Host const& host) static void on_simulation_end() { - std::vector hosts = simgrid::s4u::Engine::get_instance()->get_all_hosts(); - double total_energy = 0.0; // Total energy consumption (whole platform) double used_hosts_energy = 0.0; // Energy consumed by hosts that computed something - for (size_t i = 0; i < hosts.size(); i++) { - if (dynamic_cast(hosts[i]) == nullptr) { // Ignore virtual machines - double energy = hosts[i]->extension()->get_consumed_energy(); + for (simgrid::s4u::Host const* host : simgrid::s4u::Engine::get_instance()->get_all_hosts()) { + if (host && dynamic_cast(host) == nullptr) { // Ignore virtual machines + double energy = host->extension()->get_consumed_energy(); total_energy += energy; - if (hosts[i]->extension()->host_was_used_) + if (host->extension()->host_was_used_) used_hosts_energy += energy; } }