]> AND Public Git Repository - simgrid.git/blobdiff - src/plugins/link_load.cpp
Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
flatifier.cpp: revert change from commit ba1c6dce93, and omit empty routes from output.
[simgrid.git] / src / plugins / link_load.cpp
index 77f4382b9428b8308a234e39ccb13a5d703ba661..719b96afe3ce3b8fb2b79415d196f1e76d447b9a 100644 (file)
@@ -3,12 +3,10 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#include "simgrid/host.h"
-#include "simgrid/plugins/load.h"
-#include "simgrid/s4u/Link.hpp"
+#include <simgrid/plugins/load.h>
+#include <simgrid/s4u/Engine.hpp>
+
 #include "src/surf/network_interface.hpp"
-#include "src/surf/surf_interface.hpp"
-#include "surf/surf.hpp"
 
 #include <limits>
 
@@ -75,7 +73,7 @@ LinkLoad::LinkLoad(s4u::Link* ptr) : link_(ptr), is_tracked_(false)
 
 void LinkLoad::track()
 {
-  xbt_assert(!is_tracked_, "Trying to track load of link '%s' while it is already tracked, aborting.",
+  xbt_assert(not is_tracked_, "Trying to track load of link '%s' while it is already tracked, aborting.",
              link_->get_cname());
   XBT_DEBUG("Tracking load of link '%s'", link_->get_cname());
 
@@ -100,7 +98,7 @@ void LinkLoad::reset()
   max_bytes_per_second_ = std::numeric_limits<double>::lowest();
   XBT_DEBUG("min_bytes_per_second_ = %g", min_bytes_per_second_);
   XBT_DEBUG("max_bytes_per_second_ = %g", max_bytes_per_second_);
-  last_reset_   = surf_get_clock();
+  last_reset_   = simgrid::s4u::Engine::get_clock();
   last_updated_ = last_reset_;
 }
 
@@ -113,7 +111,7 @@ void LinkLoad::update()
              link_->get_cname());
 
   double current_instantaneous_bytes_per_second = link_->get_usage();
-  double now                                    = surf_get_clock();
+  double now                                    = simgrid::s4u::Engine::get_clock();
 
   // Update minimum/maximum observed values if needed
   min_bytes_per_second_ = std::min(min_bytes_per_second_, current_instantaneous_bytes_per_second);
@@ -150,7 +148,7 @@ double LinkLoad::get_average_bytes()
 {
   update();
 
-  double now = surf_get_clock();
+  double now = simgrid::s4u::Engine::get_clock();
   if (now > last_reset_)
     return cumulated_bytes_ / (now - last_reset_);
   else
@@ -186,8 +184,9 @@ static void on_communicate(const simgrid::kernel::resource::NetworkAction& actio
  */
 void sg_link_load_plugin_init()
 {
-  xbt_assert(sg_host_count() == 0, "Please call sg_link_load_plugin_init() BEFORE initializing the platform.");
-  xbt_assert(!LinkLoad::EXTENSION_ID.valid(), "Double call to sg_link_load_plugin_init. Aborting.");
+  xbt_assert(simgrid::s4u::Engine::get_instance()->get_host_count() == 0,
+             "Please call sg_link_load_plugin_init() BEFORE initializing the platform.");
+  xbt_assert(not LinkLoad::EXTENSION_ID.valid(), "Double call to sg_link_load_plugin_init. Aborting.");
   LinkLoad::EXTENSION_ID = simgrid::s4u::Link::extension_create<LinkLoad>();
 
   // Attach new LinkLoad links created in the future.