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 += "|";
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) {