Re: adjustable array vs hash-table



Slobodan Blazeski wrote:
I could use a hash-table or an adjustable array. Considering the keys
of the hash-table are equal to indices in the array 0.1.2.3.4...
functionality is the same. So which one is more efficient at
a. Expanding when new elements are added when container can't hold
them
b. Accessing elements via index / key.

Hard to tell, because this is probably implementation-dependent. But writing a few simple benchmarks shouldn't be too hard. The predefined 'time macro is your friend. (Put the benchmark in a function, and time a simple call to that function. Putting more complex code inside an invocation of time seems to have a negative effect on results.)


Pascal

--
1st European Lisp Symposium (ELS'08)
http://prog.vub.ac.be/~pcostanza/els08/

My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
.



Relevant Pages

  • Re: Whi is it so lsow?
    ... python, what we mostly use here,but they insist its too slow. ... This is one of the more silly "benchmarks". ... Would you like checked array indexing? ... from datetime import datetime ...
    (comp.lang.eiffel)
  • Re: PAS loop faster than BASM
    ... > I created a BASM function that searches through an array of integers ... To my surprise, it benchmarks at about 10 times slower ...
    (borland.public.delphi.language.basm)
  • Re: A Fast sorting algorithm for almost sorted data
    ... These benchmarks are interesting however they seem to using highly ... random input which is not suitable for my problem as the array of ... sample data sets derived from my current compressor can be found here: ...
    (comp.compression)
  • Re[2]: Giant-free polling [PATCH]
    ... Did you run any benchmarks to prove it? ... > I find list-version much more elegant that using an array. ... > using ifnet structure fields without synchronization, ... > access tointerface's internal mutex, ...
    (freebsd-net)