Class Timed
java.lang.Object
org.apache.sling.distribution.journal.shared.Timed
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Runs provided code updating provided metric with its execution time.static <T> T
Runs provided code updating provided metric with its execution time.
-
Method Details
-
timed
public static void timed(org.apache.sling.commons.metrics.Timer metric, Runnable code) throws Exception Runs provided code updating provided metric with its execution time. The method guarantees that the metric is updated even if the code throws an exception- Parameters:
metric
- metric to updatecode
- code to clock- Throws:
Exception
- actually it doesn't
-
timed
public static <T> T timed(org.apache.sling.commons.metrics.Timer metric, Callable<T> code) throws Exception Runs provided code updating provided metric with its execution time. The method guarantees that the metric is updated even if the code throws an exception- Parameters:
metric
- metric to updatecode
- code to clock- Returns:
- a value returned but
code.call()
invocation - Throws:
Exception
- if underlying code throws
-