Browse thread
Memory allocation nano-benchmark.
[
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: | 2005-02-10 (16:34) |
From: | Frédéric_Gava <frederic.gava@w...> |
Subject: | Re: [Caml-list] Memory allocation nano-benchmark. |
Hi, > let test tablesize = > let table = > Array.init tablesize (fun i -> > Array.init tablesize (fun j -> > Array.create tablesize 0)) > 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 Here, you have tablesize^2 applications and time to create the closure(s), so it is not a good example. 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 ) I think (not sure) that used "Array.create" instead of "Array.init" allows ours to not have the problem of buildings the closures and peraps give a faster code (for this cases). To test ;-) > [skaller@pelican] ~>time ./xmem 250 > real 0m3.327s > user 0m2.760s > sys 0m0.300s I do not understand what is "xmem". A super hero ;-) ? Cheers, Frédéric Gava