[ create a new paste ] login | about

Link: http://codepad.org/9zoYqzOP    [ raw code | output | fork ]

OCaml, pasted on Mar 5:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
open Printf

let measure f =
  let t = Unix.gettimeofday () in
  let () = f () in
  printf "%.4f sec" (Unix.gettimeofday () -. t)

let () =
  let gc () = for i = 1 to 10 do Gc.full_major () done in
  let a = Array.make 4_000_000 0 in
  measure gc;
  printf " normal %u (%u)\n%!" (Array.length a) (Gc.stat ()).Gc.live_words;

  Obj.set_tag (Obj.repr a) (Obj.no_scan_tag);
  measure gc;
  printf " no_scan_tag %u (%u)\n%!" (Array.length a) (Gc.stat ()).Gc.live_words;

  measure gc;
  printf " no array (%u)\n%!" (Gc.stat ()).Gc.live_words;
  ()


Output:
1
Reference to undefined global `Unix'


Create a new paste based on this one


Comments: