On 1/10/06, Steve Bertrand <[EMAIL PROTECTED]> wrote:

> Just to ensure the most efficient possible run, I've been doing tests
> with benchmark.

Hey, this is no place for empirical evidence! :-)

> Benchmark: running a, b, each for at least 10 CPU seconds...
>          a: 11 wallclock secs (10.59 usr +  0.01 sys = 10.60 CPU) @
> 79531.20/s (n=843155)
>          b: 11 wallclock secs (10.44 usr +  0.02 sys = 10.45 CPU) @
> 20665.69/s (n=216021)

Those values of n are the number of times the code could run during 10
CPU seconds. Algorithm a is accomplishing four times as much as
algorithm b in the same time. That means that b, the do-nothing
Schwartzian Transform, is 1/4 the speed of the simpler way of doing a
numeric sort. (The latter, I suspect, is internally optimized, too, so
the results aren't surprising. The S.T. would do better if it weren't
competing against that optimization, but it would, I'm sure, still
lose.) Needless to say, this result is heavily dependent upon the data
set and data size, so don't count on this four-to-one ratio in
general.

There's no reason to expect a do-nothing S.T. to speed general numeric
sorting, any more than you should expect to speed up your daily dental
ritual by trying to use 32 toothbrushes in parallel. The S.T. is
useful when a sort is expensive, but can be transformed into one
that's less expensive. That's why the word "Transform" is in there, in
fact. When you don't need to transform anything, you shouldn't.

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to