Skip to content

Instantly share code, notes, and snippets.

@mawaldne
Last active December 30, 2015 12:59
Show Gist options
  • Save mawaldne/7832688 to your computer and use it in GitHub Desktop.
Save mawaldne/7832688 to your computer and use it in GitHub Desktop.
Time methods using closures in groovy
def timeMethod(method, message) {
def startTime = System.currentTimeMillis()
method()
def totalTime = System.currentTimeMillis() - startTime
log.info "${message} ${totalTime} ms"
}
...
timeMethod({ someMethod() }, "someMethod Time:")
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment