From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 D20C3BB91 for ; Thu, 13 Jan 2005 18:29:33 +0100 (CET) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.195]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j0DHTX7B013888 for ; Thu, 13 Jan 2005 18:29:33 +0100 Received: by wproxy.gmail.com with SMTP id 50so173028wri for ; Thu, 13 Jan 2005 09:29:32 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=hoOOO+ysFK90IT+nvcHW9QtiIwk/v3Kq3pPVuC9ZWq9Av2lYNTyEY96EIMwm2x5Eul/ymBouMgWjJvvv9r3xHsWeI/jKYrruAt6YjvV3/z+zr4XmaUS/algFB2SiW/DeLq2uyM8j6Bm5SCKG29Cll7KYLQuZP3YTU4V4mvGs+FA= Received: by 10.54.10.9 with SMTP id 9mr334074wrj; Thu, 13 Jan 2005 09:29:32 -0800 (PST) Received: by 10.54.22.70 with HTTP; Thu, 13 Jan 2005 09:29:32 -0800 (PST) Message-ID: Date: Thu, 13 Jan 2005 12:29:32 -0500 From: John Prevost Reply-To: John Prevost To: "Will M. Farr" Subject: Re: [Caml-list] Ocaml sums the harmonic series -- four ways, four benchmarks: floating point performance Cc: shootout-list@lists.alioth.debian.org, caml-list@yquem.inria.fr In-Reply-To: <3D3A6BF5-657B-11D9-A551-000393A34E82@mit.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <3D3A6BF5-657B-11D9-A551-000393A34E82@mit.edu> X-Miltered: at nez-perce with ID 41E6AFFD.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; prevost:01 prevost:01 caml-list:01 ocaml:01 wrote:01 invocation:01 ocamlopt:01 -unsafe:01 -noassert:01 int-:01 ocaml:01 slowest:01 recursion:01 compiler:01 compiler:01 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_BY_IP autolearn=disabled version=3.0.0 X-Spam-Level: On Thu, 13 Jan 2005 10:53:16 -0500, Will M. Farr wrote: > Each invocation was compiled with "ocamlopt -unsafe -noassert > -o harmonic harmonic.ml". It looks like using references and > loops is *by far* the fastest (and also that my PowerBook is > pretty slow to convert int->float, but I don't think this is > related to ocaml, since the C version does the same thing). Note that this is dependent on what CPU you're using. On my test system (700MHz AMD Athlon with 256MB of memory), I saw this behavior: time ./harmonic 1000000000: harmonic: you: 2m01.590s .. 0m00.790s me: 0m30.811s .. 0m00.120s harmonic2: you: 2m00.340s .. 0m00.440s me: 0m30.847s .. 0m00.140s harmonic3: you: 1m44.350s .. 0m00.740s me: 0m38.002s .. 0m00.130s harmonic4: you: 1m12.680s .. 0m00.430s me: 1m14.603s .. 0m00.220s So on this system, harmonic4 is by far the slowest, and the fastest version is the one that uses float_of_int and tail recursion. It's unclear to me how much of this is that the Intel compiler is simply better optimized than the PPC compiler. John.