From 6c79e84d1b6b45b6f94ada27ff333ab4112fb881 Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Mon, 10 Apr 2017 17:38:49 -0700 Subject: [PATCH] Add BenchmarkDotNet boilerplate --- .gitignore | 1 + build/dependencies.props | 1 + build/repo.props | 5 +++ .../Configs/CoreConfig.cs | 31 +++++++++++++++++++ ...soft.AspNetCore.Routing.Performance.csproj | 28 +++++++++++++++++ .../Program.cs | 17 ++++++++++ .../readme.md | 11 +++++++ 7 files changed, 94 insertions(+) create mode 100644 build/repo.props create mode 100644 test/Microsoft.AspNetCore.Routing.Performance/Configs/CoreConfig.cs create mode 100644 test/Microsoft.AspNetCore.Routing.Performance/Microsoft.AspNetCore.Routing.Performance.csproj create mode 100644 test/Microsoft.AspNetCore.Routing.Performance/Program.cs create mode 100644 test/Microsoft.AspNetCore.Routing.Performance/readme.md diff --git a/.gitignore b/.gitignore index 4b1e6cda0d..85521e0624 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,4 @@ node_modules **/[Cc]ompiler/[Rr]esources/**/*.js *launchSettings.json global.json +BenchmarkDotNet.Artifacts/ \ No newline at end of file diff --git a/build/dependencies.props b/build/dependencies.props index b97a8aa4bc..4f7bf7b77f 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,6 +1,7 @@ 2.0.0-* + 0.10.3 4.3.0 2.0.0-* 4.6.36-alpha diff --git a/build/repo.props b/build/repo.props new file mode 100644 index 0000000000..5f43ac20f6 --- /dev/null +++ b/build/repo.props @@ -0,0 +1,5 @@ + + + + + diff --git a/test/Microsoft.AspNetCore.Routing.Performance/Configs/CoreConfig.cs b/test/Microsoft.AspNetCore.Routing.Performance/Configs/CoreConfig.cs new file mode 100644 index 0000000000..bbeb805e6d --- /dev/null +++ b/test/Microsoft.AspNetCore.Routing.Performance/Configs/CoreConfig.cs @@ -0,0 +1,31 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using BenchmarkDotNet.Columns; +using BenchmarkDotNet.Configs; +using BenchmarkDotNet.Diagnosers; +using BenchmarkDotNet.Engines; +using BenchmarkDotNet.Jobs; +using BenchmarkDotNet.Validators; + +namespace Microsoft.AspNetCore.Routing.Performance +{ + public class CoreConfig : ManualConfig + { + public CoreConfig() + { + Add(JitOptimizationsValidator.FailOnError); + Add(MemoryDiagnoser.Default); + Add(StatisticColumn.OperationsPerSecond); + + Add(Job.Default + .With(BenchmarkDotNet.Environments.Runtime.Core) + .WithRemoveOutliers(false) + .With(new GcMode() { Server = true }) + .With(RunStrategy.Throughput) + .WithLaunchCount(3) + .WithWarmupCount(5) + .WithTargetCount(10)); + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Routing.Performance/Microsoft.AspNetCore.Routing.Performance.csproj b/test/Microsoft.AspNetCore.Routing.Performance/Microsoft.AspNetCore.Routing.Performance.csproj new file mode 100644 index 0000000000..0675630b42 --- /dev/null +++ b/test/Microsoft.AspNetCore.Routing.Performance/Microsoft.AspNetCore.Routing.Performance.csproj @@ -0,0 +1,28 @@ + + + + + + netcoreapp2.0 + Exe + true + true + false + + 2.0.0-* + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Routing.Performance/Program.cs b/test/Microsoft.AspNetCore.Routing.Performance/Program.cs new file mode 100644 index 0000000000..b510a13a28 --- /dev/null +++ b/test/Microsoft.AspNetCore.Routing.Performance/Program.cs @@ -0,0 +1,17 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Reflection; +using BenchmarkDotNet.Running; + +namespace Microsoft.AspNetCore.Routing.Performance +{ + public class Program + { + public static void Main(string[] args) + { + BenchmarkSwitcher.FromAssembly(typeof(Program).GetTypeInfo().Assembly).Run(args); + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Routing.Performance/readme.md b/test/Microsoft.AspNetCore.Routing.Performance/readme.md new file mode 100644 index 0000000000..38ce0ff71a --- /dev/null +++ b/test/Microsoft.AspNetCore.Routing.Performance/readme.md @@ -0,0 +1,11 @@ +Compile the solution in Release mode (so binaries are available in release) + +To run a specific benchmark add it as parameter. +``` +dotnet run -c Release +``` + +If you run without any parameters, you'll be offered the list of all benchmarks and get to choose. +``` +dotnet run -c Release +``` \ No newline at end of file