Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- * Bo.pm
- package Bo;
- sub new {
- my ($class) = @_;
- return bless { buff => 0 }, $class;
- }
- sub buff {
- my ($self, $var) = @_;
- if (defined $var) {
- $self->{buff} = $var;
- }
- return $self->{buff};
- }
- 1;
- * Boo.pm
- package Boo;
- use Mo;
- #use Moo;
- #use Mouse;
- #use Moose;
- has 'buff' => (is => 'rw');
- #__PACKAGE__->meta->make_immutable();
- 1;
- * Moose
- $ perl -MBenchmark -E 'use Boo;use Bo;timethese(100000,{Boo=>sub{my $o=Boo->new}, Bo=>sub{my $o=Bo->new}})'
- Benchmark: timing 100000 iterations of Bo, Boo...
- Bo: 0 wallclock secs ( 0.12 usr + 0.00 sys = 0.12 CPU) @ 833333.33/s (n=100000)
- (warning: too few iterations for a reliable count)
- Boo: 0 wallclock secs ( 0.40 usr + 0.00 sys = 0.40 CPU) @ 250000.00/s (n=100000)
- $ perl -MBenchmark -E 'use Boo;use Bo;my $o=Boo->new;my $o2=Bo->new;timethese(100000,{Boo=>sub{$o->buff(5);$o->buff}, Bo=>sub{$o2->buff(5);$o2->buff}})'
- Benchmark: timing 100000 iterations of Bo, Boo...
- Bo: 0 wallclock secs ( 0.12 usr + 0.00 sys = 0.12 CPU) @ 833333.33/s (n=100000)
- (warning: too few iterations for a reliable count)
- Boo: 0 wallclock secs ( 0.09 usr + 0.00 sys = 0.09 CPU) @ 1111111.11/s (n=100000)
- (warning: too few iterations for a reliable count)
- * Mouse
- $ perl -MBenchmark -E 'use Boo;use Bo;timethese(100000,{Boo=>sub{my $o=Boo->new}, Bo=>sub{my $o=Bo->new}})'
- Benchmark: timing 100000 iterations of Bo, Boo...
- Bo: 0 wallclock secs ( 0.12 usr + 0.00 sys = 0.12 CPU) @ 833333.33/s (n=100000)
- (warning: too few iterations for a reliable count)
- Boo: 0 wallclock secs ( 0.10 usr + 0.00 sys = 0.10 CPU) @ 1000000.00/s (n=100000)
- (warning: too few iterations for a reliable count)
- $ perl -MBenchmark -E 'use Boo;use Bo;my $o=Boo->new;my $o2=Bo->new;timethese(100000,{Boo=>sub{$o->buff(5);$o->buff}, Bo=>sub{$o2->buff(5);$o2->buff}})'
- Benchmark: timing 100000 iterations of Bo, Boo...
- Bo: 0 wallclock secs ( 0.15 usr + 0.00 sys = 0.15 CPU) @ 666666.67/s (n=100000)
- (warning: too few iterations for a reliable count)
- Boo: 0 wallclock secs ( 0.04 usr + 0.00 sys = 0.04 CPU) @ 2500000.00/s (n=100000)
- (warning: too few iterations for a reliable count)
- * Moo
- $ perl -MBenchmark -E 'use Boo;use Bo;timethese(100000,{Boo=>sub{my $o=Boo->new}, Bo=>sub{my $o=Bo->new}})'
- Benchmark: timing 100000 iterations of Bo, Boo...
- Bo: 1 wallclock secs ( 0.12 usr + 0.00 sys = 0.12 CPU) @ 833333.33/s (n=100000)
- (warning: too few iterations for a reliable count)
- Boo: 0 wallclock secs ( 0.19 usr + 0.00 sys = 0.19 CPU) @ 526315.79/s (n=100000)
- (warning: too few iterations for a reliable count)
- $ perl -MBenchmark -E 'use Boo;use Bo;my $o=Boo->new;my $o2=Bo->new;timethese(100000,{Boo=>sub{$o->buff(5);$o->buff}, Bo=>sub{$o2->buff(5);$o2->buff}})'
- Benchmark: timing 100000 iterations of Bo, Boo...
- Bo: 0 wallclock secs ( 0.15 usr + 0.00 sys = 0.15 CPU) @ 666666.67/s (n=100000)
- (warning: too few iterations for a reliable count)
- Boo: 0 wallclock secs ( 0.03 usr + 0.00 sys = 0.03 CPU) @ 3333333.33/s (n=100000)
- (warning: too few iterations for a reliable count)
- * Mo
- $ perl -MBenchmark -E 'use Boo;use Bo;timethese(100000,{Boo=>sub{my $o=Boo->new}, Bo=>sub{my $o=Bo->new}})'
- Benchmark: timing 100000 iterations of Bo, Boo...
- Bo: 0 wallclock secs ( 0.12 usr + 0.00 sys = 0.12 CPU) @ 833333.33/s (n=100000)
- (warning: too few iterations for a reliable count)
- Boo: 1 wallclock secs ( 0.42 usr + 0.00 sys = 0.42 CPU) @ 238095.24/s (n=100000)
- $ perl -MBenchmark -E 'use Boo;use Bo;my $o=Boo->new;my $o2=Bo->new;timethese(100000,{Boo=>sub{$o->buff(5);$o->buff}, Bo=>sub{$o2->buff(5);$o2->buff}})'
- Benchmark: timing 100000 iterations of Bo, Boo...
- Bo: 0 wallclock secs ( 0.15 usr + 0.00 sys = 0.15 CPU) @ 666666.67/s (n=100000)
- (warning: too few iterations for a reliable count)
- Boo: 0 wallclock secs ( 0.10 usr + 0.00 sys = 0.10 CPU) @ 1000000.00/s (n=100000)
- (warning: too few iterations for a reliable count)
Add Comment
Please, Sign In to add comment