class ProgressReport – the code

class ProgressReport{
  int startTime,lastTime,end;
  String message;
  ProgressReport(int e,String m){    // task goes from 0 to e, m is a message
  void reset(){
  void report(int j){
    int time=millis();
    if(time-lastTime>2000){                // progress report every 2 seconds
      float progress=(j+0.1)/end;
      float restTime=(1.-progress)/progress*(time-startTime)*0.001;
      println(message+" done: "+(100*progress)+" %, remaining time: "+restTime+" seconds");
This entry was posted in programming and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.