Package cern.colt
Class Timer
java.lang.Object
cern.colt.PersistentObject
cern.colt.Timer
- All Implemented Interfaces:
Serializable,Cloneable
A handy stopwatch for benchmarking.
Like a real stop watch used on ancient running tracks you can start the watch, stop it,
start it again, stop it again, display the elapsed time and reset the watch.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate longprivate longprivate static final longFields inherited from class cern.colt.PersistentObject
serialVersionUID -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondisplay()Prints the elapsed time on System.outfloatSame as seconds().longmillis()Returns the elapsed time in milli seconds; does not stop the timer, if started.T = this - other; Constructs and returns a new timer which is the difference of the receiver and the other timer.floatminutes()Returns the elapsed time in minutes; does not stop the timer, if started.T = this + other; Constructs and returns a new timer which is the sum of the receiver and the other timer.reset()Resets the timer.floatseconds()Returns the elapsed time in seconds; does not stop the timer, if started.start()Starts the timer.stop()Stops the timer.static voidtest(int size) Shows how to use a timer in convenient ways.toString()Returns a String representation of the receiver.Methods inherited from class cern.colt.PersistentObject
clone
-
Field Details
-
baseTime
private long baseTime -
elapsedTime
private long elapsedTime -
UNIT
private static final long UNIT- See Also:
-
-
Constructor Details
-
Timer
public Timer()Constructs a new timer, initially not started. Use start() to start the timer.
-
-
Method Details
-
display
Prints the elapsed time on System.out- Returns:
- this (for convenience only).
-
elapsedTime
public float elapsedTime()Same as seconds(). -
millis
public long millis()Returns the elapsed time in milli seconds; does not stop the timer, if started. -
minus
T = this - other; Constructs and returns a new timer which is the difference of the receiver and the other timer. The new timer is not started.- Parameters:
other- the timer to subtract.- Returns:
- a new timer.
-
minutes
public float minutes()Returns the elapsed time in minutes; does not stop the timer, if started. -
plus
T = this + other; Constructs and returns a new timer which is the sum of the receiver and the other timer. The new timer is not started.- Parameters:
other- the timer to add.- Returns:
- a new timer.
-
reset
Resets the timer.- Returns:
- this (for convenience only).
-
seconds
public float seconds()Returns the elapsed time in seconds; does not stop the timer, if started. -
start
Starts the timer.- Returns:
- this (for convenience only).
-
stop
Stops the timer. You can start it again later, if necessary.- Returns:
- this (for convenience only).
-
test
public static void test(int size) Shows how to use a timer in convenient ways. -
toString
Returns a String representation of the receiver.
-