Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: Lazy evaluation & performance
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Damien Doligez <Damien.Doligez@i...>
Subject: Re: Lazy evaluation & performance
>From: Benoit de Boursetty <debourse@email.enst.fr>

>Has anybody done benchmarks to eval the cost of lazy computation
>encapsulation, in terms of time, memory, garbage collection? I have no
>idea of how this is implemented...

In all the versions of O'Caml so far,
    lazy (some expression)
is exactly equivalent to
    Pervasives.ref (Lazy.Delayed (fun () -> (some expression)))
.

>Could anybody give me a hint about the order of magnitude of L?

Memory: two one-field blocks plus a closure (arbitrarily big,
depending on the free variables of your expression).

Time: whatever it takes to allocate the above, i.e. not much.
Certainly less than a dozen flops.  Maybe even less than one flop, but
that may depend on the compiler (bytecode or native) and on the
architecture.

-- Damien