From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA20035; Wed, 28 Aug 2002 15:47:45 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA19809 for ; Wed, 28 Aug 2002 15:47:44 +0200 (MET DST) Received: from mail3.tpgi.com.au (mail.tpgi.com.au [203.12.160.59]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g7SDlgX20811 for ; Wed, 28 Aug 2002 15:47:42 +0200 (MET DST) Received: from ozemail.com.au (syd-ts15-2600-187.tpgi.com.au [203.213.83.187]) (authenticated (0 bits)) by mail3.tpgi.com.au (8.11.6/8.11.6) with ESMTP id g7SDitQ09907; Wed, 28 Aug 2002 23:44:55 +1000 Message-ID: <3D6CD46E.1030701@ozemail.com.au> Date: Wed, 28 Aug 2002 23:47:26 +1000 From: John Max Skaller User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.2.1) Gecko/20010901 X-Accept-Language: en-us MIME-Version: 1.0 To: Oleg CC: caml-list@inria.fr Subject: Re: [Caml-list] O'Caml vs C++: a little benchmark References: <200208181716.NAA10426@hickory.cc.columbia.edu> <3D66A3A0.1090901@ozemail.com.au> <200208232134.RAA09914@dewberry.cc.columbia.edu> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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. voice:61-2-9660-0850 ------------------- 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