using System.Diagnostics;
public static bool CheckWithIs<T>(object o)
public static bool CheckWithGetType<T>(object o)
return o.GetType() == typeof(T);
private const int Iterations = 10_000_000;
public static void Benchmark<T>(object o)
var stopwatch = new Stopwatch();
for (var i = 0; i < Iterations; ++i)
var elapsed = stopwatch.Elapsed;
Console.WriteLine($"{nameof(CheckWithIs)} -- {elapsed:g}");
for (var i = 0; i < Iterations; ++i)
elapsed = stopwatch.Elapsed - elapsed;
Console.WriteLine($"{nameof(CheckWithGetType)} -- {stopwatch.Elapsed:g}");
public static void Main()