fix: add missing line cleanup for s/it progress display (#891)

This commit is contained in:
Wagner Bruna 2025-11-30 00:45:30 -03:00 committed by GitHub
parent 0249509a30
commit 673dbdda17
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -274,13 +274,16 @@ void pretty_progress(int step, int steps, float time) {
} }
} }
progress += "|"; progress += "|";
printf(time > 1.0f ? "\r%s %i/%i - %.2fs/it" : "\r%s %i/%i - %.2fit/s\033[K",
progress.c_str(), step, steps, const char* lf = (step == steps ? "\n" : "");
time > 1.0f || time == 0 ? time : (1.0f / time)); const char* unit = "s/it";
fflush(stdout); // for linux float speed = time;
if (step == steps) { if (speed < 1.0f && speed > 0.f) {
printf("\n"); 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) { std::string ltrim(const std::string& s) {