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