Package org.apache.jackrabbit.oak.stats
Class StopwatchLogger
- java.lang.Object
-
- org.apache.jackrabbit.oak.stats.StopwatchLogger
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class StopwatchLogger extends java.lang.Object implements java.io.Closeable
Utility class to be used for tracking of timing within methods. It makes use of theClock.Fast
for speeding up the operation.
-
-
Constructor Summary
Constructors Constructor Description StopwatchLogger(@NotNull java.lang.Class<?> clazz)
instantiate a class with the provided classStopwatchLogger(@NotNull java.lang.String clazz)
Create a class with the provided class.StopwatchLogger(@Nullable Logger customLog, @NotNull java.lang.Class<?> clazz)
Instantiate a class with the provided class and custom logger.StopwatchLogger(@Nullable Logger customLog, @NotNull java.lang.String clazz)
Instantiate a class with the provided class and custom logger.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
boolean
isEnabled()
boolean
isStarted()
void
split(@Nullable java.lang.String message)
track of an intermediate time without stopping the ticking.void
start()
starts the clockvoid
stop(@Nullable java.lang.String message)
track the time and stop the clock.
-
-
-
Constructor Detail
-
StopwatchLogger
public StopwatchLogger(@NotNull @NotNull java.lang.String clazz)
Create a class with the provided class.- Parameters:
clazz
-
-
StopwatchLogger
public StopwatchLogger(@NotNull @NotNull java.lang.Class<?> clazz)
instantiate a class with the provided class- Parameters:
clazz
-
-
StopwatchLogger
public StopwatchLogger(@Nullable @Nullable Logger customLog, @NotNull @NotNull java.lang.Class<?> clazz)
Instantiate a class with the provided class and custom logger. The provided logger, if not null, will be then used for tracking down times- Parameters:
customLog
-clazz
-
-
StopwatchLogger
public StopwatchLogger(@Nullable @Nullable Logger customLog, @NotNull @NotNull java.lang.String clazz)
Instantiate a class with the provided class and custom logger. The provided logger, if not null, will be then used for tracking down times- Parameters:
customLog
-clazz
-
-
-
Method Detail
-
start
public void start()
starts the clock
-
split
public void split(@Nullable @Nullable java.lang.String message)
track of an intermediate time without stopping the ticking.- Parameters:
message
-
-
stop
public void stop(@Nullable @Nullable java.lang.String message)
track the time and stop the clock.- Parameters:
message
-
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
isStarted
public boolean isStarted()
- Returns:
- true if the clock has been started. False otherwise.
-
isEnabled
public boolean isEnabled()
- Returns:
- true whether the provided appender has DEBUG enabled and therefore asked to track times.
-
-