aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Michal Sojka <sojkam1@fel.cvut.cz>2011-01-26 14:06:57 +0100
committerGravatar Carl Worth <cworth@cworth.org>2011-01-26 23:47:51 +1000
commitc58523088ac7fcbfa841187b1447269b638bfa95 (patch)
treef961ba8ce0fa1d37563845a6b292059195224d31
parent1a915d1b3852c5771507710ed470547b53b1c7ec (diff)
new: Print progress estimates only when we have sufficient information
Without this patch, it might happen that the remaining time or processing rate were calculated just after start where nothing was processed yet. This resulted into division by a very small number (or zero) and the printed information was of little value. Instead of printing nonsenses we print only that the operation is in progress. The estimates will be printed later, after there is enough data.
-rw-r--r--notmuch-new.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/notmuch-new.c b/notmuch-new.c
index 1473d2e6..941f9d61 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -117,15 +117,19 @@ generic_print_progress (const char *action, const char *object,
printf ("%s %d ", action, processed);
if (total) {
- double time_remaining;
-
- time_remaining = ((total - processed) / rate_overall);
- printf ("of %d %s (", total, object);
- notmuch_time_print_formatted_seconds (time_remaining);
- printf (" remaining).\033[K\r");
+ printf ("of %d %s", total, object);
+ if (processed > 0 && elapsed_overall > 0.5) {
+ double time_remaining = ((total - processed) / rate_overall);
+ printf (" (");
+ notmuch_time_print_formatted_seconds (time_remaining);
+ printf (" remaining)");
+ }
} else {
- printf ("%s (%d %s/sec.)\033[K\r", object, (int) rate_overall, object);
+ printf ("%s", object);
+ if (elapsed_overall > 0.5)
+ printf (" (%d %s/sec.)", (int) rate_overall, object);
}
+ printf (".\033[K\r");
fflush (stdout);
}