Created
December 17, 2010 11:52
-
-
Save deluan/744828 to your computer and use it in GitHub Desktop.
Grails request profiling example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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