Taylan Ulrich Bayirli/Kammer <taylanbayi...@gmail.com>:

> Marko Rauhamaa <ma...@pacujo.net> writes:
>
>> Yes. In my recent tests, I found (assq-ref) was twice as fast as
>> (hashq-ref) when there were 100 entries even when I made the hash
>> table quite large (1000 entries IIRC).
>
> Do you mean the averages?

I was looking for the 50th entry.

> For me, accessing the *first* entry of an alist already seems to be
> almost as slow as accessing any entry of a hash table, and accessing
> the 100th about thrice as slow.

Ok. I ran the test again, with a couple of parameter settings this time
round:

   ===================================================
   Data Structure    # Entries   Look-up Duration (µs)
   ===================================================
   hash-table           2000           0.37
   alist                2000           5.88
   AVL tree             2000          15.65
   hash-table            100           0.35
   alist                 100           0.31
   AVL tree              100          11.09
   ===================================================

The entry that was looked up was the middle element. The lookup was
performed 1,000,000 times. The AVL tree was wholly implemented in
scheme.

So the alist wasn't "twice as fast". Must have been with fewer entries.


Marko

Reply via email to