English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Memory allocation nano-benchmark.
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-02-11 (13:04)
From: skaller <skaller@u...>
Subject: Re: [Caml-list] Memory allocation nano-benchmark.
On Fri, 2005-02-11 at 20:22, Frédéric Gava wrote:

> You could write;
> for i=0 to tablesize -1 do
>  let row1 = table.(i) in
>  for j=0 to tablesize -1 do
>   let row2 = row1.(j) do
>   for k=0 to tablesize -1 do
>    row2.(k) <- (i+1)*(j+1)*(k+1)
>  done done done
> and peraps you will have a faster code.

I found no difference, here are two runs:

[skaller@pelican] ~>time ./zmem 250
real    0m3.110s
user    0m2.820s
sys     0m0.240s

[skaller@pelican] ~>time ./zmem 250
real    0m27.732s
user    0m2.750s
sys     0m0.340s

The huge 'real' time there is VM paging.

Perhaps Xavier will bless us with a comment as to
whether invariant code motion optimisation is actually
done in 

        table.(i).(j).(k) <- (i+1)*(j+1)*(k+1)

Using bigarray (c_layout):
real    0m27.948s
user    0m0.770s
sys     0m0.500s

.. 4 times faster.

John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net