Class DbStatsStopWatch
-
- All Implemented Interfaces:
public final class DbStatsStopWatchStop watch that combines timing measurements with P6Spy query statistics.
Captures real JDBC execution times including result set processing by leveraging P6Spy event data.
Note: This object is not thread-safe and does not use synchronization.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classDbStatsStopWatch.TaskInfoData class to hold information about one task including query statistics.
-
Constructor Summary
Constructors Constructor Description DbStatsStopWatch(String id, Consumer<String> logFunction)DbStatsStopWatch(String id)DbStatsStopWatch()
-
Method Summary
Modifier and Type Method Description final UnitsetKeepTaskList(Boolean keepTaskList)Configure whether the TaskInfo array is built over time. final Unitstart()Start an unnamed task. final Unitstart(String taskName)Start a named task. final UnitstopAndStart(String taskName)Stops previous task (must be running) and starts a new one. final Unitstop()Stop the current task and capture P6Spy statistics. final BooleanisRunning()Determine whether this DbStatsStopWatch is currently running. final StringcurrentTaskName()Get the name of the currently running task, if any. final DbStatsStopWatch.TaskInfolastTaskInfo()Get the last task as a TaskInfo object. final Array<DbStatsStopWatch.TaskInfo>getTaskInfo()Get an array of the data for tasks performed. final IntegergetTaskCount()Get the number of tasks timed. final LonggetTotalTimeNanos()Get the total time for all tasks in nanoseconds. final LonggetTotalTimeMillis()Get the total time for all tasks in milliseconds. final DoublegetTotalTimeSeconds()Get the total time for all tasks in seconds. final DoublegetTotalTime(TimeUnit timeUnit)Get the total time for all tasks in the requested time unit. final StringprettyPrint()Generate a table describing all tasks performed in seconds with query statistics. final StringprettyPrint(TimeUnit timeUnit)Generate a table describing all tasks performed in the requested time unit with query statistics. final StringshortSummary()Get a short description of the total running time in seconds. StringtoString()Generate an informative string describing all tasks performed in seconds. -
-
Method Detail
-
setKeepTaskList
final Unit setKeepTaskList(Boolean keepTaskList)
Configure whether the TaskInfo array is built over time. Set this to false when using for millions of tasks to avoid excessive memory usage.
-
start
final Unit start(String taskName)
Start a named task. Marks the starting point for P6Spy query capture.
-
stopAndStart
final Unit stopAndStart(String taskName)
Stops previous task (must be running) and starts a new one.
-
currentTaskName
final String currentTaskName()
Get the name of the currently running task, if any.
-
lastTaskInfo
final DbStatsStopWatch.TaskInfo lastTaskInfo()
Get the last task as a TaskInfo object.
-
getTaskInfo
final Array<DbStatsStopWatch.TaskInfo> getTaskInfo()
Get an array of the data for tasks performed.
-
getTaskCount
final Integer getTaskCount()
Get the number of tasks timed.
-
getTotalTimeNanos
final Long getTotalTimeNanos()
Get the total time for all tasks in nanoseconds.
-
getTotalTimeMillis
final Long getTotalTimeMillis()
Get the total time for all tasks in milliseconds.
-
getTotalTimeSeconds
final Double getTotalTimeSeconds()
Get the total time for all tasks in seconds.
-
getTotalTime
final Double getTotalTime(TimeUnit timeUnit)
Get the total time for all tasks in the requested time unit.
-
prettyPrint
final String prettyPrint()
Generate a table describing all tasks performed in seconds with query statistics.
-
prettyPrint
final String prettyPrint(TimeUnit timeUnit)
Generate a table describing all tasks performed in the requested time unit with query statistics.
-
shortSummary
final String shortSummary()
Get a short description of the total running time in seconds.
-
-
-
-