Skip to content

Commit

Permalink
added method for retrieving rate
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinmilner committed Oct 19, 2017
1 parent 4b93673 commit 5782d5b
Showing 1 changed file with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,33 @@ public String getCountsString() {
return "running="+getNumRunning()+", queued="+getNumQueued()+", finished="+getNumFinished();
}

/**
* @return average runtime in milliseconds of the post-processing for each task processed
* thus far, or NaN if no batches finished processing. Threading effects ignored.
*/
public double getAverageTaskDurationMillis() {
double finished = getNumFinished();
if (finished == 0)
return Double.NaN;
return (double)millisSpent/finished;
}

/**
* @return String representation of processing rate and (if applicable) time estimates
* for running and queued batches.
*/
public String getRatesString() {
String str = "rate: ";
if (getNumFinished() > 0) {
str += Utils.smartRatePrint(getNumFinished(), millisSpent);
double millisPerTask = (double)millisSpent/(double)getNumFinished();
double millisPerTask = getAverageTaskDurationMillis();
if (getNumRunning() > 0) {
double millis = getNumRunning() * millisPerTask;
str += ", time for running: ~"+Utils.smartTimePrint(millis);
str += ", time for running: "+Utils.smartTimePrint(millis);
}
if (getNumQueued() > 0) {
double millis = getNumQueued() * millisPerTask;
str += ", time for queue: ~"+Utils.smartTimePrint(millis);
str += ", time for queue: "+Utils.smartTimePrint(millis);
}
} else {
str += "n/a";
Expand Down

0 comments on commit 5782d5b

Please sign in to comment.