Created
April 10, 2023 21:27
-
-
Save jaredpar/d4d8a19a18468d4f9b0aeb9f4f080235 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using BenchmarkDotNet.Attributes; | |
using BenchmarkDotNet.Jobs; | |
using BenchmarkDotNet.Running; | |
var summary = BenchmarkRunner.Run(typeof(DelegateInvocationBenchmark).Assembly); | |
[SimpleJob(RuntimeMoniker.Net70)] | |
[SimpleJob(RuntimeMoniker.Net472)] | |
public class DelegateInvocationBenchmark | |
{ | |
Action _instanceAction; | |
Action _staticAction; | |
private static void StaticMethod() { } | |
private void InstanceMethod() { } | |
[GlobalSetup] | |
public void GlobalSetup() | |
{ | |
_instanceAction = InstanceMethod; | |
_staticAction = StaticMethod; | |
} | |
[Benchmark] | |
public void ActionStatic() | |
{ | |
_staticAction(); | |
} | |
[Benchmark] | |
public void ActionInstance() | |
{ | |
_instanceAction(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment