Guest User

Untitled

a guest
Jan 21st, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.11 KB | None | 0 0
  1. * Bo.pm
  2.  
  3. package Bo;
  4.  
  5. sub new {
  6. my ($class) = @_;
  7. return bless { buff => 0 }, $class;
  8. }
  9.  
  10. sub buff {
  11. my ($self, $var) = @_;
  12. if (defined $var) {
  13. $self->{buff} = $var;
  14. }
  15. return $self->{buff};
  16. }
  17.  
  18. 1;
  19.  
  20.  
  21.  
  22. * Boo.pm
  23.  
  24. package Boo;
  25. use Mo;
  26. #use Moo;
  27. #use Mouse;
  28. #use Moose;
  29.  
  30. has 'buff' => (is => 'rw');
  31.  
  32. #__PACKAGE__->meta->make_immutable();
  33.  
  34. 1;
  35.  
  36.  
  37.  
  38.  
  39.  
  40. * Moose
  41.  
  42. $ perl -MBenchmark -E 'use Boo;use Bo;timethese(100000,{Boo=>sub{my $o=Boo->new}, Bo=>sub{my $o=Bo->new}})'
  43. Benchmark: timing 100000 iterations of Bo, Boo...
  44. Bo: 0 wallclock secs ( 0.12 usr + 0.00 sys = 0.12 CPU) @ 833333.33/s (n=100000)
  45. (warning: too few iterations for a reliable count)
  46. Boo: 0 wallclock secs ( 0.40 usr + 0.00 sys = 0.40 CPU) @ 250000.00/s (n=100000)
  47.  
  48.  
  49. $ 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}})'
  50. Benchmark: timing 100000 iterations of Bo, Boo...
  51. Bo: 0 wallclock secs ( 0.12 usr + 0.00 sys = 0.12 CPU) @ 833333.33/s (n=100000)
  52. (warning: too few iterations for a reliable count)
  53. Boo: 0 wallclock secs ( 0.09 usr + 0.00 sys = 0.09 CPU) @ 1111111.11/s (n=100000)
  54. (warning: too few iterations for a reliable count)
  55.  
  56.  
  57.  
  58. * Mouse
  59.  
  60. $ perl -MBenchmark -E 'use Boo;use Bo;timethese(100000,{Boo=>sub{my $o=Boo->new}, Bo=>sub{my $o=Bo->new}})'
  61. Benchmark: timing 100000 iterations of Bo, Boo...
  62. Bo: 0 wallclock secs ( 0.12 usr + 0.00 sys = 0.12 CPU) @ 833333.33/s (n=100000)
  63. (warning: too few iterations for a reliable count)
  64. Boo: 0 wallclock secs ( 0.10 usr + 0.00 sys = 0.10 CPU) @ 1000000.00/s (n=100000)
  65. (warning: too few iterations for a reliable count)
  66.  
  67. $ 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}})'
  68. Benchmark: timing 100000 iterations of Bo, Boo...
  69. Bo: 0 wallclock secs ( 0.15 usr + 0.00 sys = 0.15 CPU) @ 666666.67/s (n=100000)
  70. (warning: too few iterations for a reliable count)
  71. Boo: 0 wallclock secs ( 0.04 usr + 0.00 sys = 0.04 CPU) @ 2500000.00/s (n=100000)
  72. (warning: too few iterations for a reliable count)
  73.  
  74.  
  75.  
  76. * Moo
  77.  
  78. $ perl -MBenchmark -E 'use Boo;use Bo;timethese(100000,{Boo=>sub{my $o=Boo->new}, Bo=>sub{my $o=Bo->new}})'
  79. Benchmark: timing 100000 iterations of Bo, Boo...
  80. Bo: 1 wallclock secs ( 0.12 usr + 0.00 sys = 0.12 CPU) @ 833333.33/s (n=100000)
  81. (warning: too few iterations for a reliable count)
  82. Boo: 0 wallclock secs ( 0.19 usr + 0.00 sys = 0.19 CPU) @ 526315.79/s (n=100000)
  83. (warning: too few iterations for a reliable count)
  84.  
  85. $ 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}})'
  86. Benchmark: timing 100000 iterations of Bo, Boo...
  87. Bo: 0 wallclock secs ( 0.15 usr + 0.00 sys = 0.15 CPU) @ 666666.67/s (n=100000)
  88. (warning: too few iterations for a reliable count)
  89. Boo: 0 wallclock secs ( 0.03 usr + 0.00 sys = 0.03 CPU) @ 3333333.33/s (n=100000)
  90. (warning: too few iterations for a reliable count)
  91.  
  92.  
  93.  
  94. * Mo
  95.  
  96. $ perl -MBenchmark -E 'use Boo;use Bo;timethese(100000,{Boo=>sub{my $o=Boo->new}, Bo=>sub{my $o=Bo->new}})'
  97. Benchmark: timing 100000 iterations of Bo, Boo...
  98. Bo: 0 wallclock secs ( 0.12 usr + 0.00 sys = 0.12 CPU) @ 833333.33/s (n=100000)
  99. (warning: too few iterations for a reliable count)
  100. Boo: 1 wallclock secs ( 0.42 usr + 0.00 sys = 0.42 CPU) @ 238095.24/s (n=100000)
  101.  
  102.  
  103. $ 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}})'
  104. Benchmark: timing 100000 iterations of Bo, Boo...
  105. Bo: 0 wallclock secs ( 0.15 usr + 0.00 sys = 0.15 CPU) @ 666666.67/s (n=100000)
  106. (warning: too few iterations for a reliable count)
  107. Boo: 0 wallclock secs ( 0.10 usr + 0.00 sys = 0.10 CPU) @ 1000000.00/s (n=100000)
  108. (warning: too few iterations for a reliable count)
Add Comment
Please, Sign In to add comment