File: test.ml

package info (click to toggle)
ocplib-endian 1.2-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 252 kB
  • sloc: ml: 1,310; makefile: 16
file content (39 lines) | stat: -rw-r--r-- 1,459 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

let allocdiff =
  let stat1 = Gc.quick_stat () in
  let stat2 = Gc.quick_stat () in
  (stat2.Gc.minor_words -. stat1.Gc.minor_words)

let () =
  Test_bigstring.test1 ();
  let stat1 = Gc.quick_stat () in
  Test_bigstring.test2 ();
  if Sys.word_size = 64 then Test_bigstring.test_64 ();
  let stat2 = Gc.quick_stat () in
  (* with a 32 bit system, int64 must be heap allocated *)
  if Sys.word_size = 32 then Test_bigstring.test_64 ();
  let alloc1 = stat2.Gc.minor_words -. stat1.Gc.minor_words -. allocdiff in
  Printf.printf "bigstring: allocated words %f\n%!" alloc1;

  Test_string.test1 ();
  let stat1 = Gc.quick_stat () in
  Test_string.test2 ();
  if Sys.word_size = 64 then Test_string.test_64 ();
  let stat2 = Gc.quick_stat () in
  if Sys.word_size = 32 then Test_string.test_64 ();
  let alloc2 = stat2.Gc.minor_words -. stat1.Gc.minor_words -. allocdiff in
  Printf.printf "string: allocated words %f\n%!" alloc2;

  Test_bytes.test1 ();
  let stat1 = Gc.quick_stat () in
  Test_bytes.test2 ();
  if Sys.word_size = 64 then Test_bytes.test_64 ();
  let stat2 = Gc.quick_stat () in
  if Sys.word_size = 32 then Test_bytes.test_64 ();
  let alloc3 = stat2.Gc.minor_words -. stat1.Gc.minor_words -. allocdiff in
  Printf.printf "bytes: allocated words %f\n%!" alloc3;
  (* we cannot ensure that there are no allocations only with the
     primives added in 4.01.0 *)
  if (alloc1 <> 0. || alloc2 <> 0. || alloc3 <> 0.)
  then exit 1
  else exit 0