<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/env perl
use strict;
use warnings;
use lib '../lib';
use HTML::Template;

# this is a little script I use to test the timing behavior of various
# options in HTML::Template;;

# an array of template files to test against and params to fill in
my %templates = (
    simple  =&gt; ['templates/simple.tmpl', {}],
    include =&gt; ['templates/include.tmpl'],
    medium  =&gt; [
        'templates/medium.tmpl',
        {
            'ALERT'         =&gt; 'I am alert.',
            'COMPANY_NAME'  =&gt; "MY NAME IS",
            'COMPANY_ID'    =&gt; "10001",
            'OFFICE_ID'     =&gt; "10103214",
            'NAME'          =&gt; 'SAM I AM',
            'ADDRESS'       =&gt; '101011 North Something Something',
            'CITY'          =&gt; 'NEW York',
            'STATE'         =&gt; 'NEw York',
            'ZIP'           =&gt; '10014',
            'PHONE'         =&gt; '212-929-4315',
            'PHONE2'        =&gt; '',
            'SUBCATEGORIES' =&gt; 'kfldjaldsf',
            'DESCRIPTION' =&gt;
              "dsa;kljkldasfjkldsajflkjdsfklfjdsgkfld\nalskdjklajsdlkajfdlkjsfd\n\talksjdklajsfdkljdsf\ndsa;klfjdskfj",
            'WEBSITE'       =&gt; 'http://www.assforyou.com/',
            'INTRANET_URL'  =&gt; 'http://www.something.com',
            'REMOVE_BUTTON' =&gt; "&lt;INPUT TYPE=SUBMIT NAME=command VALUE=\"Remove Office\"&gt;",
            'COMPANY_ADMIN_AREA' =&gt;
              "&lt;A HREF=administrator.cgi?office_id=office_id&amp;command=manage&gt;Manage Office Administrators&lt;/A&gt;",
            'CASESTUDIES_LIST' =&gt;
              "adsfkljdskldszfgfdfdsgdsfgfdshghdmfldkgjfhdskjfhdskjhfkhdsakgagsfjhbvdsaj hsgbf jhfg sajfjdsag ffasfj hfkjhsdkjhdsakjfhkj kjhdsfkjhdskfjhdskjfkjsda kjjsafdkjhds kjds fkj skjh fdskjhfkj kj kjhf kjh sfkjhadsfkj hadskjfhkjhs ajhdsfkj akj fkj kj kj  kkjdsfhk skjhadskfj haskjh fkjsahfkjhsfk ksjfhdkjh sfkjhdskjfhakj shiou weryheuwnjcinuc 3289u4234k 5 i 43iundsinfinafiunai saiufhiudsaf afiuhahfwefna uwhf u auiu uh weiuhfiuh iau huwehiucnaiuncianweciuninc iuaciun iucniunciunweiucniuwnciwe",
            'NUMBER_OF_CONTACTS' =&gt; "aksfjdkldsajfkljds",
            'COUNTRY_SELECTOR'   =&gt; "klajslkjdsafkljds",
            'LOGO_LINK'          =&gt; "dsfpkjdsfkgljdsfkglj",
            'PHOTO_LINK'         =&gt; "lsadfjlkfjdsgkljhfgklhasgh",
        }
    ],
    long_loop =&gt; ['templates/long_loops.tmpl', {}],
    loop_if   =&gt; ['templates/loop-if.tmpl',    {LOOP_ONE =&gt; [{VAR =&gt; 'foo'}]}]

);

# a hash of option hashes to test
my %options = (
    'no cache' =&gt; {},
    #'simple cache' =&gt; { cache =&gt; 1 },
    # 'shared cache' =&gt; { shared_cache =&gt; 1, cache =&gt; 1 },
    'file cache' =&gt; {
        file_cache     =&gt; 1,
        file_cache_dir =&gt; './file_cache'
    },
    #               'simple cache, no_includes' =&gt; { cache =&gt; 1, no_includes =&gt; 1},
    #               'blind cache' =&gt; { blind_cache =&gt; 1},
);

# number of times over each template
my $n = 100;
#open(OUT, "&gt;test.out");

foreach my $template (keys %templates) {
    print "\nTESTING : $template : $n iterations\n\n";

    foreach my $option (keys %options) {
        my $start_time = (times)[0];
        for (my $x = 0 ; $x &lt; $n ; $x++) {
            my $template = HTML::Template-&gt;new(
                filename =&gt; $templates{$template}-&gt;[0],
                %{$options{$option}}
            );
            foreach my $name (keys %{$templates{$template}-&gt;[1]}) {
                $template-&gt;param($name =&gt; $templates{$template}-&gt;[1]-&gt;{$name});
            }
            my $result = $template-&gt;output;
            #print OUT $result;
            #$template-&gt;output(print_to =&gt; *OUT);
        }

        my $end_time = (times)[0];
        print "$option : average iteration in " . (($end_time - $start_time) / $n) . " seconds\n";
    }
}

</pre></body></html>