Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Efficiency of 'a list
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Ville-Pertti Keinonen <will@e...>
Subject: Re: [Caml-list] Efficiency of 'a list
> I've done a little timing of things, and according to my results:
> If you care about efficiency and use OCaml, you should use lists
> fairly often, ie if you are always looping and accessing the elements
> in order. OCaml can iterate through a list (recursively) about twice as
> fast as it can iterate through an array.  It can iterate through a
> list about as fast as or maybe even a little faster than C or C++ can
> iterate through an array.

Don't trust microbenchmarks too far over what your knowledge of how 
things should work tell you.

Iterating over arrays is certainly going to be much more cache- and 
TLB-friendly.

BTW: Did you try turning off bounds checking?  The OCaml optimizer 
isn't smart enough to get rid of them.

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners