/mobile Handheld Friendly website

 performance measurements

Each table row shows performance measurements for this ATS program with a particular command-line input value N.

 N  CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
120.040.04?926  0% 0% 0% 100%
160.760.7612,992926  1% 100% 0% 1%
2016.6116.64198,252926  0% 0% 0% 100%

Read the ↓ make, command line, and program output logs to see how this program was run.

Read binary-trees benchmark to see what this program should do.

 notes

ATS/Anairiats version 0.2.9

 binary-trees ATS program source code

(*
** The Computer Language Benchmarks Game
** http://benchmarksgame.alioth.debian.org/
**
** contributed by Hongwei Xi
**
** compilation command:
**   atscc -O3 binary-trees2.dats -o binary-trees2 -D_ATS_GCATS
*)

(* ****** ****** *)

staload _(*anonymous*) = "prelude/DATS/reference.dats"

(* ****** ****** *)

dataviewtype tree (int) =
  Nil(0) | {n1,n2:two} Node(1) of (tree n1, int, tree n2)
// end of [tree]

viewtypedef Tree = [n:two] tree n

fun tree_make (d: int, i: int): Tree =
  if d > 0 then let
    val d1 = d-1 and i2 = i << 1 in
    Node (tree_make (d1, i2 - 1), i, tree_make (d1, i2))
  end else Node (Nil (), i, Nil ())
// end of [tree_make]

fun check_and_free (t: Tree):<!ntm> int =  case+ t of
  | ~Node (tl, i, tr) => i + check_and_free tl - check_and_free tr
  | ~Nil () => 0
// end of [check_and_free]

fun check (t: !Tree):<!ntm> int = case+ t of
  | Node (!tl, i, !tr) => let
      val ans = i + check (!tl) - check (!tr) in (fold@ t; ans)
    end // end of [Node]
  | Nil () => (fold@ t; 0)
// end of [check]

fun check_ref (r: ref Tree): int = let
  val (vbox pf | p) = ref_get_view_ptr r in check !p     
end // end of [check_ref]

(* ****** ****** *)

#define MIN_DEPTH 4

fn stretch (max_depth: Nat): void = let
   val stretch_depth = max_depth + 1
   val t = tree_make (stretch_depth, 0)
   val c = check_and_free (t)
in
   printf ("stretch tree of depth %i\t check: %i\n", @(stretch_depth, c));
end // end of [stretch]

fn long_lived_tree_make
  (max_depth: Nat): ref Tree = let
  val t = tree_make (max_depth, 0); val t_r = ref<Tree> (t)
in
  t_r
end // end of [long_lived_tree_make]

fun loop_depths (d: Nat, max_depth: Nat): void = begin
  if d <= max_depth then let
    val n = 1 << (max_depth - d + MIN_DEPTH)
    fun loop (i: Nat, c: int):<cloref1> int =
      if i < n then let
        val t = tree_make(d,  i); val c1 = check_and_free t
        val t = tree_make(d, ~i); val c2 = check_and_free t
      in
        loop (i+1, c + c1 + c2)
      end else c
    val c = loop (0, 0)
  in
    printf ("%i\t trees of depth %i\t check: %i\n", @(2 * n, d, c));
    loop_depths (d + 2, max_depth)
  end
end // end of [loop_depths]

implement main (argc, argv) = let
  val () = assert_errmsg
    (argc = 2, "Exit: wrong command format!\n")
  val n = int1_of argv.[1]
  val () = assert_errmsg
    (n >= 0, "The input integer needs to be a natural number.\n")
  // this simply means that no garbage collection can be triggered
  // and memory allocation and deallocation must be handled manually
  val () = gc_chunk_count_limit_max_set (~1) // infinite
  val max_depth = max (MIN_DEPTH + 2, n)
  val () = stretch (max_depth)
  val long_lived_tree = long_lived_tree_make (max_depth)
in
  loop_depths (MIN_DEPTH, max_depth);
  printf ("long lived tree of depth %i\t check: %i\n", @(max_depth, check_ref long_lived_tree))
end // end of [main]

(* ****** ****** *)

(* end of [binary-tree2.dats] *)

 make, command-line, and program output logs

Tue, 22 Jan 2013 19:07:37 GMT

MAKE:
/usr/local/src/ats-lang-anairiats-0.2.9/bin/atscc -pthread -D_GNU_SOURCE -D_ATS_MULTITHREAD -D_ATS_GCATS -pipe -Wall -O3 -fomit-frame-pointer -march=native  binarytrees.dats -o binarytrees.ats_run 
/usr/local/src/ats-lang-anairiats-0.2.9/bin/atsopt --output binarytrees_dats.c --dynamic binarytrees.dats
/usr/local/src/ats-lang-anairiats-0.2.9/ccomp/runtime/ats_prelude.c: In function ‘ats_pthread_create_detached’:
/usr/local/src/ats-lang-anairiats-0.2.9/ccomp/runtime/ats_prelude.c:181:3: warning: implicit declaration of function ‘gc_pthread_create’ [-Wimplicit-function-declaration]
In file included from binarytrees_dats.c:19:0:
/usr/local/src/ats-lang-anairiats-0.2.9/prelude/CATS/basics.cats: In function ‘atspre_fprint_newline’:
/usr/local/src/ats-lang-anairiats-0.2.9/prelude/CATS/basics.cats:271:11: warning: variable ‘n2’ set but not used [-Wunused-but-set-variable]
/usr/local/src/ats-lang-anairiats-0.2.9/prelude/CATS/basics.cats:271:7: warning: variable ‘n1’ set but not used [-Wunused-but-set-variable]
binarytrees_dats.c: In function ‘tree_make_0’:
binarytrees_dats.c:131:1: warning: label ‘__ats_lab_tree_make_0’ defined but not used [-Wunused-label]
binarytrees_dats.c: In function ‘check_and_free_1’:
binarytrees_dats.c:188:1: warning: label ‘__ats_lab_1_1’ defined but not used [-Wunused-label]
binarytrees_dats.c:174:1: warning: label ‘__ats_lab_0_1’ defined but not used [-Wunused-label]
binarytrees_dats.c:172:1: warning: label ‘__ats_lab_0_0’ defined but not used [-Wunused-label]
binarytrees_dats.c:169:1: warning: label ‘__ats_lab_check_and_free_1’ defined but not used [-Wunused-label]
binarytrees_dats.c: In function ‘check_2’:
binarytrees_dats.c:232:1: warning: label ‘__ats_lab_3_1’ defined but not used [-Wunused-label]
binarytrees_dats.c:217:1: warning: label ‘__ats_lab_2_1’ defined but not used [-Wunused-label]
binarytrees_dats.c:215:1: warning: label ‘__ats_lab_2_0’ defined but not used [-Wunused-label]
binarytrees_dats.c:212:1: warning: label ‘__ats_lab_check_2’ defined but not used [-Wunused-label]
binarytrees_dats.c: In function ‘check_ref_3’:
binarytrees_dats.c:250:1: warning: label ‘__ats_lab_check_ref_3’ defined but not used [-Wunused-label]
binarytrees_dats.c: In function ‘stretch_4’:
binarytrees_dats.c:269:1: warning: label ‘__ats_lab_stretch_4’ defined but not used [-Wunused-label]
binarytrees_dats.c: In function ‘ref_01033_ats_ptr_type’:
binarytrees_dats.c:287:1: warning: label ‘__ats_lab_ref_01033_ats_ptr_type’ defined but not used [-Wunused-label]
binarytrees_dats.c: In function ‘long_lived_tree_make_5’:
binarytrees_dats.c:304:1: warning: label ‘__ats_lab_long_lived_tree_make_5’ defined but not used [-Wunused-label]
binarytrees_dats.c: In function ‘mainats’:
binarytrees_dats.c:433:1: warning: label ‘__ats_lab_mainats’ defined but not used [-Wunused-label]
In file included from binarytrees_dats.c:29:0:
binarytrees_dats.c: At top level:
/usr/local/src/ats-lang-anairiats-0.2.9/prelude/CATS/pointer.cats:52:14: warning: ‘atspre_null_ptr’ defined but not used [-Wunused-variable]
In file included from binarytrees_dats.c:30:0:
/usr/local/src/ats-lang-anairiats-0.2.9/prelude/CATS/printf.cats:57:1: warning: ‘atspre_fprintf_err’ defined but not used [-Wunused-function]
/usr/local/src/ats-lang-anairiats-0.2.9/prelude/CATS/printf.cats:69:1: warning: ‘atspre_fprintf_exn’ defined but not used [-Wunused-function]
/usr/local/src/ats-lang-anairiats-0.2.9/prelude/CATS/printf.cats:105:1: warning: ‘atspre_prerrf_exn’ defined but not used [-Wunused-function]
In file included from binarytrees_dats.c:33:0:
/usr/local/src/ats-lang-anairiats-0.2.9/prelude/CATS/string.cats:351:14: warning: ‘atspre_stropt_none’ defined but not used [-Wunused-variable]
binarytrees_dats.c:369:1: warning: ‘loop_8_closure_make’ defined but not used [-Wunused-function]
gcc -I/usr/local/src/ats-lang-anairiats-0.2.9/ -I/usr/local/src/ats-lang-anairiats-0.2.9/ccomp/runtime/ -L/usr/local/src/ats-lang-anairiats-0.2.9/ccomp/lib64/ /usr/local/src/ats-lang-anairiats-0.2.9/ccomp/runtime/ats_prelude.c -pthread -D_GNU_SOURCE -D_ATS_MULTITHREAD -D_ATS_GCATS -pipe -Wall -O3 -fomit-frame-pointer -march=native binarytrees_dats.c -o binarytrees.ats_run /usr/local/src/ats-lang-anairiats-0.2.9/ccomp/runtime/GCATS/gc_mt.o -lats_mt -lats 
rm binarytrees.dats
0.42s to complete and log all make actions

COMMAND LINE:
./binarytrees.ats_run 20

PROGRAM OUTPUT:
stretch tree of depth 21	 check: -1
2097152	 trees of depth 4	 check: -2097152
524288	 trees of depth 6	 check: -524288
131072	 trees of depth 8	 check: -131072
32768	 trees of depth 10	 check: -32768
8192	 trees of depth 12	 check: -8192
2048	 trees of depth 14	 check: -2048
512	 trees of depth 16	 check: -512
128	 trees of depth 18	 check: -128
32	 trees of depth 20	 check: -32
long lived tree of depth 20	 check: -1

gc_collect: nother = 0
gc_collect: nother = 0
gc_collect: nother = 0
gc_collect: nother = 0
gc_collect: nother = 0
gc_collect: nother = 0
gc_collect: nother = 0
gc_collect: nother = 0
gc_collect: nother = 0
gc_collect: nother = 0
gc_collect: nother = 0
gc_collect: nother = 0
gc_collect: nother = 0
gc_collect: nother = 0
gc_collect: nother = 0

Revised BSD license

  Home   Conclusions   License   Play