Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Re: Efficiently sorting array by non-alpha strings

by knowmad (Monk)
on Feb 20, 2004 at 17:04 UTC ( [id://330604]=note: print w/replies, xml ) Need Help??


in reply to Re: Efficiently sorting array by non-alpha strings
in thread Efficiently sorting array by non-alpha strings

I did fix a few typos but my benchmark isn't nearly as sophisticated as yours. I reran the tests using your code and am getting similar results, albeit my rate is much slower :(.

Following BorisZ's comment, I placed the hash setup outside the cmpthese and indeed it is coming out as the speed demon. Interesting, I tried doing the same with the my %bucket line in your code and the performance decreased dramatically. I guess that using local variables provides better performance than globals?

Thanks again for the insights!

-Wm

Replies are listed 'Best First'.
Re: Efficiently sorting array by non-alpha strings
by Abigail-II (Bishop) on Feb 20, 2004 at 17:12 UTC
    Referring to lexical variables from within a Benchmark is the mistake made most often when benchmarking. And a very large percentage of the benchmarks I've seen in the past years make this mistake. It has prompted me to give a talk about this (and other mistakes) at YAPC::NA last year.

    Moving my %h from BorisZ code to the main program is wrong. Moving my %bucket from my code to the main program is wrong (although for a different reason!).

    Abigail

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-04-19 23:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found