petabridge / NBench

Performance benchmarking and testing framework for .NET applications :chart_with_upwards_trend:
https://nbench.io/
Apache License 2.0
532 stars 46 forks source link

Create NBench runner for dotnet CLI #165

Closed alexvaluyskiy closed 7 years ago

alexvaluyskiy commented 7 years ago

Right now NBench has netcoreapp support in NBench.Runner https://github.com/petabridge/NBench/blob/dev/src/NBench.Runner/NBench.Runner.csproj

But it is not enough for DotNet CLI.

The proper solution is to create an additional project with almost the same content as NBench.Runner, and this metadata

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <AssemblyTitle>dotnet-nbench</AssemblyTitle>
    <TargetFrameworks>netcoreapp1.0</TargetFrameworks>
    <OutputType>Exe</OutputType>
    <PackageType>DotnetCliTool</PackageType>
  </PropertyGroup>

  <ItemGroup>
    <ProjectReference Include="..\NBench\NBench.csproj" />
  </ItemGroup>
</Project>

Instead of exe and dll files the runner should accept the current project and its configuration (Debug/Release) and try to find a dll in bin/[Configuration] folder.

The project with performance test may add a runner via nuget, like this

  <ItemGroup>
    <DotNetCliToolReference Include="dotnet-nbench" Version="0.3.5" />
  </ItemGroup>

If we want to run the test, we should go to the project's folder and type

dotnet nbench
dotnet nbench [include=MyTest*.Perf*,Other*Spec]

NBench.Runner project could stay with only one target - net452

Docs: https://docs.microsoft.com/en-us/dotnet/articles/core/tools/extensibility

Aaronontheweb commented 7 years ago

This is finished as of NBench 1.0. Instructions here: https://github.com/petabridge/NBench#net-core-runner