Arrays vs tuples / lists

Ulf Wiger <>
Mon May 17 21:14:11 CEST 2004


On Mon, 17 May 2004 18:13:01 +0200 (CEST), Thomas Johnsson 
<> wrote:

>>
>> As long as you only look up stuff in large tuples,
>> access is very fast and O(1).
>
> Splendid! Presumably it is faster than an ets table lookup with an 
> integer
> as key; by how much, roughly?
>
> -- Thomas
>

Well, it's reasonably easy to measure (at least on UNIX...)
(I've enclosed a small test program, and a test run on a 3GHz XP box.)

/Uffe

Erlang (BEAM) emulator version 5.3 [threads:0]

Eshell V5.3  (abort with ^G)
1> cd("c:/cygwin/home/foo/erl").
c:/cygwin/home/foo/erl
ok
2> c(test).
{ok,test}
3> test:tup(1000,small).
{625000,ok}
4> test:tup(1000,medium).
{609000,ok}
5> test:tup(1000,big).
{609000,ok}
6> test:ets(1000,small).
{4156000,ok}
7> test:ets(1000,medium).
{8718000,ok}
8> test:ets(1000,big).
{138594000,ok}
9> test:empty(1000).
{531000,ok}
10>

-- 
Ulf Wiger
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.erl
Type: application/octet-stream
Size: 1524 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20040517/11d3a0a4/attachment.obj>


More information about the erlang-questions mailing list