Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Re: Re: Faster Perl, Good and Bad News

by MrNobo1024 (Hermit)
on Aug 10, 2002 at 00:04 UTC ( #189113=note: print w/ replies, xml ) Need Help??


in reply to Re: Re: Faster Perl, Good and Bad News
in thread Faster Perl, Good and Bad News

I benchmarked them, there was no significant difference between list assignment and using a temp var, and IMO the list assignment is more readable. Still, TMTOWTDI, and the temp var isn't really *that* obfuscated...

--MrNobo1024
s]]HrLfbfe|EbBibmv]e|s}w}ciZx^RYhL}e^print


Comment on Re: Re: Re: Faster Perl, Good and Bad News
Re: Re: Re: Re: Faster Perl, Good and Bad News
by demerphq (Chancellor) on Aug 12, 2002 at 09:33 UTC
    Im curious what you call signifigant, and also how you benchmarked them. Please post your benchmark. In my tests, with a predeclared swap variable, I see a %50 difference when using dynamic variables, and a %25 difference when using lexical variables. Personally I call that signifigant, especially if its inside a loop. Oh the difference would probably be even more drammatic for lexicals but for the fact of having to repeatedly declare them, which wouldnt be necessary in a more realisitic situation.

    use Benchmark 'cmpthese'; our $a=1; our $b=2; our $tmp; print "Dynamic variables, swap benchmark.\n"; cmpthese -10, {standard => '$::tmp=$::a; $::a=$::b; $::b=$tmp;', list => '($::a,$::b)=($::b,$::a)' }; print "Lexical variables, swap benchmark.\n"; cmpthese -10, { standard_my => sub{my $x=1;my $y=2; my $z =$x; $x=$y +; $y=$z}, standard_local => sub{my $x=1;my $y=2; local $_=$x; $x= +$y; $y=$_}, standard_global => sub{my $x=1;my $y=2; $_=$x; $x=$y; $y +=$_}, list => sub{my $x=1;my $y=2; ($x,$y)=($y,$x)} +, }; __END__ Dynamic variables, swap benchmark. Benchmark: running list, standard, each for at least 10 CPU seconds... list: 11 wallclock secs (10.39 usr + 0.00 sys = 10.39 CPU) @ 66 +4534.94/s (n=6904518) standard: 11 wallclock secs (10.84 usr + 0.00 sys = 10.84 CPU) @ 98 +3324.54/s (n=10662188) Rate list standard list 664535/s -- -32% standard 983325/s 48% -- Lexical variables, swap benchmark. Benchmark: running list, standard_global, standard_local, standard_my, + each for at least 10 CPU seconds... list: 10 wallclock secs (10.13 usr + 0.00 sys = 10.13 CPU) @ 40 +4027.75/s (n=4090781) standard_global: 9 wallclock secs (10.05 usr + 0.00 sys = 10.05 CPU) @ 484686.67/s ( +n=4869647) standard_local: 10 wallclock secs (10.03 usr + 0.00 sys = 10.03 CPU) @ 402621.17/s ( +n=4038693) standard_my: 10 wallclock secs (10.80 usr + 0.00 sys = 10.80 CPU) @ 503630.27/s ( +n=5437696) Rate standard_local list standard_global s +tandard_my standard_local 402621/s -- -0% -17% + -20% list 404028/s 0% -- -17% + -20% standard_global 484687/s 20% 20% -- + -4% standard_my 503630/s 25% 25% 4% + --

    Yves / DeMerphq
    ---
    Software Engineering is Programming when you can't. -- E. W. Dijkstra (RIP)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://189113]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2015-07-03 07:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (48 votes), past polls