FileDocCategorySizeDatePackage
ProcessEstimator.javaAPI DocExample2115Wed May 18 09:39:02 BST 2005com.discursive.jccook.math.timeestimate

ProcessEstimator

public class ProcessEstimator extends Object

Fields Summary
private org.apache.commons.math.stat.regression.SimpleRegression
regression
private org.apache.commons.lang.time.StopWatch
stopWatch
private int
units
private int
completed
private int
sampleRate
Constructors Summary
public ProcessEstimator(int numUnits, int sampleRate)

	
	       
		this.units = numUnits;
		this.sampleRate = sampleRate;
	
Methods Summary
public intgetCompleted()

		return completed;
	
public longgetTimeSpent()

		return stopWatch.getTime();
	
public intgetUnits()

		return units;
	
public longprojectedFinish()

		return (long) regression.getIntercept();
	
public longprojectedTimeRemaining()

		long timeRemaining = projectedFinish() - getTimeSpent();		
		return timeRemaining;
	
public voidstart()

		stopWatch.start();
	
public voidstop()

		stopWatch.stop();
	
public voidunitCompleted()

		completed++;
		
		if( completed % sampleRate == 0 ) {
			long now = System.currentTimeMillis();
			regression.addData( units - completed, stopWatch.getTime());
		}