diff --git a/util.cpp b/util.cpp index d6d06752..6c58f404 100644 --- a/util.cpp +++ b/util.cpp @@ -269,13 +269,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) {