Skip to content

@tednaleid /grailsScriptTiming.diff
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
output every grails event with timing
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) {
@tednaleid
Owner

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 []
@burtbeckwith

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

@tednaleid
Owner

@burtbeckwith pull requests/forks accepted :)

@burtbeckwith

That's ok, it's correct here: grails/grails-core@22dbc51 :)

@tednaleid
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.