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
Re: [Caml-list] time complexity on basic data types
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-08-23 (17:23)
From: Krishnaswami, Neel <neelk@c...>
Subject: Re: [Caml-list] time complexity on basic data types
Collin Monahan [] wrote:
> With respect to arrays and lists, is the complexity for operations 
> on these data structures like "normal?" E.g. random access in arrays 
> in constant time, insertion in lists in constant time, random access 
> in lists in linear time . . .

Yep, that's correct.

> What facilities exist for timing constructs in Caml? I see 
>            val times : unit -> process_times
> in the manual, under unix system calls. If this is like the times()
> function in Solaris, then it would work. But I think the Caml syntax 
> is messing me up again, because if I type
>            times();;
> or
>            let foo = times();;
> into the toplevel, the system indicates that "times" is not bound.

Okay, first of all, to reference a name in another module you have
to qualify the name with the module. 

Eg, you'd need to type Unix.times(), rather than just times(). Second,
for reasons I don't understand the Unix library is not linked by 
default, so you need to explicitly specify it when you compile
your programs. (This is described at the top of the chapter on the
Unix library: <URI:>)
In addition to this, you can also use the nice profiler that comes
with the OCaml distribution, which gives you all sorts of fancy 
instruction counts. That's in chapter 16 of the Caml manual:

Neel Krishnaswami
Bug reports:  FAQ:
To unsubscribe, mail  Archives: