Memory allocation nanobenchmark.
[
Home
]
[ Index:
by date

by threads
]
[ Message by date: previous  next ] [ Message in thread: previous  next ] [ Thread: previous  next ]
[ Message by date: previous  next ] [ Message in thread: previous  next ] [ Thread: previous  next ]
Date:  20050211 (09:20) 
From:  FrÃ©dÃ©ric_Gava <frederic.gava@w...> 
Subject:  Re: [Camllist] Memory allocation nanobenchmark. 
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 N1 do  for i = 0 to N1 do  c.(i).(j) < a.(i).(j) + b.(i).(j)  done  done but write:  for i = 0 to N1 do  let row_a = a.(i) and row_b = b.(i) and row_c = c.(i) in  for j = 0 to N1 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