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
500,00042.2742.2959,256591  1% 1% 0% 100%
5,000,000422.15422.3159,312591  1% 1% 1% 100%
50,000,000Timed Out  591   

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

Read thread-ring benchmark to see what this program should do.

 notes

Mono JIT compiler version 4.3.0 (master/54e8010 Sun May 31 13:36:15 PDT 2015)
LLVM: yes(3.6.0svn-mono-master/ce4fcec)
GC: sgen

 thread-ring C# Mono #2 program source code

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

using System;
using System.Diagnostics;
using System.Linq;
using System.Threading;

internal class NamedThread {
    private readonly int name;
    private readonly ManualResetEventSlim signal = new ManualResetEventSlim(false);
    private int token;

    internal NamedThread( int name ) {
        this.name = name;
    }

    internal NamedThread NextThread() {
        return ThreadRing.threadRing[ name % ThreadRing.numberOfThreads ];
    }

    internal void Run() {
        while ( TokenNotDone() )
            NextThread().TakeToken( token - 1 );

        if ( token == 0 ) Console.WriteLine( name );
        NextThread().TakeToken( -1 );
    }

    internal void TakeToken( int x ) {
        token = x;
        signal.Set();
    }

    private bool TokenNotDone() {
        signal.Wait();
        signal.Reset();
        return token > 0;
    }
}

public class ThreadRing {
    internal const int numberOfThreads = 503;
    internal static NamedThread[] threadRing = new NamedThread[503];

    private static void Main( String[] args ) {
        Main2( args );
    }

    public static void Main2( string[] args ) {
        for ( var i = 0; i < numberOfThreads; i++ ) threadRing[ i ] = new NamedThread( i + 1 );
        var thrs = threadRing.Select( a => new Thread( a.Run ) ).ToArray();
        foreach ( var thread in thrs ) thread.Start(); 
        var cnt = args.Length > 0 ? int.Parse( args[ 0 ] ) : 50000000;
        threadRing[ 0 ].TakeToken( cnt );
        foreach ( var thread in thrs ) thread.Join();
    }
}

 make, command-line, and program output logs

Mon, 01 Jun 2015 20:37:59 GMT

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

COMMAND LINE:
/usr/local/bin/mono --llvm threadring.csharp-2.csharp_run 50000000

TIMED OUT after 600s


PROGRAM OUTPUT:

Revised BSD license

  Home   Conclusions   License   Play