From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id F3B66BC88 for ; Thu, 10 Feb 2005 20:56:53 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j1AJur0U016842 for ; Thu, 10 Feb 2005 20:56:53 +0100 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 UAA02483 for ; Thu, 10 Feb 2005 20:56:53 +0100 (MET) Received: from mailout10.sul.t-online.com (mailout10.sul.t-online.com [194.25.134.21]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j1AJuqeh016839 for ; Thu, 10 Feb 2005 20:56:53 +0100 Received: from fwd02.aul.t-online.de by mailout10.sul.t-online.com with smtp id 1CzKQm-0001d9-00; Thu, 10 Feb 2005 20:56:52 +0100 Received: from [217.82.239.182] (b7YfvTZQoehJrN6u8qkg19lrQsQQ9mdy6WmrSGBzpdTJSP6DZM0-6v@[217.82.239.182]) by fwd02.sul.t-online.com with esmtp id 1CzKQe-2ANgqO0; Thu, 10 Feb 2005 20:56:44 +0100 Message-ID: <420BBC7D.5070103@t-online.de> Date: Thu, 10 Feb 2005 20:56:45 +0100 From: Christian Szegedy User-Agent: Mozilla Thunderbird 1.0 (X11/20050131) X-Accept-Language: en-us, en MIME-Version: 1.0 To: caml-list Subject: Re: [Caml-list] Memory allocation nano-benchmark. References: <420B7A7E.90504@or.uni-bonn.de> <005101c50f7f$6db0e560$d54380d9@mshome.net> <1108048745.16698.101.camel@pelican.wigram> <014801c50f8e$a08e9a40$d54380d9@mshome.net> <015f01c50f99$e8a57e60$d54380d9@mshome.net> In-Reply-To: <015f01c50f99$e8a57e60$d54380d9@mshome.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ID: b7YfvTZQoehJrN6u8qkg19lrQsQQ9mdy6WmrSGBzpdTJSP6DZM0-6v X-TOI-MSGID: f2197a0a-2062-4280-897d-df2b15edeb7c X-Miltered: at concorde with ID 420BBC85.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 420BBC85.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 gava:01 wrote:01 argv:01 gentoo:01 ocamlopt:01 -unsafe:01 -inline:01 gentoo:01 ocamlopt:01 -unsafe:01 -inline:01 gcc:01 ric:98 int:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: Frédéric Gava wrote: >Peraps test the following code (I do not have test it) > > OK: memnew.ml let test tablesize = let table = Array.create tablesize [| [| |] |] in for i=0 to tablesize - 1 do table.(i) <- ( let tmp=Array.create tablesize [||] in for j=0 to tablesize -1 do tmp.(j) <- Array.create tablesize 0 done; tmp) done; for i = 0 to tablesize - 1 do for j = 0 to tablesize - 1 do for k = 0 to tablesize - 1 do table.(i).(j).(k) <- (i+1)*(j+1)*(k+1) done done done let _ = test (int_of_string Sys.argv.(1)) The results (on an AMD 2000XP): chris@gentoo:~/test$ ocamlopt -unsafe -inline 40 memnew.ml chris@gentoo:~/test$ a.out 300 chris@gentoo:~/test$ time a.out 300 real 0m1.560s user 0m1.391s sys 0m0.105s chris@gentoo:~/test$ ocamlopt -unsafe -inline 40 mem.ml chris@gentoo:~/test$ time a.out 300 real 0m2.106s user 0m1.904s sys 0m0.106s chris@gentoo:~/test$ gcc -O3 -fomit-frame-pointer mem.c chris@gentoo:~/test$ time a.out 300 real 0m0.380s user 0m0.283s sys 0m0.072s So, yours is slightly faster, but both are in the same ballpark and the C version is at least 4X faster.