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 D71E4BC88 for ; Fri, 11 Feb 2005 10:20:55 +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 j1B9Ktlk022656 for ; Fri, 11 Feb 2005 10:20:55 +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 KAA32314 for ; Fri, 11 Feb 2005 10:20:55 +0100 (MET) Received: from smtp7.wanadoo.fr (smtp7.wanadoo.fr [193.252.22.24]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j1B9KsWC015431 for ; Fri, 11 Feb 2005 10:20:54 +0100 Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf0704.wanadoo.fr (SMTP Server) with ESMTP id 98AEA14000BA; Fri, 11 Feb 2005 10:20:54 +0100 (CET) Received: from nono (ARouen-106-1-12-162.w80-11.abo.wanadoo.fr [80.11.244.162]) by mwinf0704.wanadoo.fr (SMTP Server) with SMTP id 23A6E14000B5; Fri, 11 Feb 2005 10:20:54 +0100 (CET) X-ME-UUID: 20050211092054146.23A6E14000B5@mwinf0704.wanadoo.fr Message-ID: <002401c5101b$4130b640$a2f40b50@mshome.net> From: =?UTF-8?Q?Fr=C3=A9d=C3=A9ric_Gava?= To: "Christian Szegedy" , "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 10:22:48 +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 concorde with ID 420C78F7.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 420C78F6.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; gava:01 gava:01 caml-list:01 ocaml:01 ocaml:01 ric:98 ric:98 faq:01 caml:02 slightly:02 frederic:03 numerical:03 let:03 let:03 inria:05 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, > So, yours is slightly faster, but both are in the same ballpark > and the C version is at least 4X faster. The FAQ of OCaml says (http://caml.inria.fr/ocaml/numerical.html) | for j = 0 to N-1 do | for i = 0 to N-1 do | c.(i).(j) <- a.(i).(j) + b.(i).(j) | done | done |but write: | for i = 0 to N-1 do | let row_a = a.(i) and row_b = b.(i) and row_c = c.(i) in | for j = 0 to N-1 do | row_c.(j) <- row_a.(j) + row_b.(j) | done | done So for your code > 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 You could write; for i=0 to tablesize -1 do let row1 = table.(i) in for j=0 to tablesize -1 do let row2 = row1.(j) do for k=0 to tablesize -1 do row2.(k) <- (i+1)*(j+1)*(k+1) done done done and peraps you will have a faster code. Try with "make_matrice" and without and tell me please, I am interested by this subject. Regards, Frédéric Gava