From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id RAA21707 for caml-redistribution; Thu, 7 Oct 1999 17:50:09 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id OAA16388 for ; Thu, 7 Oct 1999 14:59:25 +0200 (MET DST) Received: from nenuphar.saclay.cea.fr (nenuphar.saclay.cea.fr [132.166.192.7]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id OAA08590 for ; Thu, 7 Oct 1999 14:59:24 +0200 (MET DST) Received: from muguet.saclay.cea.fr (muguet.saclay.cea.fr [132.166.192.6]) by nenuphar.saclay.cea.fr (8.9.1a/8.9.1/CEAnet-relay-5.0.D20) with ESMTP id OAA09346 for ; Thu, 7 Oct 1999 14:59:24 +0200 (MET DST) Received: from harpie.saclay.cea.fr (harpie.saclay.cea.fr [132.166.133.152]) by muguet.saclay.cea.fr (8.9.1a/8.9.1/CEAnet-relay-5.1.D20) with ESMTP id OAA07425; Thu, 7 Oct 1999 14:59:23 +0200 (MET DST) Received: by harpie.saclay.cea.fr (8.8.8+Sun/CEANET.2.0.1) id PAA21744; Thu, 7 Oct 1999 15:00:13 +0200 (MET DST) From: STARYNKEVITCH Basile MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit Message-ID: <14332.39261.289821.218167@gargle.gargle.HOWL> Date: Thu, 7 Oct 1999 15:00:13 +0200 (MET DST) To: caml-list@inria.fr Subject: Re: speed versus C X-Mailer: VM 6.75 under Emacs 20.4.1 Content-Transfer-Encoding: 8bit Content-Transfer-Encoding: 8bit Sender: weis in september 1998, on a previous job (in the same organization, CEA, but in a different department), I did work (several months) on benchmarking various langages and implementations. My former collegue Emmanuel Dorlet asked me to mail some timing results. My tiny benchmark was related to computing the sum of inverses of integers (a serie converging to pi^2/6 as we all know) let onsquare i j = let ii = float i and jj = float j in ii /. ( jj *. jj) ;; let test2 n p = for i=1 to p do let rec loop j s = if (j <= 0) then s else loop (j-1) (s +. onsquare i j) in let s = loop n 0.0 in Format.printf "n=%d i=%d s=%f\n" n i s done ;; On that time I benched ocaml 1.07 or 2.00. Plateform was a PC/Linux (Redhat-5.2, Pentium II 300? MHz). Here are the results, mesuring the internal iteration time (running equivalent of test2 1000000 50, or test2 10000 50 for slow implementations), which is the total CPU time divided by n*p Notice that this benchmark is a numerical test, and numbers is a domain where Ocaml is rather poor (integers are tagged, and floating point numbers are often boxed) I tested ocaml in an imperative (for loop with reference) and functional (terminal recursion) langage impl. time/iteration slowdown/C CPU microsec Fortran77 compiled 0.124µs 0.95 C compiled 0.131µs 1 Ocaml1.07 compiled 0.408µs 3.11 Java {JDK1.1.5} 1.31µs 10 Ocaml {1.07 fonctionnal} 1.92µs 14.66 Ocaml {1.07 impérative} 2.014µs 15.37 Ocaml {2.00 fonctionnal} 2.112µs 16.12 Lua 3.1 3.43µs 26.18 Scheme {vscm 0.4} 16.64µs 127 Python 1.5 17.93µs 137 Perl 5.003 18.62µs 142 Scheme {guile 1.2} 34.37µs 262 Tcl8.0 158.3µs 1208 Gibiane 2656µs 20275 For your information, Gibiane was an internal scripting langage (simliar to Tcl, implemented in a Fortran dialect) which should now be dismissed. My personal opinion is that there are domain (such as tree manipulation) where Ocaml outperform C or C++ (but that did not convince my current boss). Choosing Ocaml is not a technical issue. It is a managerial and psychological issue. I am bad on both. Regards. N.B. Any opinions expressed here are only mine, and not of my organization. N.B. Les opinions exprimees ici me sont personnelles et n engagent pas le CEA. --------------------------------------------------------------------- Basile STARYNKEVITCH ---- Commissariat à l Energie Atomique DTA/LETI/DEIN/SLA * CEA/Saclay b.528 (p111f) * 91191 GIF/YVETTE CEDEX * France phone: 1,69.08.60.55; fax: 1.69.08.83.95 home: 1,46.65.45.53 email: Basile point Starynkevitch at cea point fr