Hi Brett,

I declared B so, that no garbage collection occurred in this case, (see the
1'000 in MAKE STRING!) or in any case where not more than 1'000 elements are
changed. That is why I declared it outside of CP.

To measure the time I used my TIME-BLOCK function (can be found at my site
http://www.sweb.cz/LMecir under benchmarks).

It seems that (strangely) the speed of CHANGE/PART depends on the total size
of SAMPLE only. My guess is, that similar results can be obtained using
blocks too.

Cheers
    Ladislav

<<
The CP function code being far faster than the CHANGE native function is
interesting.

Was having B declared outside of CP crucial or was it just to avoid a
potential unfair function overhead on CP?
Both seem very quick. How did you measure the difference in speed?
As you increase the size of the sample string or change the reference points
to change/copy, is there changes in the results?
What of blocks instead of strings?

Brett.
>>

> according to my measurements the CP function defined as follows:
>
> use [b] [
>     b: make string! 1'000
>     cp: func [
>         string [any-string!]
>         value [any-string!]
>         range [any-string! integer!]
>     ] [
>         change string head insert/part clear b value range
>     ]
> ]
>
> Where:
>
>     sample: insert/dup "" #"x" 30'000
>
> Used as:
>
>     cp sample skip sample 1'000 skip sample 2'000
>
> is almost 100 times faster than:
>
>     change/part sample skip sample 1'000 skip sample 2'000
>
> Any comments?
>
> Cheers
>     Ladislav
>


-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to