public class OperationTime
extends java.lang.Object
SqlOperation
. The exception
times that may be recorded are prepare (JDBC prepare), write (setting column and where
parameters), execute (JDBC execute), and read (reading result set values into row objects).
A total time is the sum of all prepare, write, execute, and read times.
An optional parentOperationTime can be set used to hold sub-totals of more than on OperationTime.
This class is not thread safe. If more than one thread will be updating times, then synchronize for proper results.
Constructor and Description |
---|
OperationTime(java.lang.String timingId)
Constructs for a timing id.
|
OperationTime(java.lang.String timingId,
OperationTime parentOperationTime)
Constructs for a timing id and a parent summary.
|
Modifier and Type | Method and Description |
---|---|
void |
cancel()
Cancels recording active time.
|
protected java.lang.String |
format(ElapsedTime et)
Formats an
ElapsedTime into a standard format. |
java.lang.String |
getDescription() |
ElapsedTime |
getExecuteTime() |
ElapsedTime |
getPrepareTime() |
ElapsedTime |
getReadTime() |
java.lang.String |
getTimingId() |
ElapsedTime |
getTotalTime() |
ElapsedTime |
getWriteTime() |
void |
logTimings()
Writes prepare, write, execute, and read time to log along with average, total, and percent.
|
void |
pause()
Stops recording the currently active time until
resume() is invoked. |
void |
resume()
Starts recording the active time that was paused.
|
void |
setDescription(java.lang.String description)
Sets description for timings that are logged with
logTimings() . |
protected void |
start(ElapsedTime et)
Starts recording an elapsed time.
|
void |
startExecuteTime()
Starts recording execute time.
|
void |
startPrepareTime()
Starts recording prepare time.
|
void |
startReadTime()
Starts recording read time.
|
void |
startWriteTime()
Starts recording write time.
|
void |
stop()
Stops recording the active time that was started with one of the start methods.
|
void |
updateSource(java.lang.StackTraceElement stackTraceElement)
Records stack trace information and count where timing is initiated.
|
public OperationTime(java.lang.String timingId)
timingId
- a String that uniquely identifies a set of timingspublic OperationTime(java.lang.String timingId, OperationTime parentOperationTime)
timingId
- a String that uniquely identifies a set of timingsparentOperationTime
- an operation time that will record timings; null for nonepublic java.lang.String getTimingId()
public java.lang.String getDescription()
setDescription(String)
public void setDescription(java.lang.String description)
logTimings()
. A good description
to use would be SqlOperation.getSql()
.description
- human readable label for timings when they are loggedpublic void startPrepareTime()
stop()
to stop recording.public void startWriteTime()
stop()
to stop recording.public void startExecuteTime()
stop()
to stop recording.public void startReadTime()
stop()
to stop recording.protected void start(ElapsedTime et)
cancel()
, stop()
, pause()
, and resume()
act upon the active time.et
- elapsed time to startpublic void stop()
public void cancel()
public void pause()
resume()
is invoked. Zero
or more pause/resume pairs may be invoked.public void resume()
public ElapsedTime getPrepareTime()
public ElapsedTime getWriteTime()
public ElapsedTime getExecuteTime()
public ElapsedTime getReadTime()
public ElapsedTime getTotalTime()
public void updateSource(java.lang.StackTraceElement stackTraceElement)
stackTraceElement
- the location on the stack where operation was initiatedpublic void logTimings()
protected java.lang.String format(ElapsedTime et)
ElapsedTime
into a standard format.et
- elapsed time to format