/mobile Handheld Friendly website

 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
1,0000.500.37272869  32% 46% 27% 34%
4,0002.630.9319,264869  70% 70% 77% 66%
16,00035.949.2454,572869  98% 97% 98% 97%

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

Read mandelbrot benchmark to see what this program should do.

 notes

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

Mono JIT compiler version 3.2.3 (tarball Wed Oct 30 12:15:41 PDT 2013)
LLVM: yes(3.3svn-mono-mono/8bdedb5)
GC: sgen

 mandelbrot F# Mono #4 program source code

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

      Contributed by Don Syme
      Port of C# version by Antti Lankila, Isaac Gouy's, 
      The Anh Tran, Robert F. Tobler, Nigel Delaney, Marek Safar, kasthack
*)

open System
open Mono.Simd
open System.IO
open System.Threading


[<EntryPoint>]
let main argv = 
    let n  = if (argv.Length > 0) then Int32.Parse(argv.[0]) else 200
    Console.Out.WriteLine("P4\n{0} {0}", n)
    let lineLen = (n - 1) / 8 + 1
    let data = Array.init n (fun i -> Array.zeroCreate lineLen)
    let xa = Array.init n (fun x -> float x * 2.0 / float n - 1.5)
    let lineCount = ref -1
    let calculate()  =
        let mutable y = 0
        let twoOverN = 2.0 / float n
        while (y <- Interlocked.Increment(&lineCount.contents); y < n) do
         let line = data.[y]
         let mutable xbyte = 0
         let mutable bits = 1
         let ci = float y * twoOverN - 1.0
         let Ci = new Vector2d (ci)
         for x in 0 .. 2 .. xa.Length - 1 do
            let Cr = new Vector2d(xa.[x],xa.[x+1])//vector of constant real terms
            let Tempr = Cr * Cr
            let Tempi = Ci * Ci
            let mutable Zr = Cr
            let mutable Zi = Ci
            let mutable Temp = Tempr - Tempi + Cr
            if (bits > 0xff) then line.[xbyte] <- byte(bits ^^^ -1); xbyte <- xbyte + 1; bits <- 1 
            let mutable i = 49
            let mutable b = 0
            let mutable brk = false
            while not brk do
               let Zri = Zr*Zi  //calculate r*i for both
               Zi <- Zri+Zri+Ci //double that and add a constant 
               Zr <- Temp//pre-calculated on previous loop
               let mutable V0 = Zr.InterleaveLow(Zi)//r0,i0
               let mutable V1 = Zr.InterleaveHigh(Zi)//r1,i1
               V0 <- V0*V0 //r0^2,i0^2
               V1 <- V1*V1
               let Length = V0.HorizontalAdd(V1)//(r0^2+i0^2),(r1^2+i1^2)
               Temp <- V0.HorizontalSub(V1)+Cr//(r0^2-i0^2),(r1^2-i1^2)
                //now to determine end condition, 
               if(Length.X>4.0) then (b <- b ||| 2; if(b=3) then brk <- true)
               if(not brk && Length.Y>4.0) then (b <- b ||| 1; if(b=3) then brk <- true)
               i <- i - 1
               if (i = 0) then brk <- true
            bits <- (bits <<< 2) + b
         while (bits < 0x100) do bits <- (bits <<< 1) 
         line.[xbyte] <- byte(bits ^^^ -1)

    let threads = Array.init Environment.ProcessorCount (fun _ -> let t = new Thread(calculate) in t.Start(); t)
    for t in threads do t.Join()
    let s = Console.OpenStandardOutput()
    for y in 0 .. n - 1 do s.Write(data.[y], 0, lineLen)
    0

 make, command-line, and program output logs

Thu, 31 Oct 2013 03:32:06 GMT

MAKE:
mv mandelbrot.fsharp-4.fsharp mandelbrot.fsharp-4.fs
/usr/local/bin/fsharpc --target:exe --platform:x86 -O -r:/usr/local/lib/mono/4.5/Mono.Simd.dll -o mandelbrot.fsharp-4.fsharp_run.exe mandelbrot.fsharp-4.fs
F# Compiler for F# 3.0 (Open Source Edition)
Freely distributed under the Apache 2.0 Open Source License

/home/dunham/benchmarksgame_quadcore/mandelbrot/tmp/mandelbrot.fsharp-4.fs(10,1): warning FS0221: The declarations in this file will be placed in an implicit module 'Mandelbrot.fsharp-4' based on the file name 'mandelbrot.fsharp-4.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 mandelbrot.fsharp-4.fs
4.03s to complete and log all make actions

COMMAND LINE:
/usr/local/bin/mono --llvm mandelbrot.fsharp-4.fsharp_run.exe 16000

(BINARY) PROGRAM OUTPUT NOT SHOWN

Revised BSD license

  Home   Conclusions   License   Play