[REBOL] Re: [series] Series performance was Re: MySQL-protocol.r
From: atruter::labyrinth::net::au at: 3-Jan-2004 17:37
> But I believe that lists and blocks are implemented
> differently internally, but I'm ignorant as to how.
> any comments on this?
Conceptually, a block is just a collection of values where the sequence is
directly known (ie. like an "array" REBOL knows where the Nth value is). A
list on the other hand ensures that each value knows where the previous
and next values are (finding the Nth value in this case involves "walking"
the list one value at a time).
The following test attempts to highlight the strength and weakness of each
series! type (keep in mind that the memory cost of list! / hash! is higher
One million numbers from one through to one million in a 6.75MB file.
Intel Pentium 3.0 GHz with 1GB of RAM.
Operations Per Second
Operation Block! List! Hash!
================== ========= ========= =========
first / last 1,961,614 2,038,423 1,936,023
pick / poke / at 1,844,334 504 1,846,456
find / select (1) 1,546,259 1,538,385 1,399,606
find / select (2) 52 51 1,402,559
foreach 13 20 19
insert 81 1,087,684 19
insert tail 1,032,956 861,769 723,152
change 1,572,834 1,569,881 1,307,086
head / tail / next 1,883,858 1,916,338 1,816,748
remove 80 1,493,110 54
remove tail 1,127,093 1,187,992 1,115,157
(1) First value in series
(2) Last value in series