Package org.apache.iceberg.metrics
Interface Timer
-
- All Known Implementing Classes:
DefaultTimer
public interface TimerGeneralized Timer interface for creating telemetry related instances for measuring duration of operations.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceTimer.TimedA timing sample that carries internal state about the Timer's start position.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description longcount()The number of timestime(Duration)was called.default booleanisNoop()Determines whether this timer is a NOOP timer.voidrecord(long amount, java.util.concurrent.TimeUnit unit)Records a custom amount in the given time unit.Timer.Timedstart()Starts the timer and returns aTimer.Timedinstance.voidtime(java.lang.Runnable runnable)Executes and measures the givenRunnableinstance.default voidtime(java.time.Duration duration)The duration to record<T> Ttime(java.util.function.Supplier<T> supplier)Gets the result from the givenSupplierand measures its execution time.<T> TtimeCallable(java.util.concurrent.Callable<T> callable)Executes and measures the givenCallableand returns its result.java.time.DurationtotalDuration()The total duration that was recorded.default java.util.concurrent.TimeUnitunit()TheTimeUnitof the timer.
-
-
-
Field Detail
-
NOOP
static final Timer NOOP
-
-
Method Detail
-
count
long count()
The number of timestime(Duration)was called.- Returns:
- The number of times
time(Duration)was called.
-
totalDuration
java.time.Duration totalDuration()
The total duration that was recorded.- Returns:
- The total duration that was recorded.
-
start
Timer.Timed start()
Starts the timer and returns aTimer.Timedinstance. CallTimer.Timed.stop()to complete the timing.- Returns:
- A
Timer.Timedinstance with the start time recorded.
-
unit
default java.util.concurrent.TimeUnit unit()
TheTimeUnitof the timer.- Returns:
- The
TimeUnitof the timer.
-
record
void record(long amount, java.util.concurrent.TimeUnit unit)Records a custom amount in the given time unit.- Parameters:
amount- The amount to recordunit- The time unit of the amount
-
time
default void time(java.time.Duration duration)
The duration to record- Parameters:
duration- The duration to record
-
time
void time(java.lang.Runnable runnable)
Executes and measures the givenRunnableinstance.- Parameters:
runnable- TheRunnableto execute and measure.
-
timeCallable
<T> T timeCallable(java.util.concurrent.Callable<T> callable) throws java.lang.ExceptionExecutes and measures the givenCallableand returns its result.- Type Parameters:
T- The type of theCallable- Parameters:
callable- TheCallableto execute and measure.- Returns:
- The result of the underlying
Callable. - Throws:
java.lang.Exception- In case theCallablefails.
-
time
<T> T time(java.util.function.Supplier<T> supplier)
Gets the result from the givenSupplierand measures its execution time.- Type Parameters:
T- The type of theSupplier.- Parameters:
supplier- TheSupplierto execute and measure.- Returns:
- The result of the underlying
Supplier.
-
isNoop
default boolean isNoop()
Determines whether this timer is a NOOP timer.- Returns:
- Whether this timer is a NOOP timer.
-
-