Package org.apache.iceberg.metrics
Interface Timer
- All Known Implementing Classes:
DefaultTimer
public interface Timer
Generalized Timer interface for creating telemetry related instances for measuring duration of
operations.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
A timing sample that carries internal state about the Timer's start position. -
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionlong
count()
The number of timestime(Duration)
was called.default boolean
isNoop()
Determines whether this timer is a NOOP timer.void
Records a custom amount in the given time unit.start()
Starts the timer and returns aTimer.Timed
instance.void
Executes and measures the givenRunnable
instance.default void
The duration to record<T> T
Gets the result from the givenSupplier
and measures its execution time.<T> T
timeCallable
(Callable<T> callable) Executes and measures the givenCallable
and returns its result.The total duration that was recorded.default TimeUnit
unit()
TheTimeUnit
of the timer.
-
Field Details
-
NOOP
-
-
Method Details
-
count
long count()The number of timestime(Duration)
was called.- Returns:
- The number of times
time(Duration)
was called.
-
totalDuration
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.Timed
instance. CallTimer.Timed.stop()
to complete the timing.- Returns:
- A
Timer.Timed
instance with the start time recorded.
-
unit
TheTimeUnit
of the timer.- Returns:
- The
TimeUnit
of the timer.
-
record
Records a custom amount in the given time unit.- Parameters:
amount
- The amount to recordunit
- The time unit of the amount
-
time
The duration to record- Parameters:
duration
- The duration to record
-
time
Executes and measures the givenRunnable
instance.- Parameters:
runnable
- TheRunnable
to execute and measure.
-
timeCallable
Executes and measures the givenCallable
and returns its result. -
time
Gets the result from the givenSupplier
and measures its execution time. -
isNoop
default boolean isNoop()Determines whether this timer is a NOOP timer.- Returns:
- Whether this timer is a NOOP timer.
-