added benchmark script
[gitmo/Mouse.git] / author / benchmark.pl
CommitLineData
ddca6c8f 1use strict;
2use warnings;
3use Benchmark qw/cmpthese/;
4use String::TT qw/tt/;
5
6for my $klass (qw/Moose Mouse/) {
7 eval tt(q{
8 package [% klass %]One;
9 use [% klass %];
10 has n => (
11 is => 'rw',
12 isa => 'Int',
13 );
14 no [% klass %];
15 __PACKAGE__->meta->make_immutable;
16 });
17 die $@ if $@;
18}
19
20print "---- new\n";
21cmpthese(
22 100000 => {
23 map { my $x = $_; $_ => sub { $x->new(n => 3) } }
24 map { "${_}One" }
25 qw/Moose Mouse/
26 }
27);
28
29print "---- new,set\n";
30cmpthese(
31 100000 => {
32 map { my $y = $_; $_ => sub { $y->new(n => 3)->n(5) } }
33 map { "${_}One" }
34 qw/Moose Mouse/
35 }
36);