Package net.obvj.performetrics
Class UnmodifiableTimingSession
- java.lang.Object
-
- net.obvj.performetrics.TimingSession
-
- net.obvj.performetrics.UnmodifiableTimingSession
-
public final class UnmodifiableTimingSession extends TimingSession
A "wrapper" class that allows retrieving values from an existing
TimingSessionbut prevents users from modifying it.- Since:
- 2.4.0
- Author:
- oswaldo.bapvic.jr
- See Also:
TimingSession
-
-
Constructor Summary
Constructors Constructor Description UnmodifiableTimingSession(TimingSession timingSession)Creates an unmodifiable object for a presetTimingSession.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DurationelapsedTime(Counter.Type type)A convenient method that returns the elapsed time of a specific counter.doubleelapsedTime(Counter.Type type, TimeUnit timeUnit)A convenient method that returns the elapsed time of a specific counter, in the specified time unit.doubleelapsedTime(Counter.Type type, TimeUnit timeUnit, ConversionMode conversionMode)A convenient method that returns the elapsed time of a specific counter, in the specified time unit, by applying a customConversionMode.booleanisStarted()Returnstrueif this timing session is started.voidreset()Resets all counters associated with this timing session.voidstart()Starts the timing session.voidstop()Stops the timing session.
-
-
-
Constructor Detail
-
UnmodifiableTimingSession
public UnmodifiableTimingSession(TimingSession timingSession)
Creates an unmodifiable object for a presetTimingSession.- Parameters:
timingSession- theTimingSessionto be wrapped; not null- Throws:
NullPointerException- if theTimingSessionto be wrapped is null
-
-
Method Detail
-
reset
public void reset()
Description copied from class:TimingSessionResets all counters associated with this timing session.- Overrides:
resetin classTimingSession
-
start
public void start()
Description copied from class:TimingSessionStarts the timing session.- Overrides:
startin classTimingSession
-
stop
public void stop()
Description copied from class:TimingSessionStops the timing session.- Overrides:
stopin classTimingSession
-
isStarted
public boolean isStarted()
Description copied from class:TimingSessionReturnstrueif this timing session is started.- Overrides:
isStartedin classTimingSession- Returns:
- true if the timing session is started; otherwise, false
-
elapsedTime
public Duration elapsedTime(Counter.Type type)
Description copied from class:TimingSessionA convenient method that returns the elapsed time of a specific counter.This has the same effect as calling:
timingSession.getCounter(type).elapsedTime()- Overrides:
elapsedTimein classTimingSession- Parameters:
type- the counter type to be fetched- Returns:
- the elapsed time for the specified counter
-
elapsedTime
public double elapsedTime(Counter.Type type, TimeUnit timeUnit)
Description copied from class:TimingSessionA convenient method that returns the elapsed time of a specific counter, in the specified time unit.This has the same effect as calling:
timingSession.getCounter(type).elapsedTime(timeUnit)- Overrides:
elapsedTimein classTimingSession- Parameters:
type- the counter type to be fetchedtimeUnit- the time unit to which the elapsed time will be converted- Returns:
- the elapsed time for the specified counter, converted to the given time unit using the default conversion mode.
-
elapsedTime
public double elapsedTime(Counter.Type type, TimeUnit timeUnit, ConversionMode conversionMode)
Description copied from class:TimingSessionA convenient method that returns the elapsed time of a specific counter, in the specified time unit, by applying a customConversionMode.This has the same effect as calling:
timingSession.getCounter(type).elapsedTime(timeUnit, conversionMode)- Overrides:
elapsedTimein classTimingSession- Parameters:
type- the counter type to be fetchedtimeUnit- the time unit to which the elapsed time will be convertedconversionMode- theConversionModeto be applied- Returns:
- the elapsed time for the specified counter, converted to the given time unit using the given conversion mode.
-
-