/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
101.041.0416,796548  3% 1% 99% 0%
118.318.3215,744548  100% 0% 0% 1%
12109.63109.6615,488548  1% 0% 0% 100%

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

Read fannkuch-redux 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

 fannkuch-redux F# Mono #2 program source code

(* The Computer Language Benchmarks Game

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



   from Scala version by Otto Bommer, August 2010

   Modified by Faisal Waris by remvoing ref's and using mutable variables, April 25, 2011

*)

let fannkuch n =
  begin
  let perm1 = Array.create n 0 in for i = 0 to (n-1) do perm1.[i] <- i done;
  let perm = Array.create n 0
  let count = Array.create n 0
  let mutable flips = 0 
  let mutable maxflips = 0 
  let mutable checksum = 0 
  let mutable nperm = 0
  let mutable r = n
  while r > 0 do 
    for i = 0 to n-1 do perm.[i] <- perm1.[i] done;

    while r <> 1 do count.[r-1] <- r; r <- r - 1; done;

    flips <- 0;
    let mutable k = perm.[0] in
    while k <> 0 do
      let mutable t = 0 in
      for i = 0 to k / 2 do
        t <- perm.[i];
        perm.[i] <- perm.[k - i];
        perm.[k - i] <- t;
        done;
        
      k <- perm.[0];
      flips <- flips + 1;
      done;

    maxflips <- max maxflips flips;
    if nperm &&& 1 = 0 then checksum <- checksum + flips else checksum <- checksum - flips
    
    let mutable go = true in
    let mutable t = 0 in
    while go do
      if r = n then begin go <- false; r <- 0; end
      else
        begin
        t <- perm1.[0];
        for i = 0 to r - 1 do perm1.[i] <- perm1.[i+1] done;
        perm1.[r] <- t;

        count.[r] <- count.[r] - 1;
        if count.[r] > 0 then go <- false
        else r <- r + 1;
        end
      done;

    nperm <- nperm + 1;
    done;

  (maxflips, checksum);
  end

let _ =
  let n = try int((System.Environment.GetCommandLineArgs()).[1]) with _ -> 7
  let (maxflips, checksum) = fannkuch n
  Printf.printf "%d\nPfannkuchen(%d) = %d\n" checksum n maxflips

 make, command-line, and program output logs

Thu, 31 Oct 2013 03:09:32 GMT

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

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

COMMAND LINE:
/usr/local/bin/mono --llvm fannkuchredux.fsharp-2.fsharp_run.exe 12

PROGRAM OUTPUT:
3968050
Pfannkuchen(12) = 65

Revised BSD license

  Home   Conclusions   License   Play