Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Try this:

use strict;
use warnings;
use Template;
use Benchmark qw( :hireswallclock );

my $tt_2 = Template->new( INCLUDE_PATH => '/home/joerg' );

# precache
doit_1();
doit_2();

Benchmark::cmpthese(
    10000,
    {
        'doit_1' => \&doit_1,
        'doit_2' => \&doit_2
    }
);

sub doit_1 {
    my $tt_1 = Template->new( INCLUDE_PATH => '/home/joerg' );
    my $vars = { HELLO_WORLD => 'Hello, World!' };
    $tt_1->process( 'test.tt', $vars, \( my $void ) );
    return;
}

sub doit_2 {
    my $vars = { HELLO_WORLD => 'Hello, World!' };
    $tt_2->process( 'test.tt', $vars, \( my $void ) );
    return;
}

# joerg@Marvin:~> '/home/joerg/benchmark.pl'
#          Rate doit_1 doit_2
# doit_1  627/s     --   -90%
# doit_2 6329/s   909%     --

At the moment, you are benchmarking Template->new, which isn't really fair.

Update: You might also want to include HTML::Template::Compiled in your benchmarks. It's fast. Really fast.


In reply to Re: TT memory caching by WizardOfUz
in thread TT memory caching by december

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (6)
As of 2024-03-28 15:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found