"

2013 FRC Java API

"

com.sun.squawk.util
Class ComputationTimer

java.lang.Object
  extended by com.sun.squawk.util.ComputationTimer

public final class ComputationTimer
extends Object

This is a singleton class that provides support for timing computations, including nested computations.


Nested Class Summary
static interface ComputationTimer.Computation
          A computation to be timed that does not throw a checked exception.
static interface ComputationTimer.ComputationException
          A computation to be timed that throws a checked exception.
 
Method Summary
static void dump(PrintStream out)
          Print a summary of the times.
static Enumeration getComputations()
          Gets an enumeration over the identifiers of computations for which times were collected.
static Enumeration getFlatTimes()
          Gets an enumeration over the collected flat times.
static Enumeration getTotalTimes()
          Gets an enumeration over the collected accumulative times.
static void reset()
          Resets all the data gathered by the timer.
static Object time(String id, ComputationTimer.Computation computation)
          Time a specified computation denoted by a specified identifier.
static Object time(String id, ComputationTimer.ComputationException computation)
          Time a specified computation denoted by a specified identifier.
static String timesAsString()
          Returns a string representation of the times accumulated by the timer in the form of a set of entries, enclosed in braces and separated by the ASCII characters ", " (comma and space).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

time

public static Object time(String id,
                          ComputationTimer.Computation computation)
Time a specified computation denoted by a specified identifier. The time taken to perform the computation is added to the accumulative time to perform all computations with the same identifier.

Parameters:
id - the identifier for the computation
computation - the computation to be performed and timed
Returns:
the result of the computation

time

public static Object time(String id,
                          ComputationTimer.ComputationException computation)
                   throws Exception
Time a specified computation denoted by a specified identifier. The time taken to perform the computation is added to the accumulative time to perform all computations with the same identifier.

Parameters:
id - the identifier for the computation
computation - the computation to be performed and timed
Returns:
the result of the computation.
Throws:
Exception

getComputations

public static Enumeration getComputations()
Gets an enumeration over the identifiers of computations for which times were collected.

Returns:
an enumeration over the identifiers of computations for which times were collected

getFlatTimes

public static Enumeration getFlatTimes()
Gets an enumeration over the collected flat times.

Returns:
an enumeration over the collected flat times

getTotalTimes

public static Enumeration getTotalTimes()
Gets an enumeration over the collected accumulative times.

Returns:
an enumeration over the collected accumulative times

reset

public static void reset()
Resets all the data gathered by the timer.

Throws:
IllegalStateException - if there is an execution currently being timed

timesAsString

public static String timesAsString()
Returns a string representation of the times accumulated by the timer in the form of a set of entries, enclosed in braces and separated by the ASCII characters ", " (comma and space). Each entry is rendered as the computation identifier, a colon sign ':', the total time associated with the computation, a colon sign ':' and the flat time associated with the computation.

Returns:
a string representation of the collected times

dump

public static void dump(PrintStream out)
Print a summary of the times.

Parameters:
out - PrintStream

"

2013 FRC Java API

"

"
For updated information see the Java FRC site
"