Hi,

Gabriele writes:

>Hello [EMAIL PROTECTED]!
>
>On 11-Gen-00, you wrote:
>
> l>>> st/start a: empty-il for i 1 20000 1 [a: prepend i a]
> l>>> st/stop
> l> == 0:00:03
> l>>> st/start a: copy [] for i 1 20000 1 [insert a i] st/stop
> l> == 0:01:36
>
>You're not fair, Ladislav!
>
>>> t: now/time a: make list! [] for i 1 2000 1 [insert a i] (now/time - t)
>== 0:00:02
>>> t: now/time a: make block! [] for i 1 2000 1 [insert a i] (now/time - t)
>== 0:00:13
>
>Trying to test with your immutable lists made REBOL crash with a
>guru on my Amiga (this is the first time I get a guru from
>REBOL!); I'll have to spend some time on this...
>
>Regards,
>    Gabriele.

I crashed too, in windows, trying to do PRINT MOLD A. Still, it seems to
work otherwise.

>> tic a: empty-il for i 1 20000 1 [a: prepend i a] toc
elapsed time: 0:00:01
>> a/what
== 20000
>> a/nxt/what
== 19999
>> a/nxt/nxt/what
== 19998
>> b: a loop 19000 [b: b/nxt] b/what
== 1000

That's fun. Is it fast?

>> tic loop 10 [b: a loop 19000 [b: b/nxt] b/what] toc
elapsed time: 0:00:09

Oooh, that's kinda slow.

>> a: copy [] tic for i 1 20000 1 [insert a i] toc
elapsed time: 0:00:51

That was slow all right, but:

>> tic loop 1000000 [pick a 19000] toc
elapsed time: 0:00:03

is not too shabby.


Gabriele points out that inserting at the head with lists is much faster.
Also appending to blocks is much faster than inserting at the head. The
longer the blocks get, the longer the insertion takes. Appending takes
longer too, but the performance hit isn't nearly so bad.

>> a: copy [] tic loop 10 [for i 1 1000 1 [insert a i] toc]
elapsed time: 0:00
elapsed time: 0:00:01
elapsed time: 0:00:01
elapsed time: 0:00:02
elapsed time: 0:00:03
elapsed time: 0:00:05
elapsed time: 0:00:07
elapsed time: 0:00:09
elapsed time: 0:00:11
elapsed time: 0:00:13
>> a: copy [] tic loop 10 [for i 1 1000 1 [append a i] toc]
elapsed time: 0:00
elapsed time: 0:00
elapsed time: 0:00
elapsed time: 0:00
elapsed time: 0:00
elapsed time: 0:00
elapsed time: 0:00:01
elapsed time: 0:00:01
elapsed time: 0:00:01
elapsed time: 0:00:01

See you,
Eric

Reply via email to