File: benchmark.pl

package info (click to toggle)
libpetal-perl 2.20-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,148 kB
  • sloc: perl: 4,712; xml: 726; makefile: 2
file content (41 lines) | stat: -rw-r--r-- 724 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/perl

##
## Benchmark some common functions
##

use warnings;
use lib 'lib';

use Test::More qw( no_plan );
use Benchmark;
use Petal;

$Petal::BASE_DIR     = './t/data/';
$Petal::DISK_CACHE   = 0;
$Petal::MEMORY_CACHE = 1;
$Petal::TAINT        = 1;
$Petal::INPUT        = 'HTML';

#$Petal::Hash::Var::ERROR_ON_UNDEF_VAR = 0;

my %vars = (
	    foo     => bless ({ bar => 1 }, 'Foo'),
	    list    => [ 1, 2, 3, 4 ],
	    session => { id   => '1234asdf',
			 user => { id => 'fred', name => 'fred fish' },
		    },
	   );

diag ("running benchmarks for 10s...");

my $b = timethis (-10, sub { run_test( %vars ) });

diag (timestr $b);

ok (1);

sub run_test {
    Petal->new( 'benchmark.html' )->process( @_ );
}