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 4F3DBBC88 for ; Fri, 11 Feb 2005 00:56:17 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j1ANuGBB021147 for ; Fri, 11 Feb 2005 00:56:17 +0100 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 AAA11215 for ; Fri, 11 Feb 2005 00:56:16 +0100 (MET) Received: from smtp10.wanadoo.fr (smtp10.wanadoo.fr [193.252.22.21]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j1ANuGEC021143 for ; Fri, 11 Feb 2005 00:56:16 +0100 Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf1008.wanadoo.fr (SMTP Server) with ESMTP id 3DB212800149 for ; Fri, 11 Feb 2005 00:56:16 +0100 (CET) Received: from nono (ARouen-106-1-2-213.w217-128.abo.wanadoo.fr [217.128.67.213]) by mwinf1008.wanadoo.fr (SMTP Server) with SMTP id DD2A12800148 for ; Fri, 11 Feb 2005 00:56:15 +0100 (CET) X-ME-UUID: 20050210235615905.DD2A12800148@mwinf1008.wanadoo.fr Message-ID: <01a001c50fcc$5cff2fe0$d54380d9@mshome.net> From: =?UTF-8?Q?Fr=C3=A9d=C3=A9ric_Gava?= To: "caml-list" 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> <420BBC7D.5070103@t-online.de> Subject: Re: [Caml-list] Memory allocation nano-benchmark. Date: Fri, 11 Feb 2005 00:58:05 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-Miltered: at nez-perce with ID 420BF4A0.003 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 420BF4A0.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; gava:01 gava:01 caml-list:01 gentoo:01 ocamlopt:01 -unsafe:01 -inline:01 gentoo:01 ocamlopt:01 -unsafe:01 -inline:01 gcc:01 gcc:01 ocaml:01 ocaml's: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: Hi, There is a function in the stdlid for have a beter code: let test tablesize = let table = Array.create tablesize [| [| |] |] in for i=0 to tablesize - 1 do table.(i) <- Array.make_matrix tablesize tablesize 0 done; ... smaller code no ? ;-) > 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. :-( Peraps due to the fact that "int" are boxed. Try to give "options you give to gcc" to ocamlopt to link optimized code. Else I do not know how to optimize this code "in a pure ocaml way" (i.e without trick with C code). Is caml guru, wizards or ocaml's creators have an idea ? Regards, Frédéric Gava