From 2354b98a853df3ceec11cc7760113e35cd9c5a00 Mon Sep 17 00:00:00 2001
From: Felix Weiglhofer <weiglhofer@fias.uni-frankfurt.de>
Date: Sun, 12 May 2024 12:57:20 +0000
Subject: [PATCH] online: Fix idle time monitoring.

---
 reco/app/cbmreco/main.cxx | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/reco/app/cbmreco/main.cxx b/reco/app/cbmreco/main.cxx
index 1c065bff8a..72614757f2 100644
--- a/reco/app/cbmreco/main.cxx
+++ b/reco/app/cbmreco/main.cxx
@@ -24,6 +24,8 @@
 
 using namespace cbm::algo;
 
+namespace chron = std::chrono;
+
 std::shared_ptr<StorableRecoResults> makeStorableRecoResults(const fles::Timeslice& ts, const RecoResults& results)
 {
   auto storable = std::make_shared<StorableRecoResults>(ts.index(), ts.start_time());
@@ -168,7 +170,7 @@ int main(int argc, char** argv)
   Reco reco;
   MemoryLogger memoryLogger;
 
-  auto startProcessing = std::chrono::high_resolution_clock::now();
+  auto startProcessing = chron::high_resolution_clock::now();
   reco.Init(opts);
 
   fles::TimesliceAutoSource source(opts.InputLocator());
@@ -190,7 +192,7 @@ int main(int argc, char** argv)
   if (num_ts > 0) num_ts += opts.SkipTimeslices();
   L_(debug) << "Starting to fetch timeslices from source...";
 
-  auto startFetchTS = std::chrono::high_resolution_clock::now();
+  auto startFetchTS = chron::high_resolution_clock::now();
   while (auto timeslice = source.get()) {
     if (tsIdx < opts.SkipTimeslices()) {
       tsIdx++;
@@ -206,10 +208,9 @@ int main(int argc, char** argv)
       ts = std::move(timeslice);
     }
 
-    auto endFetchTS      = std::chrono::high_resolution_clock::now();
+    auto endFetchTS       = chron::high_resolution_clock::now();
     auto durationFetchTS = endFetchTS - startFetchTS;
-    extraMonitor.timeIdle +=
-      std::chrono::duration_cast<std::chrono::duration<double, std::milli>>(durationFetchTS).count();
+    extraMonitor.timeIdle = chron::duration_cast<chron::duration<double, std::milli>>(durationFetchTS).count();
 
     try {
       RecoResults result = reco.Run(*ts);
@@ -236,14 +237,14 @@ int main(int argc, char** argv)
 
     if (num_ts > 0 && tsIdx >= num_ts) break;
 
-    startFetchTS = std::chrono::high_resolution_clock::now();
+    startFetchTS = chron::high_resolution_clock::now();
   }
 
   if (archive) archive->end_stream();
 
   reco.Finalize();
-  auto endProcessing = std::chrono::high_resolution_clock::now();
-  auto duration      = std::chrono::duration_cast<std::chrono::milliseconds>(endProcessing - startProcessing);
+  auto endProcessing = chron::high_resolution_clock::now();
+  auto duration      = chron::duration_cast<chron::milliseconds>(endProcessing - startProcessing);
   L_(info) << "Total Processing time (Wall): " << duration.count() << " ms";
 
   return 0;
-- 
GitLab