unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Michal Sojka <sojkam1@fel.cvut.cz>
To: notmuch@notmuchmail.org
Subject: [PATCH] new: Print progress estimates only when we have sufficient information
Date: Wed, 26 Jan 2011 14:06:57 +0100	[thread overview]
Message-ID: <1296047217-7266-1-git-send-email-sojkam1@fel.cvut.cz> (raw)
In-Reply-To: <1295603977-14326-5-git-send-email-sojkam1@fel.cvut.cz>

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.
---
 notmuch-new.c |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/notmuch-new.c b/notmuch-new.c
index fa7a76d..8f64b25 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);
 }
-- 
1.7.2.3

  parent reply	other threads:[~2011-01-26 13:07 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-21  9:59 [PATCH 0/3] Speedups and enhancements of notmuch new Michal Sojka
2011-01-21  9:59 ` [PATCH 1/3] Do not defer maildir flag synchronization during the first " Michal Sojka
2011-01-21  9:59 ` [PATCH 1/3] new: Do not defer maildir flag synchronization during the first run Michal Sojka
2011-01-25 22:42   ` Austin Clements
2011-01-26  9:15     ` Carl Worth
2011-01-26 11:59       ` Carl Worth
2011-01-26 15:07         ` Austin Clements
2011-01-26 16:50           ` Michal Sojka
2011-01-27  5:04           ` Carl Worth
2011-01-27  5:43             ` Austin Clements
2011-01-30  0:21               ` Rob Browning
2011-01-21  9:59 ` [PATCH 2/3] new: Add all initial tags at once Michal Sojka
2011-01-26 12:10   ` Carl Worth
2011-01-26 16:52   ` Thomas Schwinge
2011-01-27  5:03     ` Carl Worth
2011-01-27  7:14       ` Carl Worth
2011-01-27 11:08         ` Michal Sojka
2011-01-21  9:59 ` [PATCH 3/3] new: Enhance progress reporting Michal Sojka
2011-01-26 12:23   ` Carl Worth
2011-01-26 13:16     ` Michal Sojka
2011-01-26 13:06   ` Michal Sojka [this message]
2011-01-26 13:49     ` [PATCH] new: Print progress estimates only when we have sufficient information Carl Worth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1296047217-7266-1-git-send-email-sojkam1@fel.cvut.cz \
    --to=sojkam1@fel.cvut.cz \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).