You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by jo...@locus.apache.org on 2000/12/04 05:24:35 UTC

cvs commit: jakarta-velocity/src/java/org/apache/velocity/util Timer.java

jon         00/12/03 20:24:35

  Modified:    src/java/org/apache/velocity/util Timer.java
  Log:
  removed tabs
  
  Revision  Changes    Path
  1.2       +78 -78    jakarta-velocity/src/java/org/apache/velocity/util/Timer.java
  
  Index: Timer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/util/Timer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Timer.java	2000/12/04 04:22:35	1.1
  +++ Timer.java	2000/12/04 04:24:34	1.2
  @@ -60,85 +60,85 @@
   import java.util.*;
   
   /**
  -	A stopwatch class. Measures real time in milliseconds.
  +    A stopwatch class. Measures real time in milliseconds.
   */
   public class Timer
   {
  -	Date		startTime;
  -	double	seconds;
  -	double	totalSeconds;
  -
  -	/**
  -		Creates a new timer. The timer does not start running until start is called.
  -	*/
  -	public Timer()
  -	{
  -		reset();
  -	}
  -
  -	/**
  -		Returns the time between start and stop. If the timer is running, it returns
  -		the time since start was called.
  -	*/
  -	public double getSeconds()
  -	{
  -		return seconds + calcTime();
  -	}
  -
  -	/**
  -		Returns the total time spent running since the timer was created. Useful for
  -		aggregating several invocations of start & stop.
  -	*/
  -	public double getTotalSeconds()
  -	{
  -		return totalSeconds + calcTime();
  -	}
  -
  -	/**
  -		Resets the timer. Both seconds and total seconds are cleared.
  -	*/
  -	public void reset()
  -	{
  -		startTime = null;
  -		seconds = 0;
  -		totalSeconds = 0;
  -	}
  -
  -	/**
  -		Starts the timer.
  -	*/
  -	public void start()
  -	{
  -		if (timerRunning())
  -			return;
  -		startTime = new Date();
  -	}
  -
  -	/**
  -		Stops the timer.
  -	*/
  -	public void stop()
  -	{
  -		if (!timerRunning())
  -			return;
  -		seconds = calcTime();
  -		totalSeconds += seconds;
  -		startTime = null;
  -	}
  -
  -	/**
  -		Returns true if the timer is running.
  -	*/
  -	public boolean timerRunning()
  -	{
  -		return (startTime != null);
  -	}
  -
  -	double calcTime()
  -	{
  -		if (!timerRunning())
  -			return 0.0;
  -		Date now = new Date();
  -		return (now.getTime() - startTime.getTime()) / 1000.0;
  -	}
  +    Date        startTime;
  +    double  seconds;
  +    double  totalSeconds;
  +
  +    /**
  +        Creates a new timer. The timer does not start running until start is called.
  +    */
  +    public Timer()
  +    {
  +        reset();
  +    }
  +
  +    /**
  +        Returns the time between start and stop. If the timer is running, it returns
  +        the time since start was called.
  +    */
  +    public double getSeconds()
  +    {
  +        return seconds + calcTime();
  +    }
  +
  +    /**
  +        Returns the total time spent running since the timer was created. Useful for
  +        aggregating several invocations of start & stop.
  +    */
  +    public double getTotalSeconds()
  +    {
  +        return totalSeconds + calcTime();
  +    }
  +
  +    /**
  +        Resets the timer. Both seconds and total seconds are cleared.
  +    */
  +    public void reset()
  +    {
  +        startTime = null;
  +        seconds = 0;
  +        totalSeconds = 0;
  +    }
  +
  +    /**
  +        Starts the timer.
  +    */
  +    public void start()
  +    {
  +        if (timerRunning())
  +            return;
  +        startTime = new Date();
  +    }
  +
  +    /**
  +        Stops the timer.
  +    */
  +    public void stop()
  +    {
  +        if (!timerRunning())
  +            return;
  +        seconds = calcTime();
  +        totalSeconds += seconds;
  +        startTime = null;
  +    }
  +
  +    /**
  +        Returns true if the timer is running.
  +    */
  +    public boolean timerRunning()
  +    {
  +        return (startTime != null);
  +    }
  +
  +    double calcTime()
  +    {
  +        if (!timerRunning())
  +            return 0.0;
  +        Date now = new Date();
  +        return (now.getTime() - startTime.getTime()) / 1000.0;
  +    }
   }