From: Tokuhiro Matsuno Date: Mon, 6 Apr 2009 02:30:46 +0000 (+0900) Subject: added benchmark script for C::A::Fast X-Git-Tag: 0.20~14 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bb3f31b1dbdb50a00a80d833b15d1f45922e6096;p=gitmo%2FMouse.git added benchmark script for C::A::Fast --- diff --git a/author/benchmarks/caf.pl b/author/benchmarks/caf.pl new file mode 100644 index 0000000..650ee54 --- /dev/null +++ b/author/benchmarks/caf.pl @@ -0,0 +1,58 @@ +# benchmark +use strict; +use warnings; +use Benchmark ':all'; + +{ + package Bench::CAF; + use base 'Class::Accessor::Fast'; + __PACKAGE__->mk_accessors(qw/a/); +} + +{ + package Bench::Mouse; + use Mouse; + has 'a' => ( is => 'rw' ); + no Mouse; + __PACKAGE__->meta->make_immutable; +} + +my $c = Bench::CAF->new; +my $m = Bench::Mouse->new; + +print "-- new\n"; +cmpthese( + -1, { + mouse => sub { + Bench::Mouse->new() + }, + caf => sub { + Bench::CAF->new() + }, + }, +); + +print "-- setter\n"; +cmpthese( + -1, { + mouse => sub { + $m->a(1); + }, + caf => sub { + $c->a(1) + }, + }, +); + +print "-- getter\n"; +cmpthese( + -1, { + mouse => sub { + $m->a; + }, + caf => sub { + $c->a + }, + }, +); +