-
-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds all the bootstrapping to quickly add benchmarks for pieces afterwards. Instructions for running added to the README.
- Loading branch information
1 parent
a4825de
commit 38d7fae
Showing
6 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
test/Ben.Demystifier.Benchmarks/Ben.Demystifier.Benchmarks.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0"> | ||
<PropertyGroup> | ||
<TargetFrameworks>netcoreapp2.0;net462</TargetFrameworks> | ||
<Configuration>Release</Configuration> | ||
<OutputType>Exe</OutputType> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Ben.Demystifier\Ben.Demystifier.csproj" /> | ||
<PackageReference Include="BenchmarkDotNet" Version="0.10.12" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using BenchmarkDotNet.Attributes; | ||
using BenchmarkDotNet.Attributes.Jobs; | ||
|
||
namespace Ben.Demystifier.Benchmarks | ||
{ | ||
[ClrJob, CoreJob] | ||
[Config(typeof(Config))] | ||
public class ExceptionTests | ||
{ | ||
[Benchmark(Baseline = true, Description = ".ToString()")] | ||
public string Baseline() => new Exception().ToString(); | ||
|
||
[Benchmark(Description = "Demystify().ToString()")] | ||
public string Demystify() => new Exception().Demystify().ToString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using BenchmarkDotNet.Configs; | ||
using BenchmarkDotNet.Diagnosers; | ||
using BenchmarkDotNet.Running; | ||
using System; | ||
using System.Linq; | ||
using System.Reflection; | ||
|
||
namespace Ben.Demystifier.Benchmarks | ||
{ | ||
public static class Program | ||
{ | ||
private const string BenchmarkSuffix = "Tests"; | ||
|
||
public static void Main(string[] args) | ||
{ | ||
var benchmarks = Assembly.GetEntryAssembly() | ||
.DefinedTypes.Where(t => t.Name.EndsWith(BenchmarkSuffix)) | ||
.ToDictionary(t => t.Name.Substring(0, t.Name.Length - BenchmarkSuffix.Length), t => t, StringComparer.OrdinalIgnoreCase); | ||
|
||
if (args.Length > 0 && args[0].Equals("all", StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
Console.WriteLine("Running full benchmarks suite"); | ||
benchmarks.Select(pair => pair.Value).ToList().ForEach(action => BenchmarkRunner.Run(action)); | ||
return; | ||
} | ||
|
||
if (args.Length == 0 || !benchmarks.ContainsKey(args[0])) | ||
{ | ||
Console.WriteLine("Please, select benchmark, list of available:"); | ||
benchmarks | ||
.Select(pair => pair.Key) | ||
.ToList() | ||
.ForEach(Console.WriteLine); | ||
Console.WriteLine("All"); | ||
return; | ||
} | ||
|
||
BenchmarkRunner.Run(benchmarks[args[0]]); | ||
|
||
Console.Read(); | ||
} | ||
} | ||
|
||
internal class Config : ManualConfig | ||
{ | ||
public Config() => Add(new MemoryDiagnoser()); | ||
} | ||
} |