summaryrefslogtreecommitdiff
path: root/tests/src/performance/perflab/EnumPerf.cs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src/performance/perflab/EnumPerf.cs')
-rw-r--r--tests/src/performance/perflab/EnumPerf.cs109
1 files changed, 56 insertions, 53 deletions
diff --git a/tests/src/performance/perflab/EnumPerf.cs b/tests/src/performance/perflab/EnumPerf.cs
index bf8d89b476..1e3a493686 100644
--- a/tests/src/performance/perflab/EnumPerf.cs
+++ b/tests/src/performance/perflab/EnumPerf.cs
@@ -6,71 +6,74 @@ using System;
using System.Reflection;
using Xunit;
-public enum Color
+namespace PerfLabTests
{
- Black,
- White,
- Red,
- Brown,
- Yellow,
- Purple,
- Orange
-}
-
-public class EnumPerf
-{
- [Benchmark(InnerIterationCount=300000)]
- [InlineData(Color.Red)]
- public static void EnumCompareTo(Color color)
+ public enum Color
{
- Color white = Color.White;
-
- foreach (var iteration in Benchmark.Iterations)
- using (iteration.StartMeasurement())
- for (int i = 0; i < Benchmark.InnerIterationCount; i++)
- color.CompareTo(white);
+ Black,
+ White,
+ Red,
+ Brown,
+ Yellow,
+ Purple,
+ Orange
}
- [Benchmark(InnerIterationCount=300000)]
- public static Type ObjectGetType()
+ public class EnumPerf
{
- Type tmp = null;
- Color black = Color.Black;
+ [Benchmark(InnerIterationCount = 300000)]
+ [InlineData(Color.Red)]
+ public static void EnumCompareTo(Color color)
+ {
+ Color white = Color.White;
- foreach (var iteration in Benchmark.Iterations)
- using (iteration.StartMeasurement())
- for (int i = 0; i < Benchmark.InnerIterationCount; i++)
- tmp = black.GetType();
+ foreach (var iteration in Benchmark.Iterations)
+ using (iteration.StartMeasurement())
+ for (int i = 0; i < Benchmark.InnerIterationCount; i++)
+ color.CompareTo(white);
+ }
- return tmp;
- }
+ [Benchmark(InnerIterationCount = 300000)]
+ public static Type ObjectGetType()
+ {
+ Type tmp = null;
+ Color black = Color.Black;
- [Benchmark(InnerIterationCount=300000)]
- public static Type ObjectGetTypeNoBoxing()
- {
- Type tmp = null;
- object black = Color.Black;
+ foreach (var iteration in Benchmark.Iterations)
+ using (iteration.StartMeasurement())
+ for (int i = 0; i < Benchmark.InnerIterationCount; i++)
+ tmp = black.GetType();
- foreach (var iteration in Benchmark.Iterations)
- using (iteration.StartMeasurement())
- for (int i = 0; i < Benchmark.InnerIterationCount; i++)
- tmp = black.GetType();
+ return tmp;
+ }
- return tmp;
- }
+ [Benchmark(InnerIterationCount = 300000)]
+ public static Type ObjectGetTypeNoBoxing()
+ {
+ Type tmp = null;
+ object black = Color.Black;
- [Benchmark(InnerIterationCount=300000)]
- public static bool EnumEquals()
- {
- Color black = Color.Black;
- Color white = Color.White;
- bool tmp = false;
+ foreach (var iteration in Benchmark.Iterations)
+ using (iteration.StartMeasurement())
+ for (int i = 0; i < Benchmark.InnerIterationCount; i++)
+ tmp = black.GetType();
+
+ return tmp;
+ }
+
+ [Benchmark(InnerIterationCount = 300000)]
+ public static bool EnumEquals()
+ {
+ Color black = Color.Black;
+ Color white = Color.White;
+ bool tmp = false;
- foreach (var iteration in Benchmark.Iterations)
- using (iteration.StartMeasurement())
- for (int i = 0; i < Benchmark.InnerIterationCount; i++)
- tmp = black.Equals(white);
+ foreach (var iteration in Benchmark.Iterations)
+ using (iteration.StartMeasurement())
+ for (int i = 0; i < Benchmark.InnerIterationCount; i++)
+ tmp = black.Equals(white);
- return tmp;
+ return tmp;
+ }
}
}