Template::Timer - Rudimentary profiling for Template Toolkit
Version 0.01
Template::Timer provides inline timings of the template processing througout your code. It's an overridden version of Template::Context that wraps the process() and include() methods.
process()
include()
Using Template::Timer is simple.
my %config = ( # Whatever your config is INCLUDE_PATH => "/my/template/path", COMPILE_EXT => ".ttc", COMPILE_DIR => "/tmp/tt", ); if ( $development_mode ) { $config{ CONTEXT } = Template::Timer->new( %config ); } my $template = Template->new( \%config );
Now when you process templates, HTML comments will get embedded in your output, which you can easily grep for.
<!-- TIMER START: process mainmenu/mainmenu.ttml --> <!-- TIMER START: include mainmenu/cssindex.tt --> <!-- TIMER START: process mainmenu/cssindex.tt --> <!-- TIMER END: process mainmenu/cssindex.tt (0.017279 seconds) --> <!-- TIMER END: include mainmenu/cssindex.tt (0.017401 seconds) -->
....
<!-- TIMER END: process mainmenu/footer.tt (0.003016 seconds) --> <!-- TIMER END: include mainmenu/footer.tt (0.003104 seconds) --> <!-- TIMER END: process mainmenu/mainmenu.ttml (0.400409 seconds) -->
Note that since INCLUDE is a wrapper around PROCESS, calls to INCLUDEs will be doubled up, and slightly longer than the PROCESS call.
Andy Lester, <andy@petdance.com>
<andy@petdance.com>
Please report any bugs or feature requests to bug-template-timer@rt.cpan.org, or through the web interface at http://rt.cpan.org. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-template-timer@rt.cpan.org
Thanks to Randal Schwartz, and to Gavin Estey for the original code.
Copyright 2004 Andy Lester, All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Template::Timer, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Template::Timer
CPAN shell
perl -MCPAN -e shell install Template::Timer
For more information on module installation, please visit the detailed CPAN module installation guide.