From b6a17a2d65557f2b9f96d336f970b67b05d14c03 Mon Sep 17 00:00:00 2001
From: Mohcine Chraibi <m.chraibi@fz-juelich.de>
Date: Sat, 19 May 2018 09:50:53 +0200
Subject: [PATCH] Add elapsed time and reduce print logs per frame

---
 Analysis.cpp         |  1 +
 main.cpp             | 21 +++++++++++++++------
 methods/Method_D.cpp |  6 +++---
 3 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/Analysis.cpp b/Analysis.cpp
index 748931ae..7fce560c 100644
--- a/Analysis.cpp
+++ b/Analysis.cpp
@@ -398,6 +398,7 @@ int Analysis::RunAnalysis(const string& filename, const string& path)
                if(result_D)
                {
                     Log->Write("INFO:\tSuccess with Method D using measurement area id %d!\n",_areaForMethod_D[i]->_id);
+                    std::cout << "INFO:\tSuccess with Method D using measurement area id "<< _areaForMethod_D[i]->_id << "\n";
                     if(_plotTimeseriesD[i])
                     {
                          string parameters_Timeseries="python \""+_scriptsLocation+"/_Plot_timeseries_rho_v.py\" -p \""+ _projectRootDir+VORO_LOCATION + "\" -n "+filename+
diff --git a/main.cpp b/main.cpp
index 06a0855c..c9c1b80f 100644
--- a/main.cpp
+++ b/main.cpp
@@ -1,8 +1,8 @@
 /**
  * \file        main.cpp
  * \date        Oct 10, 2014
- * \version     v0.8.1
- * \copyright   <2009-2015> Forschungszentrum Juelich GmbH. All rights reserved.
+ * \version     v0.8.3
+ * \copyright   <2009-2018> Forschungszentrum Juelich GmbH. All rights reserved.
  *
  * \section License
  * This file is part of JuPedSim.
@@ -29,18 +29,20 @@
  *
  **/
 
+#include <chrono>
 #include "geometry/Building.h"
 #include "general/ArgumentParser.h"
 #include "Analysis.h"
 
 using namespace std;
+using namespace std::chrono;
 
 int main(int argc, char **argv)
 {
       Log = new STDIOHandler();
      // Parsing the arguments
       ArgumentParser* args = new ArgumentParser();
-
+      std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now();
 
      if(args->ParseArgs(argc, argv))
      {
@@ -58,6 +60,7 @@ int main(int argc, char **argv)
                analysis.RunAnalysis(file, path);
                Log->Write("**********************************************************************");
                Log->Write("INFO: \tEnd Analysis for the file: %s\n",file.c_str());
+               std::cout << "INFO: \tEnd Analysis for the file: " << file.c_str() << "\n";
           }
      }
      else
@@ -65,9 +68,15 @@ int main(int argc, char **argv)
           //Log->Write("INFO:\tFail to parse the ini file");
           Log->Write("INFO:\tFinishing...");
      }
+
      //do the last cleaning
-     delete args;
-     delete Log;
+      std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now();
+      float duration = std::chrono::duration_cast<std::chrono::microseconds>(end - begin).count()/1000000.0;
+      Log->Write("Time elapsed:\t %0.2f [s]\n", duration);
+
+      std::cout << "Time elapsed:\t " << duration << " [s]\n";
 
-     return (EXIT_SUCCESS);
+      delete args;
+      delete Log;
+      return (EXIT_SUCCESS);
 }
diff --git a/methods/Method_D.cpp b/methods/Method_D.cpp
index 7444010f..41c11599 100644
--- a/methods/Method_D.cpp
+++ b/methods/Method_D.cpp
@@ -130,9 +130,9 @@ bool Method_D::Process (const PedData& peddata,const std::string& scriptsLocatio
           std::ostringstream ss;
           ss << std::setw(5) << std::setfill('0') << frid;
           const std::string str_frid = ss.str();
-          if(!(frid%10))
+          if(!(frid%50))
           {
-               Log->Write("frame ID = %d",frid);
+               Log->Write("INFO:\tframe ID = %d",frid);
           }
           vector<int> ids=_peds_t[frameNr];
           vector<int> IdInFrame = peddata.GetIdInFrame(frameNr, ids, zPos_measureArea);
@@ -211,7 +211,7 @@ bool Method_D::Process (const PedData& peddata,const std::string& scriptsLocatio
           } // if N >3
           else
           {
-               Log->Write("INFO: \tThe number of the pedestrians is less than 2. Frame = %d (minFrame = %d)\n", frid, minFrame);
+               Log->Write("INFO: \tThe number of the pedestrians is small (%d). Frame = %d (minFrame = %d)\n", NumPeds, frid, minFrame);
           }
      }
      fclose(_fVoronoiRhoV);
-- 
GitLab