[sf-perl] Real perl

Jonathan Swartz swartz at pobox.com
Tue Apr 10 17:05:29 PDT 2012


Dana: Agreed that performance is a consideration but Moose != MooseX::Declare!! Moose does have its startup costs, but MooseX::Declare has runtime costs *far* greater than either Moose or plain old classes.

I'm a big fan of Method::Signatures::Simple myself, because I don't need runtime type-checking on individual method arguments enough to pay the considerable price.

If you redo p2 with this code --

   package Foo;
   use Moose;
   use Method::Signatures::Simple;
   
   method adder ($ct) {
       return $ct + 1;
   }
   
   1;

I think you'll find the performance to be much closer to p1 than p2.

Jon

> dana at hithlum:~/bench$ cat p1
> #!/usr/bin/perl
> 
> my $foo = {};
> bless $foo, 'Foo';
> 
> my $counter = 1;
> for(1..100000) {
>     $counter = $foo->adder($counter);
> }
> print "$counter\n";
> 
> package Foo;
> 
> sub
> adder {
>     return $_ + 1;
> }
> 
> dana at hithlum:~/bench$ time ./p1
> 100001
> 
> real    0m0.045s
> user    0m0.044s7
> sys     0m0.000s
> dana at hithlum:~/bench$ cat p2
> #!/usr/bin/perl
> 
> use lib '.';
> use Foo;
> 
> my $foo = Foo->new;
> my $counter = 1;
> for(1..100000) {
>     $counter = $foo->adder($counter);
> }
> print "$counter\n";
> dana at hithlum:~/bench$ cat Foo.pm 
> use MooseX::Declare;
> 
> class Foo {
>     method adder (Num $ct) {
>         return $ct + 1;
>     }
> }
> dana at hithlum:~/bench$ time perl ./p2
> 100001
> 
> real    0m13.718s
> user    0m13.661s
> sys     0m0.044s
> dana at hithlum:~/bench$ 
> 
> I write code using Moose and the wide galaxy of exceptional modules it has spawned every day.  And I yearn for the day that I can use Perl6 in my production environment.  (It's getting close, last time I looked!)  But sometimes raw 'cpu' performance is important.
> 
> Most of the time, I start using the highest-level modules possible, and if there's a performance problem, I end up 'dumbing down' the hot-spots, using simpler Perl.  For me, this is rare.
> 
> Cheers,
> -Dana
> 
> On Tue, Apr 10, 2012 at 2:00 PM, Randal L. Schwartz <merlyn at stonehenge.com> wrote:
> >>>>> "Dodger" == Dodger  <el.dodgero at gmail.com> writes:
> 
> Dodger> So... How about some old school perl without mooses and meeses?
> Dodger> Anybody out there code in... You know... Perl?
> 
> Seriously, if you're launching green code and not using Moose, you have
> some weird nostalgia in you that prevents you from being a useful coder
> for me or my clients.
> 
> --
> Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
> <merlyn at stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
> Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
> See http://methodsandmessages.posterous.com/ for Smalltalk discussion
> _______________________________________________
> SanFrancisco-pm mailing list
> SanFrancisco-pm at pm.org
> http://mail.pm.org/mailman/listinfo/sanfrancisco-pm
> 
> _______________________________________________
> SanFrancisco-pm mailing list
> SanFrancisco-pm at pm.org
> http://mail.pm.org/mailman/listinfo/sanfrancisco-pm

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/sanfrancisco-pm/attachments/20120410/4205e24e/attachment-0001.html>


More information about the SanFrancisco-pm mailing list