RE: [REBOL] Re: newlines

Hi Joel, Ladislav,

keep in mind not to trigger unfair gc's because of a
non-real-world amount of loops and therefore garbage.
it looks the most time competing algorithm at 10000
slows down heavily with 30000 without good reason.
it uses parse too, but with copy instead of markers,
so it produces more garbage. could go over a limit
with 30000 so it starts triggering gc's.
so benchmarking with different loop-counts
(=different amount of garbage) is a good idea.
 
also use a reasonable amout of pre-alocation, like
out: make string! 50000 without producing garbage..
wrong pre-allocation slows down heavy, AFAIK a bug..
i doubt you will see a slowdown by a single
allocation, even if large.
btw you know the trick of using[out: clear [] ] for static buffers
and using [return copy out]?
Gabriele noted it while ago, pretty for self-adjusting
programms. 

after you have done this, switch to garbage-free 
[insert clear s out]
which copies the result back to the input string,
instead of allocating something.
this should run at native speed. 
IIRC there was no notable slowdown, but i benchmarked
a bit lazy.
as i said, i was not aware of having the fastest 
looking algorithm..

-Volker

[EMAIL PROTECTED] wrote:
> 
> Hi, Ladislav,
> 
> Ladislav Mecir wrote:
> > 
> > I would like to comment the speed of the INS1 algorithm:
> > 
> > <<
> >         out: clear ""
> >         parse/all s [
> >             any [
> >                 start: thru "..." end1: any "." (
> >                     insert/part tail out start back end1
> >                 )
> >             ]
> >         ]
> >         insert tail out start
> >         out
> > >>
> > 
> > The way the algorithm is designed gives it an unfair advantage
> > when it is timed in a loop where it is executed more than once...
> >
> 
> Good observation for follow-up; thanks!
> 
> I'll be glad to make a version that uses COPY "" and re-run the
> benchmarks with both.
> 
> -jn-
> 
> -- 
> This sentence contradicts itself -- no actually it doesn't.
> -- Doug Hofstadter
>                               joel<dot>neely<at>fedex<dot>com
> -- 
> To unsubscribe from this list, please send an email to
> [EMAIL PROTECTED] with "unsubscribe" in the 
> subject, without the quotes.
> 
-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to