[Templates] Announcing Template::Timer

[prev] [thread] [next] [Date index for 2004/10/26]

From: Andy Lester
Subject: [Templates] Announcing Template::Timer
Date: 15:32 on 26 Oct 2004
  file: $CPAN/authors/id/P/PE/PETDANCE/Template-Timer-0.01.tar.gz
  size: 2489 bytes
   md5: a77568ba820f26d81be05fef4f2d02e4

I bundled up the functionality that Gavin posted and Randal modified.
Now, people in my situation ("Surely there must be a profiler
somewhere!") have a tool they can easily find.


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.

        -- 
        Andy Lester => andy@xxxxxxxx.xxx => www.petdance.com => AIM:petdance

_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates

[Templates] Announcing Template::Timer
Andy Lester 15:32 on 26 Oct 2004

Generated at 08:56 on 15 Mar 2005 by mariachi v0.52