From 673dbdda1705c3172307e59f618c50c2ace258ab Mon Sep 17 00:00:00 2001 From: Wagner Bruna Date: Sun, 30 Nov 2025 00:45:30 -0300 Subject: [PATCH] fix: add missing line cleanup for s/it progress display (#891) --- util.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/util.cpp b/util.cpp index 26cfde4..f101c3b 100644 --- a/util.cpp +++ b/util.cpp @@ -274,13 +274,16 @@ void pretty_progress(int step, int steps, float time) { } } progress += "|"; - printf(time > 1.0f ? "\r%s %i/%i - %.2fs/it" : "\r%s %i/%i - %.2fit/s\033[K", - progress.c_str(), step, steps, - time > 1.0f || time == 0 ? time : (1.0f / time)); - fflush(stdout); // for linux - if (step == steps) { - printf("\n"); + + const char* lf = (step == steps ? "\n" : ""); + const char* unit = "s/it"; + float speed = time; + if (speed < 1.0f && speed > 0.f) { + speed = 1.0f / speed; + unit = "it/s"; } + printf("\r%s %i/%i - %.2f%s\033[K%s", progress.c_str(), step, steps, speed, unit, lf); + fflush(stdout); // for linux } std::string ltrim(const std::string& s) {