performance measurements

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

 N  CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
100.520.5219,340520  4% 4% 2% 100%
115.155.1519,340520  1% 0% 1% 100%
1270.3370.3619,344520  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

Mono JIT compiler version 3.4.1 (master/ea46441 Mon Apr 28 17:45:05 PDT 2014)
LLVM: yes(3.4svn-mono-mono/e656cac)
GC: sgen

 fannkuch-redux C# Mono program source code

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

   contributed by Isaac Gouy, transliterated from Rex Kerr's Scala program
*/

using System;

class FannkuchRedux
{
   public static int fannkuch(int n) {
      int[] perm = new int[n], perm1 = new int[n], count = new int[n];
      for(int j=0; j<n; j++) perm1[j] = j;
      int f = 0, i = 0, k = 0, r = 0, flips = 0, nperm = 0, checksum = 0;

      r = n;
      while (r>0) {
         i = 0;
         while (r != 1) { count[r-1] = r; r -= 1; }
         while (i < n) { perm[i] = perm1[i]; i += 1; }
      
         // Count flips and update max  and checksum
         f = 0;
         k = perm[0];
         while (k != 0) {
           i = 0;
           while (2*i < k) {
             var t = perm[i]; perm[i] = perm[k-i]; perm[k-i] = t;
             i += 1;
           }
           k = perm[0];
           f += 1;
         }
         if (f>flips) flips = f;
         if ((nperm&0x1)==0) checksum += f;
         else checksum -= f;
                      
         // Use incremental change to generate another permutation
         var go = true;
         while (go) {
            if (r == n) {
               Console.WriteLine(checksum);
               return flips;
            }
            var p0 = perm1[0];
            i = 0;
            while (i < r) {
               var j = i+1;
               perm1[i] = perm1[j];
               i = j;
            }
            perm1[r] = p0;

            count[r] -= 1;
            if (count[r] > 0) go = false;
            else r += 1;
         }
         nperm += 1;
      }
      return flips;
   }

   static void Main(string[] args){
      int n = 7;
      if (args.Length > 0) n = Int32.Parse(args[0]);
      Console.WriteLine("Pfannkuchen({0}) = {1}", n, fannkuch(n));
   }
}

 make, command-line, and program output logs

Tue, 29 Apr 2014 08:59:20 GMT

MAKE:
mv fannkuchredux.csharp fannkuchredux.cs
/usr/local/bin/mcs  -optimize+ -platform:x64 -out:fannkuchredux.csharp_run fannkuchredux.cs
rm fannkuchredux.cs
0.21s to complete and log all make actions

COMMAND LINE:
/usr/local/bin/mono --llvm fannkuchredux.csharp_run 12

PROGRAM OUTPUT:
3968050
Pfannkuchen(12) = 65

Revised BSD license

  Home   Conclusions   License   Play