BenchmarkDotNet,跳过特定运行时的基准

时间:2019-12-20 08:41:20

标签: c# benchmarkdotnet

https://benchmarkdotnet.org/

是否可以针对特定的运行时跳过单个基准测试部分?

例如,我要测试4.7.2和Core 3.1的几个功能, 但只能在Core31上使用

[Benchmark]
public void CoreOnly()
{
#if NETCOREAPP3_1
    //some stuff i only want to test with 3.1
#endif
}

[Benchmark]
public void General()
{
    //some stuff i want to test on all runtimes
}

那是我到目前为止所做的。 有更好的方法吗?

1 个答案:

答案 0 :(得分:1)

这在设计上是不可能的。

在运行以XYZ框架为目标的主机进程时,BDN使用反射来获取可用方法(基准)的列表。如果您使用2231 = out_rows_number-1 = month_days_number*hours_per_day*orig_rows_number - 1定义,则每个主机进程目标框架的基准列表将有所不同。

性能回购文档在此处描述了如何比较多个运行时性能: https://github.com/dotnet/performance/blob/master/docs/benchmarkdotnet.md#multiple-runtimes

主机进程必须是您要比较的运行时的最低公共API分母!

您可以在此处阅读有关测试多个运行时的更多信息: https://benchmarkdotnet.org/articles/configs/toolchains.html#multiple-frameworks-support

相关问题