diff --git a/src/benchmarks/micro/runtime/System.Reflection/RuntimeEventInfo.cs b/src/benchmarks/micro/runtime/System.Reflection/RuntimeEventInfo.cs new file mode 100644 index 00000000000..3fe5046fcf9 --- /dev/null +++ b/src/benchmarks/micro/runtime/System.Reflection/RuntimeEventInfo.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using BenchmarkDotNet.Attributes; +using MicroBenchmarks; + +namespace System.Reflection +{ + [BenchmarkCategory(Categories.Runtime, Categories.Reflection)] + public class RuntimeEventInfo + { + private static readonly EventInfo s_eventInfo = typeof(RuntimeEventInfoTestClass).GetEvent(nameof(RuntimeEventInfoTestClass.Event1)); + + [Benchmark] + public int GetHashCodeBenchmark() + { + return s_eventInfo.GetHashCode(); + } + } + + public class RuntimeEventInfoTestClass + { + public event EventHandler Event1; + protected virtual void OnEvent1() => Event1?.Invoke(this, EventArgs.Empty); + } +} \ No newline at end of file diff --git a/src/benchmarks/micro/runtime/System.Reflection/RuntimeFieldInfo.cs b/src/benchmarks/micro/runtime/System.Reflection/RuntimeFieldInfo.cs new file mode 100644 index 00000000000..b69bcdfecdb --- /dev/null +++ b/src/benchmarks/micro/runtime/System.Reflection/RuntimeFieldInfo.cs @@ -0,0 +1,26 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using BenchmarkDotNet.Attributes; +using MicroBenchmarks; + +namespace System.Reflection +{ + [BenchmarkCategory(Categories.Runtime, Categories.Reflection)] + public class RuntimeFieldInfo + { + private static readonly FieldInfo s_fieldInfo = typeof(RuntimeFieldInfoTestClass).GetField(nameof(RuntimeFieldInfoTestClass.Field1)); + + [Benchmark] + public int GetHashCodeBenchmark() + { + return s_fieldInfo.GetHashCode(); + } + } + + public class RuntimeFieldInfoTestClass + { + public int Field1; + } +} \ No newline at end of file diff --git a/src/benchmarks/micro/runtime/System.Reflection/RuntimeMethodInfo.cs b/src/benchmarks/micro/runtime/System.Reflection/RuntimeMethodInfo.cs new file mode 100644 index 00000000000..239a2cd3d1e --- /dev/null +++ b/src/benchmarks/micro/runtime/System.Reflection/RuntimeMethodInfo.cs @@ -0,0 +1,26 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using BenchmarkDotNet.Attributes; +using MicroBenchmarks; + +namespace System.Reflection +{ + [BenchmarkCategory(Categories.Runtime, Categories.Reflection)] + public class RuntimeMethodInfo + { + private static readonly MethodInfo s_methodInfo = typeof(RuntimeMethodInfoTestClass).GetMethod(nameof(RuntimeMethodInfoTestClass.Method1)); + + [Benchmark] + public int GetHashCodeBenchmark() + { + return s_methodInfo.GetHashCode(); + } + } + + public class RuntimeMethodInfoTestClass + { + public int Method1() => throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/src/benchmarks/micro/runtime/System.Reflection/RuntimePropertyInfo.cs b/src/benchmarks/micro/runtime/System.Reflection/RuntimePropertyInfo.cs new file mode 100644 index 00000000000..477dbbfdc04 --- /dev/null +++ b/src/benchmarks/micro/runtime/System.Reflection/RuntimePropertyInfo.cs @@ -0,0 +1,26 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using BenchmarkDotNet.Attributes; +using MicroBenchmarks; + +namespace System.Reflection +{ + [BenchmarkCategory(Categories.Runtime, Categories.Reflection)] + public class RuntimePropertyInfo + { + private static readonly PropertyInfo s_propertyInfo = typeof(RuntimePropertyInfoTestClass).GetProperty(nameof(RuntimePropertyInfoTestClass.Property1)); + + [Benchmark] + public int GetHashCodeBenchmark() + { + return s_propertyInfo.GetHashCode(); + } + } + + public class RuntimePropertyInfoTestClass + { + public int Property1 { get; set; } + } +} \ No newline at end of file