in reply to sort routines crossing package lines
though the docs for sort say this is slower than using the un-prototyped version with $a and $b.sub caseless ($$) { lc $_[0] cmp lc $_[1] }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: sort routines crossing package lines
by ikegami (Patriarch) on Nov 24, 2004 at 22:32 UTC | |
Update: I'm now saving the values for more realism, and corrected the extra 's' BrowserUK mentioned (which I had already fixed in the .pl file, just not in the post). Some concrete numbers:
Here's a different comparison: (One that yeilds less unfair optimization)
Active Perl 5.6.1 | [reply] [d/l] [select] |
by BrowserUk (Patriarch) on Nov 24, 2004 at 23:37 UTC | |
Not optimisations, errors.
Examine what is said, not who speaks.
"But you should never overestimate the ingenuity of the sceptics to come up with a counter-argument." -Myles Allen"Think for yourself!" - Abigail "Time is a poor substitute for thought"--theorbtwo "Efficiency is intelligent laziness." -David Dunham "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon | [reply] [d/l] |
by DrWhy (Chaplain) on Nov 24, 2004 at 23:37 UTC | |
I'm not terribly surprised that inline is faster than the other named sub methods, but am quite surprsied that the 'args' version is the fastest. Update: Okay, adding an assignment in the benchmarked code gives more sensible results:
--DrWhy
"If God had meant for us to think for ourselves he would have given us brains. Oh, wait..." | [reply] [d/l] [select] |
by BrowserUk (Patriarch) on Nov 24, 2004 at 23:14 UTC | |
An interesting anomoly: sub argsless ... argless => sub { sort arg?less Examine what is said, not who speaks.
"But you should never overestimate the ingenuity of the sceptics to come up with a counter-argument." -Myles Allen"Think for yourself!" - Abigail "Time is a poor substitute for thought"--theorbtwo "Efficiency is intelligent laziness." -David Dunham "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon | [reply] |