Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: 2003-05-04 (07:55)
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 

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

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: