【发布时间】:2019-12-20 08:41:20
【问题描述】:
(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
}
这就是我到目前为止所做的。 有没有更好的办法?
【问题讨论】:
-
如何将
#if和#endif部分移到方法外以将其完全封装? -
那么它不会检测到 CoreOnly() 基准,并且只测试了 General。在我的版本中,CoreOnly() 被添加到 4.7.2-report 中,速度超快 XD。我希望 CoreOnly() 隐藏在结果报告中(不,我不想手动从报告中删除它;))
标签: c# benchmarkdotnet