Some benchmarks for ValueType Equals () and GetHashCode
authorGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Fri, 14 Nov 2003 17:26:38 +0000 (17:26 -0000)
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Fri, 14 Nov 2003 17:26:38 +0000 (17:26 -0000)
svn path=/trunk/mono/; revision=20000

mono/benchmark/Makefile.am
mono/benchmark/valuetype1.cs [new file with mode: 0644]
mono/benchmark/valuetype2.cs [new file with mode: 0644]
mono/benchmark/valuetype3.cs [new file with mode: 0644]

index 857e5403f24887b5b2712cf823e4721595e0cd1e..b4d8c71ccc9fea1b0ec4be606e0465ff1865d2ed 100644 (file)
@@ -24,7 +24,9 @@ TESTSRC=                      \
        readonly.cs             \
        bulkcpy.il              \
        math.cs                 \
-       boxtest.cs
+       boxtest.cs              \
+       valuetype1.cs           \
+       valuetype2.cs
 
 TESTSI_TMP=$(TESTSRC:.cs=.exe)
 TESTSI=$(TESTSI_TMP:.il=.exe)
diff --git a/mono/benchmark/valuetype1.cs b/mono/benchmark/valuetype1.cs
new file mode 100644 (file)
index 0000000..1fbbbdf
--- /dev/null
@@ -0,0 +1,27 @@
+using System;
+
+public class ValueType1
+{
+       static int Main ()
+       {
+               Blah a = new Blah ("abc", 1);
+
+               for (int i = 0; i < 1000000; i++)
+                       a.GetHashCode ();
+
+               return 0;
+       }
+
+       struct Blah
+       { 
+               public string s;
+               public int i;
+
+               public Blah (string s, int k)
+               {
+                       this.s = s;
+                       i = k;
+               }
+       }
+}
+
diff --git a/mono/benchmark/valuetype2.cs b/mono/benchmark/valuetype2.cs
new file mode 100644 (file)
index 0000000..e07d964
--- /dev/null
@@ -0,0 +1,28 @@
+using System;
+
+public class ValueType2
+{
+       static int Main ()
+       {
+               Blah a = new Blah ("abc", 1);
+               Blah b = new Blah (string.Format ("ab{0}", 'c'), 1);
+
+               for (int i = 0; i < 1000000; i++)
+                       a.Equals (b);
+
+               return 0;
+       }
+
+       struct Blah
+       { 
+               public string s;
+               public int i;
+
+               public Blah (string s, int k)
+               {
+                       this.s = s;
+                       i = k;
+               }
+       }
+}
+
diff --git a/mono/benchmark/valuetype3.cs b/mono/benchmark/valuetype3.cs
new file mode 100644 (file)
index 0000000..f92ea18
--- /dev/null
@@ -0,0 +1,28 @@
+using System;
+
+public class ValueType2
+{
+       static int Main ()
+       {
+               Blah a = new Blah ("abc", 1);
+               Blah b = new Blah (string.Format ("ab{0}", 'c'), 2);
+
+               for (int i = 0; i < 1000000; i++)
+                       a.Equals (b);
+
+               return 0;
+       }
+
+       struct Blah
+       { 
+               public string s;
+               public int i;
+
+               public Blah (string s, int k)
+               {
+                       this.s = s;
+                       i = k;
+               }
+       }
+}
+