6 * Print a progress bar to stderr + elapsed time since execution
7 * Stolen from some of my Codejam stuff, but modified to actually print the correct times...
9 inline void ProgressBar(int64_t c, int64_t nCases, int len=20)
11 static timeval startTime;
12 static timeval thisTime;
13 static timeval lastTime;
14 static int64_t total_usec = 0;
15 gettimeofday(&thisTime, NULL);
24 fprintf(stderr, "\33[2K\r");
25 //fprintf(stderr, "\n");
29 for (i = 0; i < ((len*c)/nCases); ++i)
36 int64_t delta_usec = 1000000*(thisTime.tv_sec-lastTime.tv_sec) + (thisTime.tv_usec-lastTime.tv_usec);
37 total_usec += delta_usec;
39 int64_t ds = delta_usec / 1000000;
40 int64_t dus = delta_usec - 1000000*ds;
41 int64_t ts = total_usec / 1000000;
42 int64_t tus = total_usec - 1000000*ts;
44 fprintf(stderr, "] Case #%li: %02li:%02li.%06li Total: %02li:%02li.%06li| ", c,