]> AND Private Git Repository - loba.git/blobdiff - main.cpp
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
Ongoing work on process logic...
[loba.git] / main.cpp
index 401a51a88079e3ea001e0ded4129f2429e8b9ed4..5d43190e14e4cc9512e8355a7304e4ee6058c891 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -45,6 +45,25 @@ int simulation_main(int argc, char* argv[])
     return result;
 }
 
+void check_for_lost_load()
+{
+    const double threshold = 1e-4;
+    double total_init = process::get_total_load_init();
+    double total_exit = process::get_total_load_exit();
+    double lost = total_init - total_exit;
+    double lost_ratio = 100 * lost / total_init;
+    if (lost_ratio < -threshold) {
+        CRITICAL2("Gained load at exit! %g (%g%%) <============",
+                  lost, lost_ratio);
+    } else if (lost_ratio > threshold) {
+        CRITICAL2("Lost load at exit! %g (%g%%) <============",
+                  lost, lost_ratio);
+    } else {
+        DEBUG2("Total load at exit looks good: %g (%g%%)", lost, lost_ratio);
+    }
+
+}
+
 int main(int argc, char* argv[])
 {
     // Note: variables used after THROW must be declared as volatile.
@@ -113,8 +132,9 @@ int main(int argc, char* argv[])
         // Launch the MSG simulation.
         INFO1("Starting simulation at %f...", MSG_get_clock());
         res = MSG_main();
-        INFO1("Simulation ended at %f.", MSG_get_clock());
         simulated_time = MSG_get_clock();
+        INFO1("Simulation ended at %f.", simulated_time);
+        check_for_lost_load();
         if (res != MSG_OK)
             THROW1(0, 0, "MSG_main() failed with status %#x", res);