[REBOL] Re: Trimming values from a series?
From: joel:neely:fedex at: 29-Jul-2002 14:36
Just back from a week camping in the Great Smoky Mountains National
Park, and my inbox prompts me to do a quick benchmark...
Ed Dana wrote:
> Carl Read wrote:
> >On 25-Jul-02, Ed Dana wrote:
> >>Maybe the algorithm is something similar to what's used for some
> >>compression schemes?
> >Getting the unique values from a string would be simple. Just have an
> >array of 256 flags and tick them as found based on the char values as
> >you parse once through the string. Blocks of mixed datatypes
> >wouldn't be quite so easy though...
> Of course, but somehow I think I'll need to sort more than 256 things,
> some day. :)
For the test below, both BSU and BUS are initialized as copies of a
series that contains 500 copies of the integers from 1 to 500 (making
250000 integer values in all). (Console transcript wrapped for email
>> t0: now/time/precise rbus: unique sort bus
t1: now/time/precise rbsu: sort unique bsu
t2: now/time/precise print [to-decimal t1 - t0 to-decimal t2 -
I got consistent results over multiple trials, so UNIQUEing first
and then SORTing appears faster for blocks of integers than the
other order. Independent tests showed that applying only UNIQUE
to such a block is faster than applying SORT, so I conclude that
UNIQUE is not simply sort-and-sweep.