Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Perl: porters

[perl #74650] perlperf.pod wrong example

 

 

Perl porters RSS feed   Index | Next | Previous | View Threaded


perlbug-followup at perl

Aug 10, 2013, 9:26 PM

Post #1 of 1 (15 views)
Permalink
[perl #74650] perlperf.pod wrong example

On Sat Aug 10 09:48:14 2013, occitan [at] esperanto wrote:
> la 2013-08-10 03:36 James E Keenan via RT skribis:
> > On Sun Apr 25 06:21:03 2010, occitan [at] esperanto wrote:
> >> In the dereference benchmark you make exactly the mistake you warn
> of
> >> before: you change several factors at once and show an overdrawn
> >> conclusion. While refactoring out the common $ref->{ref} to access
> it
> >> only once, you unnecessarily also copy both strings to a local
> >> variable. It is this second action that drives the time up, if you
> >> leave that out and run timethese several times your findings are
> still
> >> right, but far less. If however you need a third or more values
> (which
> >> I added of the same length), dereferencing the outer hash only once
> >> becomes a clear winner:
> >>
> >> timethese(1000000, {
> >> '2direct' => sub {
> >> my $x = $ref->{ref}{_myscore} . $ref->{ref}{_yourscore}
> ;
> >> },
> >> '2wrong' => sub {
> >> my $ref = $ref->{ref};
> >> my $myscore = $ref->{_myscore}; # why?
> >> my $yourscore = $ref->{_yourscore}; # why?
> >> my $x = $myscore . $yourscore;
> >> },
> >> '2dereference' => sub {
> >> my $ref = $ref->{ref};
> >> my $x = $ref->{_myscore} . $ref->{_yourscore};
> >> },
> >> '3direct' => sub {
> >> my $x = $ref->{ref}{_myscore} . $ref->{ref}{_yourscore}
> .
> >> $ref->{ref}{_ourscore};
> >> },
> >> '3dereference' => sub {
> >> my $ref = $ref->{ref};
> >> my $x = $ref->{_myscore} . $ref->{_yourscore} .
> >> $ref->{_ourscore};
> > I get "Use of uninitialized value in concatenation (.) or string" on
> the
> > line above.
> >
> >> },
> >> });
> >>
> >> Btw. I have left out the intermediate arrow, making it less of an
> >> eyesore and easier to understand as a two dimensional hash.
> >>
> >> Thank you very much.
> >> Jim Keenan
> >>
>
> You'd obvoiusly have to add _ouscore to the inital hash. I'd also
> look at
> taking a hash slice and joining that, even though I fear it might be
> slower
> (and somewhat messy syntactically.
>
> 안녕히 계세요 / coralament / best Grötens / liebe Grüße / best regards /
> elkorajn salutojn
> Daniel Pfeiffer
>


I have to admit that I'm not comfortable being asked to edit a patch
originally submitted more than three years ago. I think we need
additional eyeballs on Daniel's original critique of pod/perlperf.pod.
Is the code example incorrect? If so, how do we improve it?

Thank you very much.
Jim Keenan

---
via perlbug: queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=74650

Perl porters RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.