Created
February 16, 2018 02:59
-
-
Save ViktorHofer/43a61de5cd7d3e45b29e36e7a40f21c2 to your computer and use it in GitHub Desktop.
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
using BenchmarkDotNet.Attributes; | |
using BenchmarkDotNet.Columns; | |
using BenchmarkDotNet.Configs; | |
using BenchmarkDotNet.Diagnosers; | |
using BenchmarkDotNet.Environments; | |
using BenchmarkDotNet.Exporters; | |
using BenchmarkDotNet.Jobs; | |
using BenchmarkDotNet.Loggers; | |
using BenchmarkDotNet.Running; | |
using BenchmarkDotNet.Toolchains.CsProj; | |
using BenchmarkDotNet.Toolchains.DotNetCli; | |
using BenchmarkDotNet.Toolchains.InProcess; | |
using System; | |
using System.Linq; | |
namespace uribenchmark | |
{ | |
public class UriBenchmark | |
{ | |
private readonly char[] _chars = Enumerable.Range(33, 126).Select(i => (char)i).ToArray(); | |
[Benchmark] | |
public void HexEscape() | |
{ | |
for (int i = 0; i < 200_000; i++) | |
foreach (char c in _chars) | |
Uri.HexEscape(c); | |
} | |
} | |
class MainConfig : ManualConfig | |
{ | |
public MainConfig() | |
{ | |
// Job #1 | |
// Add(Job.Default | |
// .With(Runtime.Core) | |
// .With(CsProjCoreToolchain.From(NetCoreAppSettings | |
// .NetCoreApp21 | |
// .WithCustomDotNetCliPath(@"C:\dotnet\dotnet.exe", "OutOfProcessToolchain"))) | |
// .WithId(".NET Core 2.1 master")); | |
// Job #2 | |
Add(Job.Default | |
.With(InProcessToolchain.Instance) | |
.With(Runtime.Core) | |
.WithId(".NET Core 2.1 regex")); | |
Add(DefaultColumnProviders.Instance); | |
Add(MarkdownExporter.GitHub); | |
Add(new ConsoleLogger()); | |
Add(new HtmlExporter()); | |
Add(MemoryDiagnoser.Default); | |
} | |
} | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
BenchmarkRunner.Run<UriBenchmark>(new MainConfig()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment