From 182b62deaf156528c603d31a5eebcad4c8ee617b Mon Sep 17 00:00:00 2001
From: Franck Dary <franck.dary@lis-lab.fr>
Date: Sun, 8 Mar 2020 18:30:56 +0100
Subject: [PATCH] Improved prints

---
 decoder/src/Decoder.cpp | 2 +-
 trainer/src/Trainer.cpp | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/decoder/src/Decoder.cpp b/decoder/src/Decoder.cpp
index db0444a..48eb5b1 100644
--- a/decoder/src/Decoder.cpp
+++ b/decoder/src/Decoder.cpp
@@ -63,7 +63,7 @@ void Decoder::decode(BaseConfig & config, std::size_t beamSize, bool debug, bool
         auto actualTime = std::chrono::high_resolution_clock::now();
         double seconds = std::chrono::duration<double, std::milli>(actualTime-pastTime).count() / 1000.0;
         pastTime = actualTime;
-        fmt::print(stderr, "\rdecoding... speed={:<5}ex/s\r", (int)(nbExamplesProcessed/seconds));
+        fmt::print(stderr, "\r{:80}\rdecoding... speed={:<6}ex/s\r", "", (int)(nbExamplesProcessed/seconds));
         nbExamplesProcessed = 0;
       }
 
diff --git a/trainer/src/Trainer.cpp b/trainer/src/Trainer.cpp
index 0dc197c..450c416 100644
--- a/trainer/src/Trainer.cpp
+++ b/trainer/src/Trainer.cpp
@@ -134,9 +134,9 @@ float Trainer::processDataset(DataLoader & loader, bool train, bool printAdvance
         double seconds = std::chrono::duration<double, std::milli>(actualTime-pastTime).count() / 1000.0;
         pastTime = actualTime;
         if (train)
-          fmt::print(stderr, "\rcurrent epoch : {:6.2f}% loss={:<7.3f} speed={:<6}ex/s", 100.0*(currentBatchNumber*batchSize)/nbExamples, lossSoFar, (int)(nbExamplesProcessed/seconds));
+          fmt::print(stderr, "\r{:80}\rcurrent epoch : {:6.2f}% loss={:<7.3f} speed={:<6}ex/s", "", 100.0*(currentBatchNumber*batchSize)/nbExamples, lossSoFar, (int)(nbExamplesProcessed/seconds));
         else
-          fmt::print(stderr, "\reval on dev : loss={:<7.3f} speed={:<6}ex/s", lossSoFar, (int)(nbExamplesProcessed/seconds));
+          fmt::print(stderr, "\r{:80}\reval on dev : loss={:<7.3f} speed={:<6}ex/s", "", lossSoFar, (int)(nbExamplesProcessed/seconds));
         lossSoFar = 0;
         nbExamplesProcessed = 0;
       }
-- 
GitLab