/usr/share/perl5/Class/benchmark.pl is in libclass-makemethods-perl 1.01-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | #!perl
use strict;
use ExtUtils::testlib;
use Benchmark qw( cmpthese );
########################################################################
my @generators = qw( Basic Standard Composite Evaled Template );
my @methods = map "method_$_", 1 .. 30;
my %pckgno;
my $cputime = shift(@ARGV) || 0;
########################################################################
print "\nComparing module load time (usage overhead)...\n";
my %inc = %INC;
sub test_load {
local %INC = %inc;
my $f = "$_[0].pm";
$f =~ s{::}{/}g;
require $f;
}
cmpthese( $cputime, {
'Superclass' => sub {
test_load( "Class::MakeMethods" )
},
map {
my $gen = $_;
$gen => sub {
test_load( "Class::MakeMethods::${gen}::Hash" )
}
} @generators
} );
########################################################################
print "\nComparing method generation (startup duration)...\n";
cmpthese( $cputime, {
'inline' => sub {
eval( join "\n",
"package package_inline_" . ++ $pckgno{inline} . ";",
'sub new { my $class = shift; bless { @_ }, $class }',
map "sub $_ { my \$self = shift; \@_ ? \$self->{$_} = shift : \$self->{$_} }", @methods
);
},
map {
my $gen = $_;
$gen => sub {
Class::MakeMethods->make(
-MakerClass => $gen . "::Hash",
-TargetClass => ( "package_${gen}_" . ++ $pckgno{$gen} ),
'new' => 'new',
'scalar' => \@methods
);
}
} @generators
} );
########################################################################
print "\nComparing method calling (runtime duration)...\n";
cmpthese( $cputime, {
map {
my $gen = $_;
$gen => sub {
my $instance = "package_${gen}_1"->new();
foreach ( 1 .. 5 ) {
foreach my $method ( @methods ) {
my $value = $instance->$method();
$instance->$method( $value );
$instance->$method();
}
}
}
} keys %pckgno
} );
########################################################################
__END__
########################################################################
date; perl -v | grep This; perl benchmark.pl | grep -v wallclock
|