Package org.apache.iceberg.metrics
Class DefaultTimer
- java.lang.Object
-
- org.apache.iceberg.metrics.DefaultTimer
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.iceberg.metrics.Timer
Timer.Timed
-
-
Constructor Summary
Constructors Constructor Description DefaultTimer(java.util.concurrent.TimeUnit timeUnit)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
count()
The number of timesTimer.time(Duration)
was called.void
record(long amount, java.util.concurrent.TimeUnit unit)
Records a custom amount in the given time unit.Timer.Timed
start()
Starts the timer and returns aTimer.Timed
instance.void
time(java.lang.Runnable runnable)
Executes and measures the givenRunnable
instance.<T> T
time(java.util.function.Supplier<T> supplier)
Gets the result from the givenSupplier
and measures its execution time.<T> T
timeCallable(java.util.concurrent.Callable<T> callable)
Executes and measures the givenCallable
and returns its result.java.lang.String
toString()
java.time.Duration
totalDuration()
The total duration that was recorded.java.util.concurrent.TimeUnit
unit()
TheTimeUnit
of the timer.
-
-
-
Method Detail
-
count
public long count()
Description copied from interface:Timer
The number of timesTimer.time(Duration)
was called.- Specified by:
count
in interfaceTimer
- Returns:
- The number of times
Timer.time(Duration)
was called.
-
totalDuration
public java.time.Duration totalDuration()
Description copied from interface:Timer
The total duration that was recorded.- Specified by:
totalDuration
in interfaceTimer
- Returns:
- The total duration that was recorded.
-
start
public Timer.Timed start()
Description copied from interface:Timer
Starts the timer and returns aTimer.Timed
instance. CallTimer.Timed.stop()
to complete the timing.- Specified by:
start
in interfaceTimer
- Returns:
- A
Timer.Timed
instance with the start time recorded.
-
record
public void record(long amount, java.util.concurrent.TimeUnit unit)
Description copied from interface:Timer
Records a custom amount in the given time unit.
-
time
public <T> T time(java.util.function.Supplier<T> supplier)
Description copied from interface:Timer
Gets the result from the givenSupplier
and measures its execution time.
-
timeCallable
public <T> T timeCallable(java.util.concurrent.Callable<T> callable) throws java.lang.Exception
Description copied from interface:Timer
Executes and measures the givenCallable
and returns its result.- Specified by:
timeCallable
in interfaceTimer
- Type Parameters:
T
- The type of theCallable
- Parameters:
callable
- TheCallable
to execute and measure.- Returns:
- The result of the underlying
Callable
. - Throws:
java.lang.Exception
- In case theCallable
fails.
-
time
public void time(java.lang.Runnable runnable)
Description copied from interface:Timer
Executes and measures the givenRunnable
instance.
-
unit
public java.util.concurrent.TimeUnit unit()
Description copied from interface:Timer
TheTimeUnit
of the timer.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-