SPUG: Does Perl Scale? (Was: Evolution of Perl)
Ken McGlothlen
mcglk at artlogix.com
Mon Aug 13 19:24:28 CDT 2001
Bill Campbell <bill at celestial.com> writes:
| [...] I cut the run time from 20 minutes down to under 2 by replacing one
| statement in a subroutine that was executed 20,000 times per run where the
| engineer (I'm a scientist, not a programmer), calculated the square root of
| PI/2 each time the subroutine was called. [...] Of course compiler
| technology has progressed a bit since the Bendix Mishawaka (sp?) FORTRAN of
| 1966, but the principle's the same.
Absolutely. The worst-case scenario I ever ran into was with a program (in C)
that crunched a lot of statistics. It would take around three days to run with
a 4,000,000 record dataset, and was about 25K lines long.
One day, testing a revision I'd done elsewhere in the code, I started noticing
a curious pattern: O(n^2). So I grepped the source code for "sort," out of
curiosity, and discovered the lines:
int sortdata {
# look up quicksort and replace when i have time -gb
[... code for bubblesort ...]
}
Oh, how I cackled with glee. :) Not only could I improve the program, but the
local C library had a qsort routine supplied already. Some judicious whacking
followed by a single call, and the same 4,000,000 records were being done in
less than half an hour.
They thought I'd broken it. In fact, *insisted* that I broke it. Showing them
identical results didn't convince them. The original programmer, they
insisted, was brilliant, and I couldn't have improved it *that* much (in fact,
he was an awful programmer, and I was constantly fixing issues). I showed them
the original code, with the comment, but even that wasn't convincing enough.
Eventually, I gave up, and said that I'd restore it, so I did. Later on, I
talked them into an insertion sort (they understood that), but I just couldn't
get them to go for the quicksort.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
More information about the spug-list
mailing list