/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.350.35256800  0% 3% 0% 97%
4,0003.023.0218,304800  0% 2% 1% 100%
16,00045.5845.5950,124800  0% 0% 0% 100%

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 #3 program source code

(* The Computer Language Benchmarks Game

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



   Adapted by Antti Lankila from the earlier Isaac Gouy's implementation

   Add multithread & tweaks from C++ by The Anh Tran

   Translate to F# by Jomo Fisher

*)

open System
open System.Threading
open System.IO

let mutable N = 200;
let mutable width_bytes = 0
let mutable data : byte array array = null
let mutable nbyte_each_line : int array = null
let current_line = ref -1 


let Calculate() = 
    let inverse_n = 2.0 / float N

    let mutable y = Interlocked.Increment(&current_line.contents)
    while y < N do // fetch a line

        let pdata = data.[y]

        let mutable byte_count = 0
        let mutable bit_num = 0
        let mutable byte_acc = 0

        let Civ = float y * inverse_n - 1.0

        for x in 0..N-1 do 
            let Crv = float x * inverse_n - 1.5

            let mutable Zrv = Crv
            let mutable Ziv = Civ
            let mutable Trv = Crv * Crv
            let mutable Tiv = Civ * Civ

            let mutable i = 49;
            let mutable more = true
            while more do
                Ziv <- (Zrv * Ziv) + (Zrv * Ziv) + Civ
                Zrv <- Trv - Tiv + Crv

                Trv <- Zrv * Zrv
                Tiv <- Ziv * Ziv
                
                more <- (Trv + Tiv) <= 4.0 
                if more then
                    i <- i - 1
                    more <- i > 0
                    
            byte_acc <- byte_acc <<< 1
            byte_acc <- byte_acc ||| (if i = 0 then 1 else 0)

            bit_num <- bit_num + 1
            if bit_num = 8 then
                pdata.[byte_count] <- byte byte_acc
                byte_count <- byte_count + 1
                bit_num <- 0
                byte_acc <- 0

        if bit_num <> 0 then  // write left over bits

            byte_acc <- byte_acc <<< (8 - (N &&& 7))
            pdata.[byte_count] <- byte byte_acc
            byte_count<-byte_count + 1

        nbyte_each_line.[y] <- byte_count
        y <- Interlocked.Increment(&current_line.contents)


[<EntryPoint>]
let main args = 
    if args.Length > 0 then
        N <- int args.[0]
    Console.Out.WriteLine("P4\n{0} {0}", N);

    width_bytes <- N / 8
    if width_bytes * 8 < N then
        width_bytes <- width_bytes + 1

    nbyte_each_line <- Array.zeroCreate N

    data <- Array.zeroCreate N 
    for i in 0..N-1 do 
        data.[i] <- Array.zeroCreate width_bytes 

    let threads = Array.init (Environment.ProcessorCount-1) (fun i->new Thread(Calculate))
    for thread in threads do thread.Start()
    Calculate()
    for thread in threads do thread.Join()
            
    let s = Console.OpenStandardOutput();
    for y in 0..N-1 do 
        s.Write(data.[y], 0, nbyte_each_line.[y])
    0

 make, command-line, and program output logs

Thu, 31 Oct 2013 00:39:34 GMT

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

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

COMMAND LINE:
/usr/local/bin/mono --llvm --gc=sgen mandelbrot.fsharp-3.fsharp_run.exe 16000

(BINARY) PROGRAM OUTPUT NOT SHOWN

Revised BSD license

  Home   Conclusions   License   Play