[makedumpfile PATCH 2/2] print_info: show the remaining time of dump progress
Atsushi Kumagai
ats-kumagai at wm.jp.nec.com
Wed Jun 7 00:06:07 PDT 2017
Hello Pingfan,
>If the dump progress is slow, it is better to show an estimate of
>remaining time of the progress to the user. The estimator simply uses
>the average speed to work.
I like it, thanks for your work.
I have a minor comment.
[snip]
> void
>-print_progress(const char *msg, unsigned long current, unsigned long end)
>+print_progress(const char *msg, unsigned long current, unsigned long end, struct timeval *start)
> {
> float progress;
> time_t tm;
> static time_t last_time = 0;
> static unsigned int lapse = 0;
> static const char *spinner = "/|\\-";
>+ struct timeval delta;
>+ double eta;
>+ char eta_msg[32] = "eta: ";
I thinks this "eta: " should be set in eta_to_human_short(), because...
> if (current < end) {
> tm = time(NULL);
>@@ -368,13 +388,19 @@ print_progress(const char *msg, unsigned long current, unsigned long end)
> } else
> progress = 100;
>
>+ if (start != NULL) {
>+ calc_delta(start, &delta);
>+ eta = delta.tv_sec + delta.tv_usec/1e6;
>+ eta = (100 - progress) * eta/progress;
>+ eta_to_human_short(eta, eta_msg+5);
the offset for "eta: " is here as a magic number.
It has low maintainability since the number is independent of
the actual string length.
Thanks,
Atsushi Kumagai
>+ }
> if (flag_ignore_r_char) {
>- PROGRESS_MSG("%-" PROGRESS_MAXLEN "s: [%5.1f %%] %c\n",
>- msg, progress, spinner[lapse % 4]);
>+ PROGRESS_MSG("%-" PROGRESS_MAXLEN "s: [%5.1f %%] %c %16s\n",
>+ msg, progress, spinner[lapse % 4], eta_msg);
> } else {
> PROGRESS_MSG("\r");
>- PROGRESS_MSG("%-" PROGRESS_MAXLEN "s: [%5.1f %%] %c",
>- msg, progress, spinner[lapse % 4]);
>+ PROGRESS_MSG("%-" PROGRESS_MAXLEN "s: [%5.1f %%] %c %16s",
>+ msg, progress, spinner[lapse % 4], eta_msg);
> }
> lapse++;
> }
>diff --git a/print_info.h b/print_info.h
>index 01e3706..1ce3593 100644
>--- a/print_info.h
>+++ b/print_info.h
>@@ -25,7 +25,8 @@ extern int flag_ignore_r_char;
>
> void show_version(void);
> void print_usage(void);
>-void print_progress(const char *msg, unsigned long current, unsigned long end);
>+void print_progress(const char *msg, unsigned long current, unsigned long end, struct timeval *start);
>+
> void print_execution_time(char *step_name, struct timeval *tv_start);
>
> /*
>--
>2.7.4
>
>
>_______________________________________________
>kexec mailing list
>kexec at lists.infradead.org
>http://lists.infradead.org/mailman/listinfo/kexec
More information about the kexec
mailing list