Simulation progress and remaining time

Simple C++ class used for displaying simulation progress and remaining time.
Usage example:
#include "Progress_Timer.h"

#define MAX 5000000

int main()
{
tr::Progress_Timer timer;

timer.set_max(MAX);
timer.progress(0.0);
for (int i=0;i<MAX;i++)
{
//do something important
timer.progress(i+1);
}
timer.toc_print();
}
Program output:
0.0%
8.6% 11 sec remaining
18.8% 9 sec remaining
29.0% 7 sec remaining
39.2% 6 sec remaining
49.4% 5 sec remaining
59.7% 4 sec remaining
69.9% 3 sec remaining
80.1% 2 sec remaining
90.3% 1 sec remaining
100.0% 0 sec remaining
Elapsed time = 9 sec

ċ
Progress_Timer.h
(3k)
Cristea Bogdan,
Oct 31, 2009, 4:29 AM