public class Timing
extends java.lang.Object
Timing
class supports timing code fragments. A timer has a
name, which may be used for informational purposes, and a start time against
which the elapsed time is calculated.
The start time is first set to the time of instance creation and may later
be set to the current time using the reset()
method. The name of the
timer is also set at instance creation time and may be changed using the
setName(java.lang.String)
method.
The time elapsed since the last timer reset (either instance creation or
call to the reset()
method) is accessible through the
getElapsed()
and may be logged using the stamp(java.lang.String)
method.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_NAME
The defualt name for instances
|
Constructor and Description |
---|
Timing()
Creates an instance with the
default name . |
Timing(java.lang.String name)
Creates an instance with the given name.
|
Modifier and Type | Method and Description |
---|---|
long |
getElapsed()
Returns the time in milliseconds elapsed since the starting time.
|
java.lang.String |
getName()
Returns the name of this instance.
|
long |
getStartTime()
Returns the starting time of this instance.
|
void |
reset()
Resets the starting time of this instance to the current system time.
|
void |
setName(java.lang.String name)
Sets the name of this instance.
|
void |
stamp(java.lang.String message)
Writes the elapsed time to the timer log.
|
java.lang.String |
toString()
Returns a string representation of this instance, which consists of
the name and human readable form of the start time.
|
public static final java.lang.String DEFAULT_NAME
public Timing()
default name
. The
start time of the new instance is set to the time of instance creation.
Calling this method is equivalent to calling
new Timing(null)
DEFAULT_NAME
public Timing(java.lang.String name)
name
- The name of the new instance. If the name is empty or
null
, the name will be set to the
default name
.public java.lang.String getName()
public void setName(java.lang.String name)
name
- The new name to set on this instance. If the name is empty or
null
, the name will be set to the
default name
.public long getStartTime()
reset()
public void reset()
getStartTime
public long getElapsed()
reset()
,
getStartTime()
public void stamp(java.lang.String message)
The log message is logged as an informational message at level
INFO
to the logger misc.timing
.
message
- The message to be added to the log message.public java.lang.String toString()
toString
in class java.lang.Object
"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"