Created
December 25, 2017 00:00
-
-
Save benaadams/73fedf79313a90bdef4f4f617cbb7aa8 to your computer and use it in GitHub Desktop.
ExecutionContext.Run Test
This file contains hidden or 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 System.Threading; | |
| using BenchmarkDotNet.Attributes; | |
| using BenchmarkDotNet.Configs; | |
| using BenchmarkDotNet.Jobs; | |
| using BenchmarkDotNet.Running; | |
| namespace ExecutionContextTest | |
| { | |
| [Config(typeof(InProcConfig))] | |
| public class Program | |
| { | |
| private const int OperationsPerInvoke = 1000; | |
| static void Main(string[] args) | |
| { | |
| BenchmarkRunner.Run<Program>(); | |
| } | |
| [Benchmark(OperationsPerInvoke = OperationsPerInvoke)] | |
| public static void Run() | |
| { | |
| var ec = ExecutionContext.Capture(); | |
| for (var i = 0; i < OperationsPerInvoke; i++) | |
| { | |
| ExecutionContext.Run(ec, (o) => { }, null); | |
| } | |
| } | |
| } | |
| public class InProcConfig : ManualConfig | |
| { | |
| public InProcConfig() | |
| { | |
| Add(Job.InProcess | |
| .WithId("InProcess")); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment