Package net.sourceforge.pmd.benchmark
Class TimeTracker
- java.lang.Object
-
- net.sourceforge.pmd.benchmark.TimeTracker
-
public final class TimeTracker extends Object
A time tracker class to measure time spent on different sections of PMD analysis. The class is thread-aware, allowing to differentiate CPU and wall clock time.- Author:
- Juan MartÃn Sotuyo Dodero
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
bench(String label, Runnable runnable)
static <T> T
bench(String label, Supplier<T> runnable)
static void
finishThread()
Finishes tracking a thread.static void
initThread()
Initialize a thread, starting to track it's own time.static void
startGlobalTracking()
Starts global tracking.static TimedOperation
startOperation(TimedOperationCategory category)
Starts tracking an operation.static TimedOperation
startOperation(TimedOperationCategory category, String label)
Starts tracking an operation.static TimingReport
stopGlobalTracking()
Stops global tracking.
-
-
-
Method Detail
-
startGlobalTracking
public static void startGlobalTracking()
Starts global tracking. Allows tracking operations to take place and starts the wall clock. Must be called once PMD starts if tracking is desired, no tracking will be performed otherwise.
-
stopGlobalTracking
public static TimingReport stopGlobalTracking()
Stops global tracking. Stops the wall clock. All further operations will be treated as NOOP.- Returns:
- The timed data obtained through the run.
-
initThread
public static void initThread()
Initialize a thread, starting to track it's own time.
-
finishThread
public static void finishThread()
Finishes tracking a thread.
-
startOperation
public static TimedOperation startOperation(TimedOperationCategory category)
Starts tracking an operation.- Parameters:
category
- The category under which to track the operation.- Returns:
- The current timed operation being tracked.
-
startOperation
public static TimedOperation startOperation(TimedOperationCategory category, String label)
Starts tracking an operation.- Parameters:
category
- The category under which to track the operation.label
- A label to be added to the category. Allows to differentiate measures within a single category.- Returns:
- The current timed operation being tracked.
-
-