1 (***********************************************************************)
5 (* Damien Doligez, projet Para, INRIA Rocquencourt *)
7 (* Copyright 1996 Institut National de Recherche en Informatique et *)
8 (* en Automatique. All rights reserved. This file is distributed *)
9 (* under the terms of the Q Public License version 1.0. *)
11 (***********************************************************************)
15 (* Random allocation test *)
18 Allocate arrays of strings, of random sizes in [0..1000[, and put them
19 into an array of 32768. Replace a randomly-selected array with a new
20 random-length array. Reiterate ad infinitum.
26 let ar = Array.create
l "";;
30 let compact_flag = ref false;;
34 for i
= 1 to 100000 do
35 ar.(Random.int l) <- String.create
(Random.int m);
37 if !compact_flag then Gc.compact
() else Gc.full_major
();
45 "-c", Arg.Set
compact_flag, "do heap compactions";
48 Arg.parse
argspecs (fun _
-> ()) "Usage: alloc [-c]";;