From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 4B0B2BB81 for ; Sun, 5 Mar 2006 12:52:09 +0100 (CET) Received: from ptb-relay03.plus.net (ptb-relay03.plus.net [212.159.14.214]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k25Bq81l016193 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Sun, 5 Mar 2006 12:52:08 +0100 Received: from [80.229.56.224] (helo=chetara) by ptb-relay03.plus.net with esmtp (Exim) id 1FFrmR-0000i2-Vn for caml-list@yquem.inria.fr; Sun, 05 Mar 2006 11:52:08 +0000 From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Benchmarks against imperative languages Date: Sun, 5 Mar 2006 11:54:07 +0000 User-Agent: KMail/1.9.1 References: <20060304143608.GA16996@ours.starynkevitch.net> In-Reply-To: <20060304143608.GA16996@ours.starynkevitch.net> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <200603051154.07774.jon@ffconsultancy.com> X-Miltered: at nez-perce with ID 440AD0E8.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 basile:01 ocaml:01 ocaml:01 vastly:01 optimising:01 solver:01 ocamlopt:01 optimise:01 compilers:01 kloc:01 cited:01 worst-case:01 infeasible:01 compares:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 On Saturday 04 March 2006 14:36, Basile STARYNKEVITCH wrote: > We all know (by experience) that Ocaml performs quite well. We also > know that for most (but not all) of the software we are coding, the > cost and time of development does significantly matter, and a 10% > decrease in performance is not that important, hence Ocaml brings a > real win. Yes and no. I think the relative performance of OCaml is quite variable. Here is a range of examples: 1. Straightforwardly-implemented algorithms can be vastly faster when written in a functional style and optimising imperative equivalents can be tricky, e.g. set theoretic operations and the "n"th-nearest neighbour example from my ocaml book: http://www.ffconsultancy.com/products/ocaml_for_scientists/complete/ 2. Any problems that are near the limit of practical feasibility are likely to benefit enormously from improved development time. This includes the limits of computational complexity, memory usage and algorithm-implementation complexity. 3. Floating-point intensive algorithms can be miraculously (IMHO) fast for an FPL, e.g. my ray tracer benchmark on AMD (particularly AMD64): http://www.ffconsultancy.com/free/ray_tracer/languages.html 4. Certain operations can be surprisingly slow, e.g. my Sudoku solver is several times slower in OCaml because ocamlopt does not optimise integer div or mod by a constant: http://www.ffconsultancy.com/free/sudoku/ The relative development speed in OCaml and C++ is also quite variable. Some applications, like compilers and interpreters, clearly benefit enormously from languages like OCaml. Other applications, like small and simple numerical programs (e.g. the ray tracer) benefit from the availability of libraries like Blitz++ and Boost for C++. In the former case, development can be an order of magnitude faster in OCaml. In the latter case, the time taken to develop similar-performance programs can be roughly the same. > A real answer would be to have a team of programmers fluent in Ocaml > write a code (an real-sized application of hundreds of KLOC of source > code, representing several man-years of effort) which has exactly the > same precise specification than an existing code written in C. But > this will never happen (it is too costly but quite useless an > experiment). For example, nobody will recode in Ocaml an exact clone > of gcc-4.1, firefox-1.5, or mysql-5.0! I have cited my most relevant example before - a vector graphics library which was 4x longer in C++, the worst-case performance was 5x faster in OCaml and the development time was an order of magnitude faster in OCaml. It was a rewrite from C++ to OCaml, so it is biased. However, I ditched C++ because it was infeasible to do the rewrite in C++ and I have not looked back since. Also, I can't say how OCaml compares to other FPLs. The code size was ~10kLOC. -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. Objective CAML for Scientists http://www.ffconsultancy.com/products/ocaml_for_scientists