performance measurements

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

 N  CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
120.3215,216603  
140.7116,976603  
162.8939,436603  

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.

 binary-trees Java 6 -Xms64m #2 program source code

/* The Great Computer Language Shootout
   http://shootout.alioth.debian.org/

   contributed by Jarkko Miettinen
*/

public class binarytrees {

	private final static int minDepth = 4;

	public static void main(String[] args){
		int n = 0;
		if (args.length > 0) n = Integer.parseInt(args[0]);

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

		int check = (TreeNode.bottomUpTree(0,stretchDepth)).itemCheck();
		System.out.println("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();
			}
			System.out.println((iterations*2) + "\t trees of depth " + depth + "\t check: " + check);
		}
		System.out.println("long lived tree of depth " + maxDepth + "\t check: "+ longLivedTree.itemCheck());
	}


	private static class TreeNode
	{
		private TreeNode left, right;
		private int item;

		TreeNode(int item){
			this.item = item;
		}

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

		TreeNode(TreeNode left, TreeNode right, int item){
			this.left = left;
			this.right = right;
			this.item = item;
		}

		private int itemCheck(){
			// if necessary deallocate here
			if (left==null) return item;
			else return item + left.itemCheck() - right.itemCheck();
		}
	}
}

 notes

Just to show how increasing the heap size effects performance.

 make, command-line, and program output logs

BUILD COMMANDS FOR: binarytrees.javaxx-2.javaxx

Thu Jul 10 16:34:58 PDT 2008

( if [ ! -d binarytrees.javaxx-2.javaxx_run ] ; then mkdir binarytrees.javaxx-2.javaxx_run ; fi)
cp /home/dunham/gp4/shootout/bench/binarytrees/binarytrees.javaxx-2.javaxx binarytrees.javaxx-2.javaxx_run/binarytrees.java
( cd binarytrees.javaxx-2.javaxx_run ; rm -rf *.class; /opt/sun-jdk-1.6.0.07/bin/javac -classpath '.' binarytrees.java )
touch binarytrees.javaxx-2.javaxx_run

=================================================================
COMMAND LINE (%A is single numeric argument):

 /opt/sun-jdk-1.6.0.07/bin/java $JDKFLAGS -server -Xms64m -Xbatch -classpath binarytrees.javaxx-2.javaxx_run binarytrees %A


PROGRAM OUTPUT
==============
stretch tree of depth 17	 check: -1
131072	 trees of depth 4	 check: -131072
32768	 trees of depth 6	 check: -32768
8192	 trees of depth 8	 check: -8192
2048	 trees of depth 10	 check: -2048
512	 trees of depth 12	 check: -512
128	 trees of depth 14	 check: -128
32	 trees of depth 16	 check: -32
long lived tree of depth 16	 check: -1

Revised BSD license

  Home   Flawed   Fastest   License   Help