From: Tokuhiro Matsuno Date: Sat, 6 Dec 2008 05:40:43 +0000 (+0000) Subject: added benchmark script X-Git-Tag: 0.19~136^2~21 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ddca6c8f18c9c9fb84c2db836e3227f23aba3647;p=gitmo%2FMouse.git added benchmark script --- diff --git a/author/benchmark.pl b/author/benchmark.pl new file mode 100644 index 0000000..a7832e2 --- /dev/null +++ b/author/benchmark.pl @@ -0,0 +1,36 @@ +use strict; +use warnings; +use Benchmark qw/cmpthese/; +use String::TT qw/tt/; + +for my $klass (qw/Moose Mouse/) { + eval tt(q{ + package [% klass %]One; + use [% klass %]; + has n => ( + is => 'rw', + isa => 'Int', + ); + no [% klass %]; + __PACKAGE__->meta->make_immutable; + }); + die $@ if $@; +} + +print "---- new\n"; +cmpthese( + 100000 => { + map { my $x = $_; $_ => sub { $x->new(n => 3) } } + map { "${_}One" } + qw/Moose Mouse/ + } +); + +print "---- new,set\n"; +cmpthese( + 100000 => { + map { my $y = $_; $_ => sub { $y->new(n => 3)->n(5) } } + map { "${_}One" } + qw/Moose Mouse/ + } +);