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
2,000Failed  1026   

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

Read pidigits benchmark to see what this program should do.


Mono JIT compiler version 4.1.0 (master/435cc01 Wed May 20 21:03:41 PDT 2015)
LLVM: yes(3.6.0svn-mono-master/ce4fcec)
GC: sgen

 pidigits C# Mono #3 program source code

/* The Computer Language Benchmarks Game
 * Port of the Java port that uses native GMP to use native GMP with C#
 * contributed by Miguel de Icaza, based on the Java version, that was:
 * 	contributed by Mike Pall
 * 	java port by Stefan Krause
using System;
using System.Text;
using System.Runtime.InteropServices;

public class pidigits {

   GmpInteger q = new GmpInteger(), r = new GmpInteger(), s = new GmpInteger(), t = new GmpInteger();
   GmpInteger u = new GmpInteger(), v = new GmpInteger(), w = new GmpInteger();

   int i;
   StringBuilder strBuf = new StringBuilder (40);
   int n;

   pidigits (int n)

   private void compose_r(int bq, int br, int bs, int bt)
     u.mul(r, bs);
     r.mul(r, bq);
     v.mul(t, br);
     r.add(r, v);
     t.mul(t, bt);
     t.add(t, u);
     s.mul(s, bt);
     u.mul(q, bs);
     s.add(s, u);
     q.mul(q, bq);

   /* Compose matrix with numbers on the left. */
   private void compose_l(int bq, int br, int bs, int bt)
     r.mul(r, bt);
     u.mul(q, br);
     r.add(r, u);
     u.mul(t, bs);
     t.mul(t, bt);
     v.mul(s, br);
     t.add(t, v);
     s.mul(s, bq);
     s.add(s, u);
     q.mul(q, bq);

   /* Extract one digit. */
   private int extract(int j)
     u.mul(q, j);
     u.add(u, r);
     v.mul(s, j);
     v.add(v, t);
     w.div(u, v);
     return w.intValue();

   /* Print one digit. Returns 1 for the last digit. */
   private bool prdigit(int y)
      if (++i % 10 == 0 || i == n) {
         if (i%10!=0) for (int j=10-(i%10);j>0;j--) { strBuf.Append(" "); }
         strBuf = new StringBuilder(40);
      return i == n;

   /* Generate successive digits of PI. */
   void Run()
     int k = 1;
     i = 0;
     for (;;) {
       int y = extract(3);
       if (y == extract(4)) {
         if (prdigit(y)) return;
         compose_r(10, -10*y, 0, 1);
       } else {
         compose_l(k, 4*k+2, 0, 2*k+1);

   public static void Main(String[] args) {
       pidigits m = new pidigits(Int32.Parse (args[0]));

[StructLayout (LayoutKind.Sequential)]
struct mpz_t {
    public int _mp_alloc;
    public int _mp_size;
    public IntPtr ptr;

class GmpInteger {

   // Public methods

   public GmpInteger() {
      mpz_init(ref pointer);

   public GmpInteger(int value) {
      mpz_set_si(ref pointer, value);

   public void set(int value) { mpz_set_si(ref pointer, value); }

   public void mul(GmpInteger src, int val) { mpz_mul_si(ref pointer, ref src.pointer, val); }

   public void add(GmpInteger op1, GmpInteger op2) { mpz_add(ref pointer, ref op1.pointer, ref op2.pointer); }

   public void div(GmpInteger op1, GmpInteger op2) { mpz_tdiv_q(ref pointer, ref op1.pointer, ref op2.pointer); }

   public int intValue() { return mpz_get_si(ref pointer); }

   public double doubleValue() { return mpz_get_d(ref pointer); }

   // Non public stuff

   mpz_t pointer;

    [DllImport ("gmp", EntryPoint="__gmpz_init")]
    extern static void mpz_init(ref mpz_t value);

    [DllImport ("gmp", EntryPoint="__gmpz_mul_si")]
    extern static void mpz_mul_si(ref mpz_t dest, ref mpz_t src, int val);

    [DllImport ("gmp", EntryPoint="__gmpz_add")]
    extern static void mpz_add(ref mpz_t dest, ref mpz_t src, ref mpz_t src2);

    [DllImport ("gmp", EntryPoint="__gmpz_tdiv_q")]
    extern static void mpz_tdiv_q(ref mpz_t dest, ref mpz_t src, ref mpz_t src2);

    [DllImport ("gmp", EntryPoint="__gmpz_set_si")]
    extern static void mpz_set_si(ref mpz_t src, int value);

    [DllImport ("gmp", EntryPoint="__gmpz_get_si")]
    extern static int mpz_get_si(ref mpz_t src);

    [DllImport ("gmp", EntryPoint="__gmpz_get_d")]
    extern static double mpz_get_d(ref mpz_t src);

 make, command-line, and program output logs

Thu, 21 May 2015 17:22:26 GMT

mv pidigits.csharp-3.csharp pidigits.csharp-3.cs
/usr/local/bin/mcs -r:Mono.Security -optimize+ -platform:x86 -out:pidigits.csharp-3.csharp_run pidigits.csharp-3.cs
rm pidigits.csharp-3.cs
0.95s to complete and log all make actions

/usr/local/bin/mono --llvm --gc=sgen pidigits.csharp-3.csharp_run 2000




  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) GmpInteger.mpz_tdiv_q (mpz_t&,mpz_t&,mpz_t&) <0xffffffff>
  at GmpInteger.div (GmpInteger,GmpInteger) <0x0003f>

Native stacktrace:

	/usr/local/bin/mono() [0x8271690]
	/usr/local/bin/mono() [0x81ed1f0]
	/usr/lib/i386-linux-gnu/ [0xb4d7e477]
	/usr/lib/i386-linux-gnu/ [0xb4d7e4c6]
	/usr/lib/i386-linux-gnu/ [0xb4d95905]

Debug info from gdb:

Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.

Revised BSD license

  Home   Conclusions   License   Play