如何运行

  有几种方式可以让你的基准测试运行起来。

类型

    var summary = BenchmarkRunner.Run<MyBenchmarkClass>(); var summary = BenchmarkRunner.Run(typeof(MyBenchmarkClass));

全局dotcore 工具

  你可以使用 BenchmarkDotNet.Tool来执行你的基准测试。

    dotnet tool install -g BenchmarkDotNet.Tool
    dotnet benchmark MyAssemblyWithBenchmarks.dll --filter *

Url

  也可以直接运行来自internet的基准测试代码。

    string url = "<E.g. direct link to raw content of a gist>"; var summary = BenchmarkRunner.RunUrl(url);

Source

    string benchmarkSource = "public class MyBenchmarkClass { ..."; var summary = BenchmarkRunner.RunSource(benchmarkSource);

基准开关

  或者可以创建一组基准并从命令行中选择一个基准

    static void Main(string[] args) => BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);

  还可以使用config命令样式从命令行指定一些配置(更多@docs.console参数)

    dotnet run -c Release -- --job short --runtimes clr core --filter *BenchmarkClass1*
版权声明: 本文为智客工坊「楠木大叔」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。

results matching ""

    No results matching ""