Skip to content

Instantly share code, notes, and snippets.

@d6y
Created July 22, 2012 15:50
Show Gist options
  • Save d6y/3160058 to your computer and use it in GitHub Desktop.
Save d6y/3160058 to your computer and use it in GitHub Desktop.
interface Block {
R execute() throws X;
}
public R time(String opName, Block block) throws X {
long startTime = System.nanoTime();
boolean success = true;
try {
return block.execute();
} catch (final Throwable ex) {
success = false;
throw ex;
} finally {
recordTiming(
"opName", System.nanoTime() - startTime, success );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment