-
-static void computAndDisplayTotalEnergy() {
- simgrid::s4u::Link* link = nullptr;
- sg_link_t* link_list = link->listLink();
- int link_count = link->linkCount();
- double total_power = 0.0; // Total power consumption (whole platform)
- double total_energy = 0.0;
- double total_time = 0.0;
- for (int i = 0; i < link_count; i++) {
- if (link_list[i] != nullptr) {
- LinkEnergy* link_energy = link_list[i]->extension<LinkEnergy>();
- link_energy->update();
-
- double a_link_average_power = link_energy->getAveragePower(
- link_list[i]);
- total_power += a_link_average_power;
-
- double a_link_total_energy = link_energy->getALinkTotalEnergy(
- link_list[i]);
- total_energy += a_link_total_energy;
- const char* name = link_list[i]->getCname();
- if (strcmp(name, "__loopback__")) {
- XBT_INFO("%s Usage %f Bandwidth %f Power %f Energy %f", name,
- link_energy->getLinkUsage(), link_list[i]->bandwidth(),
- a_link_average_power, a_link_total_energy);
- }
- }
- }
-
- XBT_INFO("SgTotalPower %f SgTotalEnergy %f SgTransferTime %f", total_power,
- total_energy, surf_get_clock());
- xbt_free(link_list);
+static void computeAndDisplayTotalEnergy()
+{
+ std::vector<simgrid::s4u::Link*> link_list;
+ simgrid::s4u::Engine::getInstance()->getLinkList(&link_list);
+ double total_power = 0.0; // Total power consumption (whole platform)
+ double total_energy = 0.0;
+ for (const auto link : link_list) {
+ LinkEnergy* link_energy = link->extension<LinkEnergy>();
+ link_energy->update();
+
+ double a_link_total_energy = link_energy->getALinkTotalEnergy(link);
+ total_energy += a_link_total_energy;
+ const char* name = link->getCname();
+ if (strcmp(name, "__loopback__")) {
+ XBT_INFO("%s Usage %f Bandwidth %f Energy %f", name, link_energy->getLinkUsage(), link->bandwidth(),
+ a_link_total_energy);
+ }
+ }
+
+ XBT_INFO("SgTotalPower %f SgTotalEnergy %f SgTransferTime %f", total_power, total_energy, surf_get_clock());