From 04b6d35009de16258ddc4df26456093c954944c9 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 7 Dec 2020 23:16:53 +0100 Subject: [PATCH] Fixed ComputeSharp.Benchmark project --- nuget.config | 1 + .../ComputeSharp.Benchmark.csproj | 2 +- .../ComputeSharp.Benchmark/DnnBenchmark.cs | 2 ++ samples/ComputeSharp.Benchmark/Program.cs | 32 +++++++++++++------ 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/nuget.config b/nuget.config index 817ced4c..af57fd7e 100644 --- a/nuget.config +++ b/nuget.config @@ -2,5 +2,6 @@ + diff --git a/samples/ComputeSharp.Benchmark/ComputeSharp.Benchmark.csproj b/samples/ComputeSharp.Benchmark/ComputeSharp.Benchmark.csproj index 019811a5..8835dac9 100644 --- a/samples/ComputeSharp.Benchmark/ComputeSharp.Benchmark.csproj +++ b/samples/ComputeSharp.Benchmark/ComputeSharp.Benchmark.csproj @@ -6,7 +6,7 @@ - + diff --git a/samples/ComputeSharp.Benchmark/DnnBenchmark.cs b/samples/ComputeSharp.Benchmark/DnnBenchmark.cs index a5ecf7df..1b163220 100644 --- a/samples/ComputeSharp.Benchmark/DnnBenchmark.cs +++ b/samples/ComputeSharp.Benchmark/DnnBenchmark.cs @@ -3,12 +3,14 @@ using System.Buffers; using System.Diagnostics.Contracts; using System.Runtime.CompilerServices; using BenchmarkDotNet.Attributes; +using BenchmarkDotNet.Engines; namespace ComputeSharp.Benchmark { /// /// A that benchmarks the APIs in the class, on both CPU and GPU. /// + [SimpleJob(RunStrategy.Monitoring)] public class DnnBenchmark : IDisposable { /// diff --git a/samples/ComputeSharp.Benchmark/Program.cs b/samples/ComputeSharp.Benchmark/Program.cs index 3667f4c3..b90ec8ec 100644 --- a/samples/ComputeSharp.Benchmark/Program.cs +++ b/samples/ComputeSharp.Benchmark/Program.cs @@ -1,18 +1,32 @@ -using BenchmarkDotNet.Running; +using BenchmarkDotNet.Configs; +using BenchmarkDotNet.Jobs; +using BenchmarkDotNet.Running; +using BenchmarkDotNet.Toolchains.CsProj; +using BenchmarkDotNet.Toolchains.DotNetCli; namespace ComputeSharp.Benchmark { public class Program { - public static void Main() + public static void Main(string[] args) { - /* ================= - * BenchmarkDotNet - * ================ - * In order to run this benchmark, compile this project in Release mode, - * then go to its bin\Release\netcoreapp3.0 folder, open a cmd prompt - * and type "dotnet ComputeSharp.Benchmark.dll */ - BenchmarkRunner.Run(); + ManualConfig configuration = + DefaultConfig.Instance.AddJob( + Job.Default.WithToolchain( + CsProjCoreToolchain.From( + new NetCoreAppSettings( + targetFrameworkMoniker: "net5.0-windows10.0.19041.0", + runtimeFrameworkVersion: null, + name: "5.0"))) + .AsDefault()); + + // ================= + // BenchmarkDotNet + // ================ + // In order to run this benchmark, compile this project in Release mode, + // then go to its bin\Release\netcoreapp3.0 folder, open a cmd prompt + // and type "dotnet ComputeSharp.Benchmark.dll" to execute it. + BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args, configuration); } } }