public interface Timing
extends java.io.Closeable
These are normally created using Profiler.step(String)
.
Timing instances should always have stop()
called on
them. If at all possible, this should be in a finally block just
after the creation of the timing like so:
Timing timing = profilerProvider.current().step("some thing"); try { // do stuff here } finally { timing.stop(); }
or, since the timings implements Closeable
, you can use
Java 7 ARM blocks:
try(Timing timing = profilerProvider.current().step("some thing")) { // do stuff here } // automatically closed!
Modifier and Type | Method and Description |
---|---|
Profiler |
addChildProfiler(java.lang.String name)
Adds a child profiler under this step
|
void |
addCustomTiming(java.lang.String type,
java.lang.String executeType,
java.lang.String command,
long duration)
Add a custom timing to this timing.
|
void |
close()
Same as calling
stop() . |
CustomTiming |
customTiming(java.lang.String type,
java.lang.String executeType,
java.lang.String command)
Starts a custom timing under this timing.
|
<T> T |
customTiming(java.lang.String type,
java.lang.String executeType,
java.lang.String command,
java.util.concurrent.Callable<T> function)
Start and stop a new custom timing with the given callable function.
|
void |
customTiming(java.lang.String type,
java.lang.String executeType,
java.lang.String command,
java.lang.Runnable block)
Start and stop a new custom timing with the given block.
|
java.util.List<Profiler> |
getChildProfilers()
Returns child profilers of this timing
|
java.util.List<Timing> |
getChildren()
Returns all child timings of this timing
|
java.util.Map<java.lang.String,java.util.List<CustomTiming>> |
getCustomTimings()
Returns custom timings
|
int |
getDepth()
How many hops from the root timing
|
java.lang.Long |
getDurationMilliseconds()
Returned the length of this timing event
|
java.lang.String |
getName()
Returns the name of the timing
|
Timing |
getParent()
Returns the parent timing of this one.
|
long |
getStartMilliseconds()
Returns the start time of this timing in ms since profiler start
|
void |
setName(java.lang.String name)
Allows changing the name of the timing step after creation.
|
void |
stop()
Stops the timing step.
|
void stop()
java.lang.String getName()
void setName(java.lang.String name)
name
- new name of the timing stepTiming getParent()
void close()
stop()
.
Here to satisfy Closeable
and mark the method as not throwing a checked exception.
close
in interface java.lang.AutoCloseable
close
in interface java.io.Closeable
long getStartMilliseconds()
java.lang.Long getDurationMilliseconds()
stop()
method
was never calledint getDepth()
java.util.Map<java.lang.String,java.util.List<CustomTiming>> getCustomTimings()
java.util.List<Timing> getChildren()
void addCustomTiming(java.lang.String type, java.lang.String executeType, java.lang.String command, long duration)
type
- type of timing, e.g. "sql"executeType
- what type of execution, e.g. "query"command
- e.g. "select * from foo"duration
- how long the command tookCustomTiming customTiming(java.lang.String type, java.lang.String executeType, java.lang.String command)
The custom timing will not have a duration until CustomTiming.stop()
is called on the returned object.
type
- type of timing, e.g. "sql"executeType
- what type of execution, e.g. "query"command
- e.g. "select * from foo"void customTiming(java.lang.String type, java.lang.String executeType, java.lang.String command, java.lang.Runnable block)
type
- type of timing, e.g. "sql"executeType
- what type of execution, e.g. "query"command
- e.g. "select * from foo"block
- the code to run<T> T customTiming(java.lang.String type, java.lang.String executeType, java.lang.String command, java.util.concurrent.Callable<T> function) throws java.lang.Exception
T
- the return type of the functiontype
- type of timing, e.g. "sql"executeType
- what type of execution, e.g. "query"command
- e.g. "select * from foo"function
- The function to timejava.lang.Exception
- when the function throws an exceptionProfiler addChildProfiler(java.lang.String name)
name
- the name of the profilerjava.util.List<Profiler> getChildProfilers()