Version française
Home     About     Download     Resources     Contact us    
Browse thread
Memory allocation nano-benchmark.
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: skaller <skaller@u...>
Subject: Re: [Caml-list] Memory allocation nano-benchmark.
On Fri, 2005-02-11 at 01:47, Frédéric Gava wrote:
> Hi,
> 
> I think it is due to tablesize^3 applications of functions that are not
> present in the C code. 

[skaller@pelican] ~>time ./a.out 250 
real    0m3.303s
user    0m2.850s
sys     0m0.350s

Using:

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
;;
                
let _ = test (int_of_string Sys.argv.(1))

[skaller@pelican] ~>time ./xmem 250
real    0m3.327s
user    0m2.760s
sys     0m0.300s

[skaller@pelican] ~>time ./cmem 250 
real    0m0.706s
user    0m0.150s
sys     0m0.450s

[I can't run it with >250 without the disk going nuts]

-- 
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net