Skip to content

Instantly share code, notes, and snippets.

@jaredpar
Created April 10, 2023 21:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaredpar/d4d8a19a18468d4f9b0aeb9f4f080235 to your computer and use it in GitHub Desktop.
Save jaredpar/d4d8a19a18468d4f9b0aeb9f4f080235 to your computer and use it in GitHub Desktop.
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