test
Class TimeProfiler

java.lang.Object
  extended by test.TimeProfiler

public class TimeProfiler
extends Object

TimeProfiler objects allow a programmer to profile the running time of his or her code. It abstracts away any calls to System.nanoTime() and also keeps a set of statistics to allow the programmer to check worst-case time, best-case time, and average time. TimeProfilers are mutable.

Specification Fields

Constructor Summary
TimeProfiler()
           
TimeProfiler(String name)
           
 
Method Summary
 void start()
          Starts the timer
 String stats()
          returns a formatted String with stats on slowest start-stop time, fastest start-stop time, average time, total records, and aggregate time
 void stop()
          Stops the timer and records the data.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TimeProfiler

public TimeProfiler()

TimeProfiler

public TimeProfiler(String name)
Method Detail

start

public void start()
Starts the timer

Effects:
turns on timing
Modifies:
this

stop

public void stop()
Stops the timer and records the data.

Requires:
(timing == true) which means this.start() called since last time stop() called
Effects:
turns off timing, updates worst,best, and average time based on this trial
Modifies:
this

stats

public String stats()
returns a formatted String with stats on slowest start-stop time, fastest start-stop time, average time, total records, and aggregate time


toString

public String toString()
Overrides:
toString in class Object