-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"sdk": { | ||
"version": "8.0.100" | ||
"version": "9.0.100-rc.1.24452.12" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,49 @@ | ||
// Copyright © myCSharp.de - all rights reserved | ||
|
||
using System.Collections.Generic; | ||
using System.Linq; | ||
using BenchmarkDotNet.Attributes; | ||
|
||
#if OS_WIN | ||
using BenchmarkDotNet.Diagnostics.Windows.Configs; | ||
using BenchmarkDotNet.Jobs; | ||
#endif | ||
|
||
namespace MyCSharp.HttpUserAgentParser.Benchmarks | ||
{ | ||
[MemoryDiagnoser] | ||
namespace MyCSharp.HttpUserAgentParser.Benchmarks; | ||
|
||
[MemoryDiagnoser] | ||
[SimpleJob(RuntimeMoniker.Net80)] | ||
Check failure on line 13 in perf/MyCSharp.HttpUserAgentParser.Benchmarks/HttpUserAgentParserBenchmarks.cs GitHub Actions / build
Check failure on line 13 in perf/MyCSharp.HttpUserAgentParser.Benchmarks/HttpUserAgentParserBenchmarks.cs GitHub Actions / build
Check failure on line 13 in perf/MyCSharp.HttpUserAgentParser.Benchmarks/HttpUserAgentParserBenchmarks.cs GitHub Actions / build
Check failure on line 13 in perf/MyCSharp.HttpUserAgentParser.Benchmarks/HttpUserAgentParserBenchmarks.cs GitHub Actions / build
|
||
[SimpleJob(RuntimeMoniker.Net90)] | ||
Check failure on line 14 in perf/MyCSharp.HttpUserAgentParser.Benchmarks/HttpUserAgentParserBenchmarks.cs GitHub Actions / build
Check failure on line 14 in perf/MyCSharp.HttpUserAgentParser.Benchmarks/HttpUserAgentParserBenchmarks.cs GitHub Actions / build
Check failure on line 14 in perf/MyCSharp.HttpUserAgentParser.Benchmarks/HttpUserAgentParserBenchmarks.cs GitHub Actions / build
Check failure on line 14 in perf/MyCSharp.HttpUserAgentParser.Benchmarks/HttpUserAgentParserBenchmarks.cs GitHub Actions / build
|
||
#if OS_WIN | ||
[EtwProfiler] // needs admin-rights | ||
[EtwProfiler] // needs admin-rights | ||
#endif | ||
public class HttpUserAgentParserBenchmarks | ||
public class HttpUserAgentParserBenchmarks | ||
{ | ||
private string[] _testUserAgentMix; | ||
private HttpUserAgentInformation[] _results; | ||
|
||
[GlobalSetup] | ||
public void GlobalSetup() | ||
{ | ||
private string[] _testUserAgentMix; | ||
private HttpUserAgentInformation[] _results; | ||
_testUserAgentMix = GetTestUserAgents().ToArray(); | ||
_results = new HttpUserAgentInformation[_testUserAgentMix.Length]; | ||
} | ||
|
||
[GlobalSetup] | ||
public void GlobalSetup() | ||
{ | ||
_testUserAgentMix = GetTestUserAgents().ToArray(); | ||
_results = new HttpUserAgentInformation[_testUserAgentMix.Length]; | ||
} | ||
private static IEnumerable<string> GetTestUserAgents() | ||
{ | ||
yield return "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36"; | ||
yield return "APIs-Google (+https://developers.google.com/webmasters/APIs-Google.html)"; | ||
yield return "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:88.0) Gecko/20100101 Firefox/88.0"; | ||
yield return "yeah I'm unknown user agent, just to bring some fun to the mix"; | ||
} | ||
|
||
private static IEnumerable<string> GetTestUserAgents() | ||
{ | ||
yield return "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36"; | ||
yield return "APIs-Google (+https://developers.google.com/webmasters/APIs-Google.html)"; | ||
yield return "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:88.0) Gecko/20100101 Firefox/88.0"; | ||
yield return "yeah I'm unknown user agent, just to bring some fun to the mix"; | ||
} | ||
[Benchmark] | ||
public void Parse() | ||
{ | ||
string[] testUserAgentMix = _testUserAgentMix; | ||
HttpUserAgentInformation[] results = _results; | ||
|
||
[Benchmark] | ||
public void Parse() | ||
for (int i = 0; i < testUserAgentMix.Length; ++i) | ||
{ | ||
string[] testUserAgentMix = _testUserAgentMix; | ||
HttpUserAgentInformation[] results = _results; | ||
|
||
for (int i = 0; i < testUserAgentMix.Length; ++i) | ||
{ | ||
results[i] = HttpUserAgentParser.Parse(testUserAgentMix[i]); | ||
} | ||
results[i] = HttpUserAgentParser.Parse(testUserAgentMix[i]); | ||
} | ||
} | ||
} |