Open
Description
Processing dotnet/runtime#116241 (comment) command:
Command
-amd -arm
using System.Runtime.CompilerServices;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
BenchmarkSwitcher.FromAssembly(typeof(Benchmarks).Assembly).Run(args);
public class Benchmarks
{
int class1 = 0;
int class2 = 0;
BaseClass b1 = new DerivedClass1();
BaseClass b2 = new DerivedClass2();
[Benchmark]
public void Bench()
{
for (int i = 0; i < 10000; i++)
Problem(i);
}
[MethodImpl(MethodImplOptions.NoInlining)]
public void Problem(int i)
{
BaseClass b = i % 3 == 0 ? b1 : b2;
if (b is DerivedClass1)
class1++;
else if (IsDerivedClass2(b))
class2++;
}
public bool IsDerivedClass2(BaseClass b) => b is DerivedClass2;
public class BaseClass { }
public class DerivedClass1 : BaseClass { }
public class DerivedClass2 : BaseClass { }
}
(EgorBot will reply in this issue)
Metadata
Metadata
Assignees
Labels
No labels