Package org.apache.sling.distribution.journal.shared

# Class Timed

java.lang.Object
org.apache.sling.distribution.journal.shared.Timed

public final class Timed extends Object

## Method Summary

Modifier and Type
Method
Description
`static void`
`timed(org.apache.sling.commons.metrics.Timer metric, Runnable code)`
Runs provided code updating provided metric with its execution time.
`static <T> T`
`timed(org.apache.sling.commons.metrics.Timer metric, Callable<T> code)`
Runs provided code updating provided metric with its execution time.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## 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 update
  `code` - 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 update
  `code` - code to clock
Returns:
  a value returned but `code.call()` invocation
Throws:
  `Exception` - if underlying code throws