Skip to content

Commit 673dbdd

Browse files
authored
fix: add missing line cleanup for s/it progress display (#891)
1 parent 0249509 commit 673dbdd

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

util.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -274,13 +274,16 @@ void pretty_progress(int step, int steps, float time) {
274274
}
275275
}
276276
progress += "|";
277-
printf(time > 1.0f ? "\r%s %i/%i - %.2fs/it" : "\r%s %i/%i - %.2fit/s\033[K",
278-
progress.c_str(), step, steps,
279-
time > 1.0f || time == 0 ? time : (1.0f / time));
280-
fflush(stdout); // for linux
281-
if (step == steps) {
282-
printf("\n");
277+
278+
const char* lf = (step == steps ? "\n" : "");
279+
const char* unit = "s/it";
280+
float speed = time;
281+
if (speed < 1.0f && speed > 0.f) {
282+
speed = 1.0f / speed;
283+
unit = "it/s";
283284
}
285+
printf("\r%s %i/%i - %.2f%s\033[K%s", progress.c_str(), step, steps, speed, unit, lf);
286+
fflush(stdout); // for linux
284287
}
285288

286289
std::string ltrim(const std::string& s) {

0 commit comments

Comments
 (0)