Add some new benchmarks. They will be added to the makefile after the freeze
authorBen Maurer <benm@mono-cvs.ximian.com>
Mon, 28 Jun 2004 14:45:50 +0000 (14:45 -0000)
committerBen Maurer <benm@mono-cvs.ximian.com>
Mon, 28 Jun 2004 14:45:50 +0000 (14:45 -0000)
svn path=/trunk/mono/; revision=30477

mono/benchmark/incr.cs [new file with mode: 0644]
mono/benchmark/lock.cs [new file with mode: 0644]
mono/benchmark/long-muldiv.cs [new file with mode: 0644]
mono/benchmark/regalloc-2.cs
mono/benchmark/regalloc-3.cs [new file with mode: 0644]
mono/benchmark/regvar.cs [new file with mode: 0644]
mono/benchmark/stelemref.cs [new file with mode: 0644]

diff --git a/mono/benchmark/incr.cs b/mono/benchmark/incr.cs
new file mode 100644 (file)
index 0000000..696de5a
--- /dev/null
@@ -0,0 +1,26 @@
+using System;
+class T {
+       static void Main () {
+               int i = Environment.TickCount;
+               new T ().X ();
+               Console.WriteLine (Environment.TickCount - i);
+       }
+       
+       int [] window = new int [9];
+       
+       void X () {
+               int scan = 0, match = 0;
+               for (int i = 0; i < 5000000; i ++) {
+                       if (window[++scan] == window[++match] && 
+                               window[++scan] == window[++match] && 
+                               window[++scan] == window[++match] && 
+                               window[++scan] == window[++match] && 
+                               window[++scan] == window[++match] && 
+                               window[++scan] == window[++match] && 
+                               window[++scan] == window[++match] && 
+                               window[++scan] == window[++match]) {
+                                       scan = match = 0;
+                       }       
+               }
+       }
+}
\ No newline at end of file
diff --git a/mono/benchmark/lock.cs b/mono/benchmark/lock.cs
new file mode 100644 (file)
index 0000000..28e9bf1
--- /dev/null
@@ -0,0 +1,13 @@
+using System;
+class T {
+       static void Main () {
+               int i = Environment.TickCount;
+               new T ().X ();
+               Console.WriteLine (Environment.TickCount - i);
+       }
+       
+       void X () {
+               for (int i = 0; i < 10000000; i ++)
+                       lock (this) {}
+       }
+}
\ No newline at end of file
diff --git a/mono/benchmark/long-muldiv.cs b/mono/benchmark/long-muldiv.cs
new file mode 100644 (file)
index 0000000..1cdb26c
--- /dev/null
@@ -0,0 +1,24 @@
+using System;
+class T {
+       static void Main () {
+               int i = Environment.TickCount;
+               new T ().X ();
+               Console.WriteLine (Environment.TickCount - i);
+       }
+       
+       void X () {
+               long a = 1, b = 2, c = 3, d = 4;
+               
+               for (int i = 0; i < 10000000; i ++) {
+                       a /= (b + 1);
+                       b /= (c + 1);
+                       c /= (d + 1);
+                       d /= (a + 1);
+                       
+                       a *= (b + 2);
+                       b *= (c + 2);
+                       c *= (d + 2);
+                       d *= (a + 2);
+               }
+       }
+}
\ No newline at end of file
index f8b1eb698f80e133bdec7d7bcced0db4196bd4e9..69bb0c238f5ca930a18226a7c5b0a402255ea766 100644 (file)
@@ -1,3 +1,15 @@
+//
+// Idealy, we would fold the operations from a...h into one long xor chain,
+// we could then commute the xor operation.
+//
+// More realisticly, we should assign each of a...h to one reg, rather than making
+// the two swap between two registers:
+//      (stind.i4 regvar[%edi] (xor (ldind.i4 regoffset[-0x18(%ebp)]) iconst[1]))
+//      (stind.i4 regvar[%esi] (xor (ldind.i4 regvar[%edi]) iconst[2]))
+//      (stind.i4 regvar[%edi] (xor (ldind.i4 regvar[%esi]) iconst[3]))
+//      (stind.i4 regvar[%esi] (xor (ldind.i4 regvar[%edi]) iconst[4]))
+//
+
 class T {
        static void Main ()
        {
diff --git a/mono/benchmark/regalloc-3.cs b/mono/benchmark/regalloc-3.cs
new file mode 100644 (file)
index 0000000..643a9cf
--- /dev/null
@@ -0,0 +1,65 @@
+//
+// You need a deadce to get rid of the initlocals statements,
+// which make all of the variables overlap in their live ranges.
+//
+
+using System;
+class T {
+       static void Main () {
+               int i = Environment.TickCount;
+               new T ().X ();
+               Console.WriteLine (Environment.TickCount - i);
+       }
+       
+       void X () {
+               int a = 0;
+               for (int x = 0; x < 1000; x ++) {
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+                       for (int i = 0; i < 10000; i ++) a ++;
+               }
+       }
+}
\ No newline at end of file
diff --git a/mono/benchmark/regvar.cs b/mono/benchmark/regvar.cs
new file mode 100644 (file)
index 0000000..4f5e0a3
--- /dev/null
@@ -0,0 +1,43 @@
+//
+// We get stuff like:
+//  48:        8b c3                   mov    eax,ebx
+//  4a:        8b cf                   mov    ecx,edi
+//  4c:        0b c1                   or     eax,ecx
+//  4e:        8b d8                   mov    ebx,eax
+//
+
+using System;
+class T {
+       static void Main () {
+               int i = Environment.TickCount;
+               new T ().X ();
+               Console.WriteLine (Environment.TickCount - i);
+       }
+       
+       void X () {
+               int a = 0, b = 0, c = 0, d = 0;
+               for (int i = 0; i < 50000000; i ++) {
+                       
+                       
+                       a |= b;
+                       b |= c;
+                       c |= d;
+                       b |= d;
+                       
+                       a ^= b;
+                       b ^= c;
+                       c ^= d;
+                       b ^= d;
+                       
+                       a &= b;
+                       b &= c;
+                       c &= d;
+                       b &= d;
+                       
+                       a += b;
+                       b += c;
+                       c += d;
+                       b += d;
+               }
+       }
+}
\ No newline at end of file
diff --git a/mono/benchmark/stelemref.cs b/mono/benchmark/stelemref.cs
new file mode 100644 (file)
index 0000000..7020f5a
--- /dev/null
@@ -0,0 +1,15 @@
+using System;
+class T {
+       static void Main () {
+               int i = Environment.TickCount;
+               new T ().X ();
+               Console.WriteLine (Environment.TickCount - i);
+       }
+       
+       void X () {
+               object [] x = new object [1];
+               object o = new object ();
+               for (int i = 0; i < 10000000; i ++)
+                       x [0] = o;
+       }
+}
\ No newline at end of file