From a4f63452ab1eec8da7209924a5a47627f16e6008 Mon Sep 17 00:00:00 2001 From: Gonzalo Paniagua Javier Date: Fri, 14 Nov 2003 17:26:38 +0000 Subject: [PATCH] Some benchmarks for ValueType Equals () and GetHashCode svn path=/trunk/mono/; revision=20000 --- mono/benchmark/Makefile.am | 4 +++- mono/benchmark/valuetype1.cs | 27 +++++++++++++++++++++++++++ mono/benchmark/valuetype2.cs | 28 ++++++++++++++++++++++++++++ mono/benchmark/valuetype3.cs | 28 ++++++++++++++++++++++++++++ 4 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 mono/benchmark/valuetype1.cs create mode 100644 mono/benchmark/valuetype2.cs create mode 100644 mono/benchmark/valuetype3.cs diff --git a/mono/benchmark/Makefile.am b/mono/benchmark/Makefile.am index 857e5403f24..b4d8c71ccc9 100644 --- a/mono/benchmark/Makefile.am +++ b/mono/benchmark/Makefile.am @@ -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 index 00000000000..1fbbbdfd7e4 --- /dev/null +++ b/mono/benchmark/valuetype1.cs @@ -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 index 00000000000..e07d9647df3 --- /dev/null +++ b/mono/benchmark/valuetype2.cs @@ -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 index 00000000000..f92ea180d3c --- /dev/null +++ b/mono/benchmark/valuetype3.cs @@ -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; + } + } +} + -- 2.25.1