Class org.as2lib.util.StopWatch

org.as2lib.core.BasicClass
   +--org.as2lib.util.StopWatch

Description

Stopwatch stops the time.

Instantiate this class as follows: import org.as2lib.util.StopWatch; var stopWatch:StopWatch = new StopWatch();

This will create a still standing stopwatch. You can start and stop the stopwatch to record time as you please. stopWatch.start(); // Do something stopWatch.stop();

The recored time is available in milliseconds and seconds. trace(stopWatch.getTimeInMilliSeconds() + " ms"); trace(stopWatch.getTimeInSeconds() + " s");

Method Index

new StopWatch()

getTimeInMilliSeconds(), getTimeInSeconds(), hasStarted(), reset(), start(), stop(), toString()

Constructor Detail

StopWatch

public function StopWatch(Void)

Constructs a new StopWatch instance.

Method Detail

start

public function start(Void):Void

Starts the time recording process.

Throws

IllegalStateExceptionif the stopwatch has already been started

stop

public function stop(Void):Void

Stops the time recording process if the process has been started before.

Throws

IllegalStateExceptionif the stopwatch has not been already started

hasStarted

public function hasStarted(Void):Boolean

Returns whether this stopwatch has been started.

Return

true if this stopwatch has been started else false

reset

public function reset(Void):Void

Resets the stopwatch total running time.

getTimeInMilliSeconds

public function getTimeInMilliSeconds(Void):Number

Calculates and returns the elapsed time in milliseconds.

This stopwatch will not be stopped by calling this method. If this stopwatch is still running it takes the current time as stoptime for the result.

Return

the elapsed time in milliseconds

getTimeInSeconds

public function getTimeInSeconds(Void):Number

Calculates and returns the elapsed time in seconds.

This stopwatch will not be stopped by calling this method. If this stopwatch is still running it takes the current time as stoptime for the result.

Return

the elapsed time in seconds

toString

public function toString():String

Generates a string representation of this stopwatch that includes all start and stop times in milliseconds.

Return

the string representation of this stopwatch

Specified By

toString() in org.as2lib.core.BasicInterface

Overrides

toString() in org.as2lib.core.BasicClass