面对我当前的基准测试配置无法正常工作的问题,原因是我正在尝试仅运行基准测试,因为正如文档中提到的那样,我必须使用此属性[SimpleJob(RunStrategy.ColdStart, targetCount: 1)]
,这是让我走错了方向,因为从控制台我注意到我的单人板凳被建立了两次。
// ***** BenchmarkRunner: Start *****
// ***** Found 2 benchmark(s) in total *****
// ***** Building 2 exe(s) in Parallel: Start *****
internal class Program
{
static async Task Main(string[] args) => BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args, new DebugInProcessConfig());
}
[MarkdownExporter]
[AsciiDocExporter]
[HtmlExporter]
[CsvExporter]
[RPlotExporter]
[SimpleJob(RunStrategy.ColdStart, targetCount: 1)]
public class MyBench
{
[Params(2)] public int _anotherValueToTestWith;
[Params(2)] public int _valueToTestWith;
[GlobalSetup]
public void GlobalSetup()
{
// ...
}
[GlobalCleanup]
public void GlobalCleanup()
{
// CleanUp
}
[Benchmark]
public void AccessTokenServiceBench()
{
// Perform bench
}
}
我在这里缺少什么?