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
[Caml-list] O'Caml vs C++: a little benchmark
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-08-28 (13:47)
From: John Max Skaller <skaller@o...>
Subject: Re: [Caml-list] O'Caml vs C++: a little benchmark
Oleg wrote:

>>	single_pass xb (sum +. float x)
>>you have a float conversion -- creates a new heap element.
>>Try changing the tests to do integer operations,
>>they should be comparable then.
> The C++ version contains the same conversion (with the exception that int is 
> native, but that's the price O'Caml is willing to pay, right?)  And why heap? 

Because Ocaml only has two (runtime) data types:
integer and pointer to  heap object (boxed object).
Heap allocations inside a loop are bound to be slower
than the same loop without them. So if you try an integer
above, you can see the price of boxing.

> BTW does O'Caml inline tail-recursive functions?

Do you mean loop unrolling? I hear that it doesn't
do loop unrolling. [There's nothing to gain from
a simple inlining, unless the loop is only executed
once or twice - you'd only save a single function call]

John Max Skaller, mailto:skaller@ozemail.com.au
snail:10/1 Toxteth Rd, Glebe, NSW 2037, Australia.

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