performance measurements

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

 N  CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
120.345,164441  
140.887,872441  
163.5818,096441  

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 Erlang HiPE program source code

% The Computer Language Shootout
% http://shootout.alioth.debian.org/
%
% contributed by Isaac Gouy (Erlang novice)

-module(binarytrees).
-export([main/1]).

-define(Min,4).

main([Arg]) ->
   N = list_to_integer(Arg),
   Max = lists:max([?Min+2,N]),

   Stretch = Max + 1,
   io:fwrite("stretch tree of depth ~w\t check: ~w~n",
      [ Stretch, itemCheck(bottomUp(0,Stretch)) ]),

   LongLivedTree = bottomUp(0,Max),
   depthLoop(?Min,Max),

   io:fwrite("long lived tree of depth ~w\t check: ~w~n",
      [ Max, itemCheck(LongLivedTree) ]),

   halt(0).


depthLoop(D,M) when D > M -> ok;
depthLoop(D,M) ->
   N = 1 bsl (M-D + ?Min),
   io:fwrite("~w\t trees of depth ~w\t check: ~w~n",
      [ 2*N, D, sumLoop(N,D,0) ]),
   depthLoop (D+2,M).

sumLoop(0,_,Sum) -> Sum;
sumLoop(N,D,Sum) ->
   sumLoop(N-1,D, Sum + itemCheck(bottomUp(N,D)) + itemCheck(bottomUp(-1*N,D))).

bottomUp(I,0) -> {I, nil, nil};
bottomUp(I,D) -> {I, bottomUp(2*I-1,D-1), bottomUp(2*I,D-1)}.

itemCheck(nil) -> 0;
itemCheck({I,Left,Right}) ->
   I + itemCheck(Left) - itemCheck(Right).

 notes

 

 make, command-line, and program output logs

BUILD COMMANDS FOR: binarytrees.hipe

Wed Apr  2 10:45:31 PDT 2008

cp /home/dunham/gp4/shootout/bench/binarytrees/binarytrees.erlang binarytrees.erl
/opt/otp_src_R12B-1/bin/erlc +native +"{hipe, [o3]}" binarytrees.erl
rm binarytrees.erl

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

 /opt/otp_src_R12B-1/bin/erl -noshell -run binarytrees main %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