Search

Dark theme | Light theme

February 23, 2011

Grails Goodness: Profile Script Tasks

If we want to know how long the execution of a Grails task takes we can enable profiling. If we enable profiling we can see for example how long it takes to compile the source code. We can enable the profiling information by setting the system property grails.script.profile with the value true.

$ grails -Dgrails.script.profile=true compile

Another way to enable profiling of the Grails tasks is to set the property grails.script.file with the value true in grails-app/conf/BuildConfig.groovy.

// File: grails-app/conf/BuildConfig.groovy
...
grails.script.profile=true
...

If we run a Grails script and profiling is enabled we see the information in the console output:

$ grails -Dgrails.script.profile=true compile
Welcome to Grails 1.3.7 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /opt/local/grails/current

Base Directory: /Users/mrhaki/Projects/sample
Resolving dependencies...
Dependencies resolved in 3113ms.
Running script /opt/local/grails/current/scripts/Compile.groovy
Environment set to development
Profiling [Compiling sources to location [/Users/mrhaki/.grails/1.3.7/projects/sample/plugin-classes]] start
Profiling [Compiling sources to location [/Users/mrhaki/.grails/1.3.7/projects/sample/plugin-classes]] finish. Took 2319 ms
Profiling [Compiling sources to location [target/classes]] start
Profiling [Compiling sources to location [target/classes]] finish. Took 317 ms