com.partnersoft.gadgets
Class StopWatch

java.lang.Object
  extended by com.partnersoft.gadgets.StopWatch

public class StopWatch
extends java.lang.Object

A basic stopwatch; handy for testing and such.

Author:
Paul Reavis Copyright 1998 Partner Software, Inc.

Constructor Summary
StopWatch()
           
 
Method Summary
 double getAverage()
          Get the average time for all runs.
 java.lang.String getAverageString()
          Get the average time for all runs as a formatted string.
 long getCurrentTime()
          Get the time since last start.
 java.lang.String getCurrentTimeString()
          Get the time since last start as a formatted string.
 long getLastTime()
          Get the last timing run.
 java.lang.String getLastTimeString()
          Get the last timing run as a formatted string.
 java.lang.String getMemoryUsageString()
          Handy; reports memory usage as a string.
 int getNumRuns()
          Get the number of timing runs.
 double getRecentAverage()
           
 long getTotalTime()
          Get the total of all timing runs.
 java.lang.String getTotalTimeString()
          Get the total of all timing runs as a formatted string.
 boolean isRunning()
          True if watch is running.
static double millisToHertz(double millis)
          Converts millisecond timing to runs per second.
static double millisToSeconds(double millis)
          Converts milliseconds to thousandths of a second.
static java.lang.String millisToString(long millis)
           
 void reset()
          Reset everything.
 void start()
          Start the clock.
 void stop()
          Stop the clock.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StopWatch

public StopWatch()
Method Detail

millisToString

public static java.lang.String millisToString(long millis)

millisToSeconds

public static double millisToSeconds(double millis)
Converts milliseconds to thousandths of a second.


millisToHertz

public static double millisToHertz(double millis)
Converts millisecond timing to runs per second.


start

public void start()
Start the clock.


stop

public void stop()
Stop the clock.


getLastTime

public long getLastTime()
Get the last timing run. If you've buggered up stops and starts that's your lookout.


getLastTimeString

public java.lang.String getLastTimeString()
Get the last timing run as a formatted string. If you've buggered up stops and starts that's your lookout.


getTotalTime

public long getTotalTime()
Get the total of all timing runs.


getTotalTimeString

public java.lang.String getTotalTimeString()
Get the total of all timing runs as a formatted string.


getCurrentTime

public long getCurrentTime()
Get the time since last start.


getCurrentTimeString

public java.lang.String getCurrentTimeString()
Get the time since last start as a formatted string.


getNumRuns

public int getNumRuns()
Get the number of timing runs.


getAverage

public double getAverage()
Get the average time for all runs.


getAverageString

public java.lang.String getAverageString()
Get the average time for all runs as a formatted string.


reset

public void reset()
Reset everything.


isRunning

public boolean isRunning()
True if watch is running.


getMemoryUsageString

public java.lang.String getMemoryUsageString()
Handy; reports memory usage as a string.


getRecentAverage

public double getRecentAverage()