A complex grails page if often a cascade of templates rendering, nested in each others.
Optimizing page views starts with profiling which template takes time and which template is called by which one.
We offer a capture mechanism of all
Installation
grails install-plugin profile-template
grails install-plugin profile-template
Configuration
By default, all template calls are captured if the plugin is installed in your application. It is possible to deactivate the capture at start in your grails-app/conf/Config.groovy with:
profile.template.disabled=false
By default, all template calls are captured if the plugin is installed in your application. It is possible to deactivate the capture at start in your grails-app/conf/Config.groovy with:
profile.template.disabled=false
Call Stack
A list of calls of template rendering, where the indentation shows the nesting levels
A summary by template name
Where total and intrinsic duration are displayed ("intrinsic" means it is the time taken by the template itself minus the children times)
A call graph
Which template is called by which one? How many times? What is the sum of intrinsic duration for each template. This information is shown via a graphe, thanks to cytoscape.
How does it work?
Well, it is rather simple:
- the plugin PluginTemplateGrailsPlugin.groovy file contains a doWithDynamicMethods closure. This closure captures start & stop template rendering through StopWatchEvents, store into a service ProfileTemplateService.
- This service simply store the events by requests. They are store in memory, not to create any domain class and interfere with the host application.
Have fun profiling and don't hesitate to ask any question
Thanks for creating the plugin, may I know can I use this profiler for dynamic templates? Please see http://limcheekin.blogspot.com/2011/01/freemarker-vs-gsp-for-dynamic-template_27.html
ReplyDeleteI do not know?
ReplyDeletehave you tried straight?
In fact the "catching" happens in the file ProfileTemplateGrailsPlugins.groovy, where we have:
def metaGPWClass = org.codehaus.groovy.grails.web.pages.GroovyPageWritable.class.metaClass
metaGPWClass.invokeMethod = { name, args ->
If it does not catch dynamic template, we shall find out the method called to render them and insert it at the same position
Alex
Hi- the stricter GSP parsing in Grails 2.01 seems to hit a snag on the plugin. Have you noticed this? Thanks.
ReplyDeleteC:\Users\winklerj\.grails\2.0.1\projects\suwebsite\gspcompile\gsp_profileTemplate_profileTemplateReport_index_gsp.groovy: 96: unexpected token: name @ line 96,
column 6.
for( name, details in (summaryByTemplate) ) {
^
Hi Jeff,
ReplyDeletethat was related to a .. which does not work anymore
http://grails.1312388.n4.nabble.com/Iterating-over-a-map-with-g-each-td4214906.html
Fix is done and plugin released. Can you give it a try please?
(version was not updated, so you might have to remove local zip)
alex
This comment has been removed by a blog administrator.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteHi Alexandre,
ReplyDeleteI have installed your profile-template plugin. When I go to the http://localhost:8080//profileTemplateReport page, I see the link at the top and press the "start_recording" link and go back to my app and do a few things. When I come back to the ProfileTemplateReport page and press the "view_call_stack" link, nothing appears. I put breakpoints in the ProfileTemplateReportController, so I can see that the code there is executing. I put a breakpoint in the ProfileTemplateService.record() method, but it never seems to get called.
Is there some configuration step I've missed? All I did to install this was to type "grails install-plugin profile-template" and that worked fine.
Thanks for your help.
Tom
tdean@one.net
Hei,
ReplyDeleteI've not used the plugin with recent grails version. That might be the reason.
Is it easy for you to have it a go with 1.3.x?
No, I have to use grails 2.0.1. If source was available I might be able to see what's going on.
DeleteTom