diff options
author | Jiyoung Yun <jy910.yun@samsung.com> | 2016-12-27 16:46:08 +0900 |
---|---|---|
committer | Jiyoung Yun <jy910.yun@samsung.com> | 2016-12-27 16:46:08 +0900 |
commit | db20f3f1bb8595633a7e16c8900fd401a453a6b5 (patch) | |
tree | e5435159cd1bf0519276363a6fe1663d1721bed3 /tests/src/performance/perflab/EnumPerf.cs | |
parent | 4b4aad7217d3292650e77eec2cf4c198ea9c3b4b (diff) | |
download | coreclr-db20f3f1bb8595633a7e16c8900fd401a453a6b5.tar.gz coreclr-db20f3f1bb8595633a7e16c8900fd401a453a6b5.tar.bz2 coreclr-db20f3f1bb8595633a7e16c8900fd401a453a6b5.zip |
Imported Upstream version 1.0.0.9127upstream/1.0.0.9127
Diffstat (limited to 'tests/src/performance/perflab/EnumPerf.cs')
-rw-r--r-- | tests/src/performance/perflab/EnumPerf.cs | 109 |
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; + } } } |