00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "ProgressPrinter.h"
00019 #include "../thread/Timer.h"
00020
00021 namespace oasys {
00022
00026 ProgressPrinter::ProgressPrinter(const char* fmt, ...)
00027 {
00028 if (fmt) {
00029 va_list ap;
00030 va_start(ap, fmt);
00031 vprintf(fmt, ap);
00032 va_end(ap);
00033 fflush(stdout);
00034 }
00035
00036 ::gettimeofday(&start_, 0);
00037 }
00038
00042 void
00043 ProgressPrinter::start(const char* fmt, ...)
00044 {
00045 va_list ap;
00046 va_start(ap, fmt);
00047 vprintf(fmt, ap);
00048 va_end(ap);
00049 fflush(stdout);
00050
00051 ::gettimeofday(&start_, 0);
00052 }
00053
00058 void
00059 ProgressPrinter::done(const char* fmt, ...)
00060 {
00061 struct timeval end;
00062
00063 va_list ap;
00064 va_start(ap, fmt);
00065 vprintf(fmt, ap);
00066 va_end(ap);
00067
00068 ::gettimeofday(&end, 0);
00069 unsigned long elapsed = TIMEVAL_DIFF_MSEC(end, start_);
00070
00071 printf(" (%lu.%.3lu secs)\n", elapsed / 1000, (elapsed % 1000));
00072 }
00073
00074 }
00075