de.folt.util
Class Timer

java.lang.Object
  extended by de.folt.util.Timer

public class Timer
extends java.lang.Object

This class implements a timer for measuring the time need for operations. A timer can be started, stopped an continued.

 Timer timer = new Timer();
 timer.start();
 timer.stop();
 timer.continue();
 
 ...
 

Author:
klemens

Constructor Summary
Timer()
          creates a times
 
Method Summary
 void continueTimer()
          continueTimer continues a stopped timer
 void endTimer()
          endTimer sets the end time of timer at the current time.
 long getContinueTime()
           
 long getDeductTime()
           
 long getEndTime()
           
 long getStartTime()
           
 long getStopTime()
           
 void setContinueTime(long continueTime)
           
 void setDeductTime(long deductTime)
           
 void setEndTime(long endTime)
           
 void setStartTime(long startTime)
           
 void setStopTime(long stopTime)
           
 void startTimer()
          startTimer starts a timers
 void stopTimer()
          stopTimer stops a timer
 long timeNeeded()
          timeNeeded
 java.lang.String timerString(java.lang.String string)
          timerString returns a formatted timer string:
Format produced:
str = "Time needed for " + string + " " + timeneeded + " ms (" + seconds + " sec/" + minutes + " min)";
 java.lang.String timerString(java.lang.String string, long iCount)
          timerString returns a formatted timer string.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Timer

public Timer()
creates a times

Method Detail

continueTimer

public void continueTimer()
continueTimer continues a stopped timer


endTimer

public void endTimer()
endTimer sets the end time of timer at the current time.


getContinueTime

public long getContinueTime()
Returns:
Returns the continueTime.

getDeductTime

public long getDeductTime()
Returns:
Returns the deductTime.

getEndTime

public long getEndTime()
Returns:
Returns the endTime.

getStartTime

public long getStartTime()
Returns:
Returns the startTime.

getStopTime

public long getStopTime()
Returns:
Returns the stopTime.

setContinueTime

public void setContinueTime(long continueTime)
Parameters:
continueTime - The continueTime to set.

setDeductTime

public void setDeductTime(long deductTime)
Parameters:
deductTime - The deductTime to set.

setEndTime

public void setEndTime(long endTime)
Parameters:
endTime - The endTime to set.

setStartTime

public void setStartTime(long startTime)
Parameters:
startTime - The startTime to set.

setStopTime

public void setStopTime(long stopTime)
Parameters:
stopTime - The stopTime to set.

startTimer

public void startTimer()
startTimer starts a timers


stopTimer

public void stopTimer()
stopTimer stops a timer


timeNeeded

public long timeNeeded()
timeNeeded

Returns:

timerString

public java.lang.String timerString(java.lang.String string)
timerString returns a formatted timer string:
Format produced:
 str = "Time needed for " + string + " " + timeneeded + " ms (" + seconds + " sec/" + minutes + " min)";
 

Parameters:
string - description string to add
Returns:
the formatted timer string:

timerString

public java.lang.String timerString(java.lang.String string,
                                    long iCount)
timerString returns a formatted timer string. The parameter iCount is used to determine the average time a number (iCount) of operations needed per operation (e.g. for determining the average time for loading 1000 MonoLingualObjects from a database.
Format produced:
 str = "Time needed for " + string + " " + timeneeded + " ms (" + seconds + " sec/" + minutes + " min) for " + iCount + " operations. Average was " + average + " ms. ";
 

Parameters:
string - the description string to add
iCount - the number of operations for which the mean operation time should be computed.
Returns:
the formatted timer string