public
Created

output every grails event with timing

  • Download Gist
grailsScriptTiming.diff
Diff
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
diff --git a/scripts/_GrailsEvents.groovy b/scripts/_GrailsEvents.groovy
index bc0b479..bb8f13e 100644
--- a/scripts/_GrailsEvents.groovy
+++ b/scripts/_GrailsEvents.groovy
@@ -49,13 +49,19 @@ binding.addBuildListener(eventListener)
// Set up the classpath for the event hooks.
classpath()
// Now load them.
eventListener.classLoader = new GroovyClassLoader(classLoader)
eventListener.initialize()
+long eventInitStart = new Date().time
+
// Send a scripting event notification to any and all event hooks in plugins/user scripts
event = {String name, args ->
try {
+ grailsConsole.addStatus "#### (${new Date().time - eventInitStart}) $name $args"
+ grailsConsole.lastMessage = ""
eventListener.triggerEvent(name, * args)
}
catch(e) {

ex output:

| #### (2) SetClasspath [java.net.URLClassLoader@799dbc3b]
| Compiling 1 source files.
| #### (3857) TestPhasesStart [[unit, integration, functional, other]]
| #### (3893) TestPhaseStart [unit]
| #### (3893) TestCompileStart [org.codehaus.groovy.grails.test.junit4.JUnit4GrailsTestType@33c26386]
| #### (3941) TestCompileEnd [org.codehaus.groovy.grails.test.junit4.JUnit4GrailsTestType@33c26386]
| #### (4480) TestSuiteStart [unit]
| #### (4992) TestCaseStart [com.entagen.triplemap.domain.UserRoleTest]
| #### (5034) TestStart [testEquals]
| #### (6368) TestEnd [testEquals]
| #### (6368) TestStart [testEquals_differentUser]
| #### (6479) TestEnd [testEquals_differentUser]
| #### (6479) TestStart [testEquals_differentRole]
| #### (6609) TestEnd [testEquals_differentRole]
....
| #### (67607) TestPhaseEnd [integration]
| #### (67608) TestPhaseStart [other]
| #### (67609) TestPhaseEnd [other]
| #### (67609) TestProduceReports []
| Tests PASSED - view reports in target/test-reports
| #### (68087) TestPhasesEnd []

Cool stuff. One nit - new Date().time == System.currentTimeMillis(), no need to instantiate and toss a Date

@burtbeckwith pull requests/forks accepted :)

Sweet! I've actually found this info really helpful/interesting, thanks for adding it into grails core.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.