What's the best method for benchmarking the performance of my various templates when using Template::Toolkit?
I want something that will break down how much cpu/system time is spent processing each block or template file, exclusive of the time spent processing other templates within. Devel::DProf, for example, is useless for this, since it simply tells me how much time is spent in the various internal methods of the Template module.
-
It turns out that Googling for template::toolkit profiling yields the best result, an article from November 2005 by Randal Schwartz. I can't copy and paste any of the article here due to copyright, but suffice to say that you simply get his source and use it as a module after template, like so:
use Template; use My::Template::Context;And you'll get output like this to STDERR when your script runs:
-- info.html at Thu Nov 13 09:33:26 2008: cnt clk user sys cuser csys template 1 0 0.06 0.00 0.00 0.00 actions.html 1 0 0.00 0.00 0.00 0.00 banner.html 1 0 0.00 0.00 0.00 0.00 common_javascript.html 1 0 0.01 0.00 0.00 0.00 datetime.html 1 0 0.01 0.00 0.00 0.00 diag.html 3 0 0.02 0.00 0.00 0.00 field_table 1 0 0.00 0.00 0.00 0.00 header.html 1 0 0.01 0.00 0.00 0.00 info.html 1 0 0.01 0.01 0.00 0.00 my_checklists.html 1 0 0.00 0.00 0.00 0.00 my_javascript.html 1 0 0.00 0.00 0.00 0.00 qualifier.html 52 0 0.30 0.00 0.00 0.00 referral_options 1 0 0.01 0.00 0.00 0.00 relationship_block 1 0 0.00 0.00 0.00 0.00 set_bgcolor.html 1 0 0.00 0.00 0.00 0.00 shared_javascript.html 2 0 0.00 0.00 0.00 0.00 table_block 1 0 0.03 0.00 0.00 0.00 ticket.html 1 0 0.08 0.00 0.00 0.00 ticket_actions.html -- end
Note that blocks as well as separate files are listed.
This is, IMHO, much more useful than the CPAN module Template::Timer.
0 comments:
Post a Comment