From ba2c4e8dbea61bfad3754b0282887f4ffab2fa92 Mon Sep 17 00:00:00 2001 From: Wagner Bruna Date: Wed, 15 Oct 2025 22:28:15 -0300 Subject: [PATCH 1/2] fix: add missing line cleanup for s/it progress display --- util.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util.cpp b/util.cpp index c46216646..7625e95c8 100644 --- a/util.cpp +++ b/util.cpp @@ -273,7 +273,7 @@ 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", + printf(time > 1.0f ? "\r%s %i/%i - %.2fs/it\033[K" : "\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 From 80b8d6e5ba59853463a2f696ec0a2e6625f21f7a Mon Sep 17 00:00:00 2001 From: Wagner Bruna Date: Wed, 15 Oct 2025 22:28:27 -0300 Subject: [PATCH 2/2] refactor: reorganize progress line formatting --- util.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/util.cpp b/util.cpp index 7625e95c8..7db6565de 100644 --- a/util.cpp +++ b/util.cpp @@ -273,13 +273,16 @@ void pretty_progress(int step, int steps, float time) { } } progress += "|"; - printf(time > 1.0f ? "\r%s %i/%i - %.2fs/it\033[K" : "\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) {