/mobile Handheld Friendly website

 performance measurements

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

 N  CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
120.080.09?543  0% 0% 0% 100%
160.680.6841,736543  0% 0% 0% 100%
2042.6442.69153,364543  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

Dart VM version: 0.4.7.1_r21537 (Tue Apr 16 01:34:29 2013)

"The Dart team has provided an official benchmark harness that ensures your benchmark follows the benchmarking procedures necessary for the Dart VM’s optimizer."

Here are the measurements reported from benchmark_harness.dart with n=12 n=16 n=20 on x64q

Template(RunTime): 441800.0 us.
Template(RunTime): 10858000.0 us.
Template(RunTime): 1077458000.0 us.

Which is actually --

0.44 secs
1.08 secs
107.74 secs

 binary-trees Dart program source code

/* The Computer Language Benchmarks game
   http://benchmarksgame.alioth.debian.org/

   contributed by Jos Hirth, transliterated from Jarkko Miettinen's Java program
*/

import 'dart:io';

final int minDepth = 4;

void main(){
  int n = (){
    var args = new Options().arguments;
    return args.length > 0 ? int.parse(args[0]) : 0;
  }();

  int maxDepth = (minDepth + 2 > n) ? minDepth + 2 : n;
  int stretchDepth = maxDepth + 1;

  int check = (TreeNode.bottomUpTree(0, stretchDepth)).itemCheck();
  print("stretch tree of depth $stretchDepth\t check: $check");

  TreeNode longLivedTree = TreeNode.bottomUpTree(0, maxDepth);

  for (int depth = minDepth; depth <= maxDepth; depth += 2){
    int iterations = 1 << (maxDepth - depth + minDepth);
    check = 0;

    for (int i = 1; i <= iterations; i++){
      check += (TreeNode.bottomUpTree(i, depth)).itemCheck();
      check += (TreeNode.bottomUpTree(-i, depth)).itemCheck();
    }
    print("${iterations * 2}\t trees of depth $depth\t check: $check");
  }
  print("long lived tree of depth $maxDepth\t check: ${longLivedTree.itemCheck()}");
}


class TreeNode{
  TreeNode left, right;
  int item;

  TreeNode(this.item, [this.left, this.right]);

  static TreeNode bottomUpTree(int item, int depth){
    if (depth > 0){
      return new TreeNode(
        item,
        bottomUpTree(2 * item - 1, depth - 1),
        bottomUpTree(2 * item, depth - 1)
      );
    }
    return new TreeNode(item);
  }

  int itemCheck(){
    if (left == null){
      return item;
    }
    return item + left.itemCheck() - right.itemCheck();
  }
}

 make, command-line, and program output logs

Thu, 18 Apr 2013 03:30:09 GMT

COMMAND LINE:
/usr/local/src/dart-sdk/bin/dart  binarytrees.dart 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

Revised BSD license

  Home   Conclusions   License   Play