【问题标题】:How to group benchmark results by method name in BenchmarkDotNet如何在 BenchmarkDotNet 中按方法名称对基准测试结果进行分组
【发布时间】:2022-08-04 16:57:48
【问题描述】:

我正在尝试按方法名称分组输出我的 benchmarkDotNet 结果。相反,它按范围分组。

我的基准测试输出如下所示:

Method Range Mean Error StdDev
FindPrimes 1000 23.377 us 0.1524 us 0.1425 us
FindPrimesSieveOfEratosthenes 1000 3.140 us 0.0196 us 0.0183 us
FindPrimes 10000 513.180 us 0.3876 us 0.3026 us
FindPrimesSieveOfEratosthenes 10000 31.487 us 0.1408 us 0.1175 us
FindPrimes 100000 12,266.783 us 90.4759 us 84.6312 us
FindPrimesSieveOfEratosthenes 100000 282.112 us 3.7559 us 3.5133 us

我想要的是:

Method Range Mean Error StdDev
FindPrimes 1000 23.377 us 0.1524 us 0.1425 us
FindPrimes 10000 513.180 us 0.3876 us 0.3026 us
FindPrimes 100000 12,266.783 us 90.4759 us 84.6312 us
FindPrimesSieveOfEratosthenes 1000 3.140 us 0.0196 us 0.0183 us
FindPrimesSieveOfEratosthenes 10000 31.487 us 0.1408 us 0.1175 us
FindPrimesSieveOfEratosthenes 100000 282.112 us 3.7559 us 3.5133 us

我试图用 orderer 设置自定义配置,但到目前为止我没有运气。也许我使用了错误的参数:

var config = ManualConfig.CreateMinimumViable()
.WithOrderer(new DefaultOrderer(SummaryOrderPolicy.Declared, MethodOrderPolicy.Alphabetical))
.AddExporter(exporter); // an csv exporter, removed for brevity

BenchmarkRunner.Run<Benchmarks>(config);

    标签: c# benchmarkdotnet


    【解决方案1】:

    您是否尝试过在您的班级上方添加此属性?

    [Orderer(BenchmarkDotNet.Order.SummaryOrderPolicy.Method)]
    

    【讨论】:

      猜你喜欢
      • 2018-09-12
      • 1970-01-01
      • 2016-01-20
      • 1970-01-01
      • 2017-11-28
      • 1970-01-01
      • 2011-02-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多