Package net.brdloush.dbstopwatch
Class DbStopWatch
java.lang.Object
net.brdloush.dbstopwatch.DbStopWatch
Stop 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 ClassesModifier and TypeClassDescriptionstatic classData class to hold information about one task including query statistics. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidfinish()Stops previous task (if running) and pretty prints to logFunction (if specified)Get the name of the currently running task, if any.Get the last task as a TaskInfo object.intGet the number of tasks timed.Get an array of the data for tasks performed.doublegetTotalTime(TimeUnit timeUnit) Get the total time for all tasks in the requested time unit.longGet the total time for all tasks in milliseconds.longGet the total time for all tasks in nanoseconds.doubleGet the total time for all tasks in seconds.booleanDetermine whether this DbStopWatch is currently running.Generate a table describing all tasks performed in seconds with query statistics.prettyPrint(TimeUnit timeUnit) Generate a table describing all tasks performed in the requested time unit with query statistics.voidsetKeepTaskList(boolean keepTaskList) Configure whether the TaskInfo array is built over time.Get a short description of the total running time in seconds.voidstart()Start an unnamed task.voidStart a named task.voidstop()Stop the current task and capture P6Spy statistics.voidstopAndStart(String taskName) Stops previous task (must be running) and starts a new one.toString()Generate an informative string describing all tasks performed in seconds.
-
Constructor Details
-
DbStopWatch
public DbStopWatch() -
DbStopWatch
-
DbStopWatch
-
DbStopWatch
-
-
Method Details
-
setKeepTaskList
public void 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
public void start()Start an unnamed task. -
start
Start a named task. Marks the starting point for P6Spy query capture. -
stopAndStart
Stops previous task (must be running) and starts a new one. -
finish
public void finish()Stops previous task (if running) and pretty prints to logFunction (if specified) -
stop
public void stop()Stop the current task and capture P6Spy statistics. -
isRunning
public boolean isRunning()Determine whether this DbStopWatch is currently running. -
getCurrentTaskName
Get the name of the currently running task, if any. -
getLastTaskInfo
Get the last task as a TaskInfo object. -
getTaskInfo
Get an array of the data for tasks performed. -
getTaskCount
public int getTaskCount()Get the number of tasks timed. -
getTotalTimeNanos
public long getTotalTimeNanos()Get the total time for all tasks in nanoseconds. -
getTotalTimeMillis
public long getTotalTimeMillis()Get the total time for all tasks in milliseconds. -
getTotalTimeSeconds
public double getTotalTimeSeconds()Get the total time for all tasks in seconds. -
getTotalTime
Get the total time for all tasks in the requested time unit. -
prettyPrint
Generate a table describing all tasks performed in seconds with query statistics. -
prettyPrint
Generate a table describing all tasks performed in the requested time unit with query statistics. -
shortSummary
Get a short description of the total running time in seconds. -
toString
Generate an informative string describing all tasks performed in seconds.
-