Package io.delta.kernel.internal.metrics
Class Timer
Object
io.delta.kernel.internal.metrics.Timer
A timer class for measuring the duration of operations in nanoseconds
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceTimer.ThrowingSupplier<T,E extends Exception> Times an operation that can throw a specific checked exception type.static interfaceA timing sample that carries internal state about the Timer's start position. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongcount()voidrecord(long amount) Records a custom amount.start()Starts the timer and returns aTimer.Timedinstance.void<T> T<T> TtimeCallable(Callable<T> callable) <T,E extends Exception>
TtimeChecked(Timer.ThrowingSupplier<T, E> operation) Times an operation that can throw a specific checked exception type.toString()longlong
-
Constructor Details
-
Timer
public Timer()
-
-
Method Details
-
count
public long count()- Returns:
- the number of times this timer was used to record a duration.
-
totalDurationNs
public long totalDurationNs()- Returns:
- the total duration that was recorded in nanoseconds
-
totalDurationMs
public long totalDurationMs()- Returns:
- the total duration that was recorded in milliseconds
-
totalDurationIfRecorded
- Returns:
- An optional storing the total duration recorded in the timer if the timer has been used to record a duration at least once. If the timer has not been used, returns empty.
-
start
Starts the timer and returns aTimer.Timedinstance. CallTimer.Timed.stop()to complete the timing.- Returns:
- A
Timer.Timedinstance with the start time recorded.
-
record
public void record(long amount) Records a custom amount.- Parameters:
amount- The amount to record in nanoseconds
-
time
-
timeCallable
- Throws:
Exception
-
timeChecked
Times an operation that can throw a specific checked exception type.- Throws:
E
-
time
-
toString
-