Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[ENERGY] Instead of using plain integers, use constants
authorChristian Heinrich <franz-christian.heinrich@inria.fr>
Tue, 27 Jun 2017 08:20:55 +0000 (10:20 +0200)
committerChristian Heinrich <franz-christian.heinrich@inria.fr>
Thu, 6 Jul 2017 17:09:31 +0000 (19:09 +0200)
src/surf/plugins/host_energy.cpp

index 3096d22..0436ec2 100644 (file)
@@ -152,6 +152,7 @@ private:
    * with the old pstate!)
    */
   int pstate = 0;
+  const int pstate_off = -1;
 
 public:
   double watts_off    = 0.0; /*< Consumption when the machine is turned off (shutdown) */
@@ -200,7 +201,7 @@ void HostEnergy::update()
     double previous_energy = this->total_energy;
 
     double instantaneous_consumption;
-    if (this->pstate == -1) // The host was off at the beginning of this time interval
+    if (this->pstate == pstate_off) // The host was off at the beginning of this time interval
       instantaneous_consumption = this->watts_off;
     else
       instantaneous_consumption = this->getCurrentWattsValue(cpu_load);
@@ -219,7 +220,7 @@ void HostEnergy::update()
   }
 
   /* Save data for the upcoming time interval: whether it's on/off and the pstate if it's on */
-  this->pstate = host->isOn() ? host->getPstate() : -1;
+  this->pstate = host->isOn() ? host->getPstate() : pstate_off;
 }
 
 HostEnergy::HostEnergy(simgrid::s4u::Host* ptr) : host(ptr), last_updated(surf_get_clock())