performance measurements

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

 N  CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
120.830.8420,828565  0% 4% 2% 100%
162.032.0444,280565  0% 1% 0% 100%
2037.1937.23173,136565  0% 1% 1% 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

F# Compiler for F# 3.1 (Open Source Edition)

Mono JIT compiler version 3.8.1 (master/0322d96 Wed Aug 13 11:49:57 PDT 2014)
LLVM: yes(3.4svn-mono-mono/e656cac)
GC: sgen

 binary-trees F# Mono #3 program source code

// The Computer Language Benchmarks Game

// http://benchmarksgame.alioth.debian.org/

//

// Modification by Don Syme & Jomo Fisher to use null as representation

// of Empty node and to use a single Next element.

// Based on F# version by Robert Pickering

// Based on ocaml version by Troestler Christophe & Isaac Gouy


open System
open Unchecked

type Next = { Left: Tree; Right: Tree }
and [<Struct>] Tree(next:Next,item:int) =
    member t.Check() =
        match box next with 
        | null -> item
        | _ -> item + next.Left.Check() - next.Right.Check()

let rec make item depth =
    if depth > 0 then Tree({Left = make (2*item-1) (depth-1); Right=make (2*item) (depth-1)}, item)
    else Tree(defaultof<_>,item)

let inline check (tree:Tree) = tree.Check()

let rec loopDepths maxDepth minDepth d =
    if d <= maxDepth then
        let niter = 1 <<< (maxDepth - d + minDepth)
        let mutable c = 0
        for i = 1 to niter do
            c <- c + check (make i d) + check (make (-i) d)
        Console.WriteLine("{0}\t trees of depth {1}\t check: {2}",2 * niter,d,c)
        loopDepths maxDepth minDepth (d + 2)

[<EntryPoint>]
let main args =
    let minDepth = 4
    let maxDepth =
        let n = if args.Length > 0 then int args.[0] else 10
        max (minDepth + 2) n
    let stretchDepth = maxDepth + 1

    let c = check (make 0 stretchDepth)
    Console.WriteLine("stretch tree of depth {0}\t check: {1}",stretchDepth,c)
    let longLivedTree = make 0 maxDepth
    loopDepths maxDepth minDepth minDepth
    Console.WriteLine("long lived tree of depth {0}\t check: {1}",maxDepth,(check longLivedTree))
    exit 0

 make, command-line, and program output logs

Thu, 14 Aug 2014 10:22:03 GMT

MAKE:
mv binarytrees.fsharp-3.fsharp binarytrees.fsharp-3.fs
/usr/local/bin/fsharpc --target:exe --platform:x86 -O  -o binarytrees.fsharp-3.fsharp_run.exe binarytrees.fsharp-3.fs
F# Compiler for F# 3.1 (Open Source Edition)
Freely distributed under the Apache 2.0 Open Source License

/home/dunham/benchmarksgame_onecore/binarytrees/tmp/binarytrees.fsharp-3.fs(9,1): warning FS0221: The declarations in this file will be placed in an implicit module 'Binarytrees.fsharp-3' based on the file name 'binarytrees.fsharp-3.fs'. However this is not a valid F# identifier, so the contents will not be accessible from other files. Consider renaming the file or adding a 'module' or 'namespace' declaration at the top of the file.
rm binarytrees.fsharp-3.fs
4.36s to complete and log all make actions

COMMAND LINE:
/usr/local/bin/mono --llvm --gc=sgen binarytrees.fsharp-3.fsharp_run.exe 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