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
5000.980.9919,644459  0% 2% 2% 100%
3,0009.489.4920,764459  0% 1% 1% 100%
5,50030.1030.1121,208459  1% 1% 0% 100%

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

Read spectral-norm benchmark to see what this program should do.

 notes

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

 spectral-norm C# Mono program source code

/* The Computer Language Benchmarks Game
   http://benchmarksgame.alioth.debian.org/
 
   contributed by Isaac Gouy 
*/

using System;

class SpectralNorm
{
   public static void Main(String[] args) {        
      int n = 100;
      if (args.Length > 0) n = Int32.Parse(args[0]);

      Console.WriteLine("{0:f9}", new SpectralNorm().Approximate(n));
   }

   double Approximate(int n) {
      // create unit vector
      double[] u = new double[n];       
      for (int i=0; i<n; i++) u[i] =  1;

      // 20 steps of the power method
      double[] v = new double[n];  
      for (int i=0; i<n; i++) v[i] = 0;

      for (int i=0; i<10; i++) {
         MultiplyAtAv(n,u,v);
         MultiplyAtAv(n,v,u);
      }

      // B=AtA         A multiplied by A transposed
      // v.Bv /(v.v)   eigenvalue of v 
      double vBv = 0, vv = 0;
      for (int i=0; i<n; i++) {
         vBv += u[i]*v[i];
         vv  += v[i]*v[i];
      }

      return Math.Sqrt(vBv/vv);
   }


   /* return element i,j of infinite matrix A */
   double A(int i, int j){
      return 1.0/((i+j)*(i+j+1)/2 +i+1); 
   }

   /* multiply vector v by matrix A */
   void MultiplyAv(int n, double[] v, double[] Av){
      for (int i=0; i<n; i++){
         Av[i] = 0;
         for (int j=0; j<n; j++) Av[i] += A(i,j)*v[j];
      }
   }

   /* multiply vector v by matrix A transposed */
   void MultiplyAtv(int n, double[] v, double[] Atv){
      for (int i=0;i<n;i++){
         Atv[i] = 0;
         for (int j=0; j<n; j++) Atv[i] += A(j,i)*v[j];
      }
   }

   /* multiply vector v by matrix A and then by matrix A transposed */
   void MultiplyAtAv(int n, double[] v, double[] AtAv){
      double[] u = new double[n];
      MultiplyAv(n,v,u);
      MultiplyAtv(n,u,AtAv);
   }
}

 make, command-line, and program output logs

Thu, 14 Aug 2014 14:57:16 GMT

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

COMMAND LINE:
/usr/local/bin/mono --llvm --gc=sgen spectralnorm.csharp_run 5500

PROGRAM OUTPUT:
1.274224153

Revised BSD license

  Home   Conclusions   License   Play