Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

petdance (2468)

petdance
  andy@petdance.com
http://www.perlbuzz.com/
AOL IM: petdance (Add Buddy, Send Message)
Yahoo! ID: petdance (Add User, Send Message)
Jabber: petdance@gmail.com

I'm Andy Lester, and I like to test stuff. I also write for the Perl Journal, and do tech edits on books. Sometimes I write code, too.

Journal of petdance (2468)

Tuesday October 26, 2004
10:18 AM

Announcing Template::Timer

[ #21521 ]
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.

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.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.