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)


In reply to Re: Re: Re: Re: Faster Perl, Good and Bad News by demerphq
in thread Faster Perl, Good and Bad News by abitkin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.