Index: main.c =================================================================== RCS file: /cvsroot/avrdude/avrdude/main.c,v retrieving revision 1.77 diff -u -r1.77 main.c --- main.c 29 Jul 2003 22:08:21 -0000 1.77 +++ main.c 30 Jul 2003 01:10:26 -0000 @@ -41,6 +41,7 @@ #include #include #include +#include #include "avr.h" #include "config.h" @@ -254,7 +255,7 @@ return; } -typedef void (*FP_UpdateProgress)(int percent, char *hdr); +typedef void (*FP_UpdateProgress)(int percent, double etime, char *hdr); static FP_UpdateProgress update_progress; @@ -277,14 +278,21 @@ void report_progress (int completed, int total, char *hdr) { static int last = 0; + static double start_time = 0; int percent = (completed * 100) / total; + struct timeval tv; + double t; if (update_progress == NULL) return; + gettimeofday(&tv, NULL); + t = tv.tv_sec + ((double)tv.tv_usec)/1000000; + if (hdr) { last = 0; - update_progress (percent, hdr); + start_time = t; + update_progress (percent, t - start_time, hdr); } if (percent > 100) @@ -292,14 +300,14 @@ if (percent > last) { last = percent; - update_progress (percent, hdr); + update_progress (percent, t - start_time, hdr); } if (percent == 100) last = 0; /* Get ready for next time. */ } -static void update_progress_tty (int percent, char *hdr) +static void update_progress_tty (int percent, double etime, char *hdr) { static char hashes[51]; static char *header; @@ -320,7 +328,8 @@ } if (last == 0) { - fprintf (stderr, "\r%s | %s | %d%%", header, hashes, percent); + fprintf(stderr, "\r%s | %s | %d%% %0.2fs", + header, hashes, percent, etime); } if (percent == 100) { @@ -329,7 +338,7 @@ } } -static void update_progress_no_tty (int percent, char *hdr) +static void update_progress_no_tty (int percent, double etime, char *hdr) { static int last = 0; int cnt = (percent>>1)*2; @@ -346,7 +355,7 @@ } if ((percent == 100) && (last != 0)) { - fprintf (stderr, " | 100%\n\n"); + fprintf (stderr, " | 100%% %0.2fs\n\n", etime); last = 0; } else