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 E479FBC88 for ; Thu, 10 Feb 2005 18:55:03 +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 j1AHt3u0014455 for ; Thu, 10 Feb 2005 18:55:03 +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 SAA30587 for ; Thu, 10 Feb 2005 18:55:03 +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 j1AHt2TK014451 for ; Thu, 10 Feb 2005 18:55:03 +0100 Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf1007.wanadoo.fr (SMTP Server) with ESMTP id CF5FF2800157 for ; Thu, 10 Feb 2005 18:55:02 +0100 (CET) Received: from nono (ARouen-106-1-2-213.w217-128.abo.wanadoo.fr [217.128.67.213]) by mwinf1007.wanadoo.fr (SMTP Server) with SMTP id 72C7A2800153 for ; Thu, 10 Feb 2005 18:55:02 +0100 (CET) X-ME-UUID: 20050210175502471.72C7A2800153@mwinf1007.wanadoo.fr Message-ID: <015f01c50f99$e8a57e60$d54380d9@mshome.net> From: =?UTF-8?Q?Fr=C3=A9d=C3=A9ric_Gava?= Cc: "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> Subject: Re: [Caml-list] Memory allocation nano-benchmark. Date: Thu, 10 Feb 2005 18:56:54 +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 420B9FF7.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 420B9FF6.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; gava:01 gava:01 caml-list:01 arrays:01 oups:01 bug:01 arrays:01 closures:01 ric:98 ric:98 frederic:03 let:03 let:03 modify:05 table:93 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: Peraps test the following code (I do not have test it) > let tmp1=Array.create tablesize 0 in > let tmp2 = Array.create tablesize (Array.copy tmp1) in > let table = Array.create tablesize (Array.copy tmp2) in > 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 > (copy are used to not have the same arrays ) Oups !!!! The "Array.copy" is here a bug because we would do not have copies of the arrays. A better code would be: let table = Array.create tablesize [| [| |] |] in (* modify the array table to not have arrays*) 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; (* create the good values *) 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 I do not have test this code (I do not used my computer) but it does not create closures. Regards, Frédéric Gava