in reply to A heap of medians: efficiency vs. speed
Another recent topic here led me to this article: www.sysarch.com/Perl/sort_paper.html. It shows that of two seemingly identical sorts:
@fast = sort @unsorted; @slow = sort { $a <=> $b } @unsorted;
The first one is faster because it runs entirely in C in the Perl core, while the second is slower because the sortsub executes in Perl code.
I was sorting tens of thousands of files by creation time in reverse chronological order, and was delighted to find the first one below faster than the second:
@fast = reverse sort @unsorted; @slow = sort { $b <=> $a } @unsorted;
kyle, I wonder how your median_sort might benchmark if it used my @s = sort @_;?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: A heap of medians: efficiency vs. speed
by kyle (Abbot) on Jan 13, 2009 at 19:29 UTC |