aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Worth <cworth@cworth.org>2009-10-15 09:04:31 -0700
committerCarl Worth <cworth@cworth.org>2009-10-15 09:04:31 -0700
commit5fbdbeb333b4fb8293092e8cb9f5b19da3e53ed5 (patch)
tree5a640090317222001da6b8b1bd69a3a51cf7cc96
parenta2c467242ac646bb16638906dec1bd075e098674 (diff)
Change progress report to show "instantaneous" rate. Also print total time.
Instead of always showing the overall rate, we wait until the end to show that. Then, on incremental updates we show the rate over the last increment. This makes it much easier to actually watch what's happening, (and it's easy to see the efect of xapian's internal 10,000 document flush).
-rw-r--r--notmuch-index-message.cc15
1 files changed, 12 insertions, 3 deletions
diff --git a/notmuch-index-message.cc b/notmuch-index-message.cc
index f16bd1ad..7610aa41 100644
--- a/notmuch-index-message.cc
+++ b/notmuch-index-message.cc
@@ -722,7 +722,8 @@ main (int argc, char **argv)
GIOStatus gio_status;
GError *error = NULL;
int count;
- struct timeval tv_start, tv_now;
+ struct timeval tv_start, tv_last, tv_now;
+ double elapsed;
if (argc < 2) {
usage (argv[0]);
@@ -747,6 +748,7 @@ main (int argc, char **argv)
count = 0;
gettimeofday (&tv_start, NULL);
+ tv_last = tv_start;
while (1) {
gio_status = g_io_channel_read_line (channel, &filename,
@@ -768,11 +770,18 @@ main (int argc, char **argv)
if (count % 1000 == 0) {
gettimeofday (&tv_now, NULL);
printf ("Indexed %d messages (%g messages/second)\n",
- count, count / ((tv_now.tv_sec - tv_start.tv_sec) +
- (tv_now.tv_usec - tv_start.tv_usec) / 1e6));
+ count, 1000 / ((tv_now.tv_sec - tv_last.tv_sec) +
+ (tv_now.tv_usec - tv_last.tv_usec) / 1e6));
+ tv_last = tv_now;
}
}
+ gettimeofday (&tv_now, NULL);
+ elapsed = (tv_now.tv_sec - tv_start.tv_sec +
+ (tv_now.tv_usec - tv_start.tv_usec) / 1e6);
+ printf ("Completed indexing of %d messages in %g seconds (%g messages/second)\n",
+ count, elapsed, count / elapsed);
+
} catch (const Xapian::Error &error) {
cerr << "A Xapian exception occurred: " << error.get_msg () << endl;
exit (1);