Skip to content

Instantly share code, notes, and snippets.

@deluan
Created December 17, 2010 11:52
Show Gist options
  • Save deluan/744828 to your computer and use it in GitHub Desktop.
Save deluan/744828 to your computer and use it in GitHub Desktop.
Grails request profiling example
class UtilFilters {
def filters = {
profiler(controller: '*', action: '*') {
before = {
request._timeBeforeRequest = System.currentTimeMillis()
}
after = {
request._timeAfterRequest = System.currentTimeMillis()
}
afterView = {
if (params.showTime) {
session._showTime = params.showTime == "on"
}
if (session._showTime) {
def actionDuration = request._timeAfterRequest - request._timeBeforeRequest
def viewDuration = System.currentTimeMillis() - request._timeAfterRequest
log.debug("Request duration for (${controllerName}/${actionName}): ${actionDuration}ms/${viewDuration}ms")
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment