From 3bf714cbcddeca97fb524bad8917dbe04580d2c9 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Wed, 11 Jul 2018 19:41:35 +0200 Subject: [PATCH] refactor a bit --- src/instr/instr_platform.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/instr/instr_platform.cpp b/src/instr/instr_platform.cpp index 8591e8028b..ff63c714cd 100644 --- a/src/instr/instr_platform.cpp +++ b/src/instr/instr_platform.cpp @@ -238,23 +238,21 @@ static void instr_action_on_state_change(simgrid::kernel::resource::Action* acti int n = action->get_variable()->get_number_of_constraint(); for (int i = 0; i < n; i++) { + double value = action->get_variable()->get_value() * action->get_variable()->get_constraint_weight(i); /* Beware of composite actions: ptasks put links and cpus together. Extra pb: we cannot dynamic_cast from void* */ simgrid::kernel::resource::Resource* resource = static_cast(action->get_variable()->get_constraint(i)->get_id()); simgrid::surf::Cpu* cpu = dynamic_cast(resource); - if (cpu != nullptr) { - double value = action->get_variable()->get_value() * action->get_variable()->get_constraint_weight(i); + if (cpu != nullptr) TRACE_surf_resource_set_utilization("HOST", "power_used", cpu->get_cname(), action->get_category(), value, action->get_last_update(), SIMIX_get_clock() - action->get_last_update()); - } + simgrid::kernel::resource::LinkImpl* link = dynamic_cast(resource); - if (link != nullptr) { - double value = action->get_variable()->get_value() * action->get_variable()->get_constraint_weight(i); + if (link != nullptr) TRACE_surf_resource_set_utilization("LINK", "bandwidth_used", link->get_cname(), action->get_category(), value, action->get_last_update(), SIMIX_get_clock() - action->get_last_update()); - } } } -- 2.20.1