mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
Benchmark Framework
This commit is contained in:
@@ -0,0 +1,46 @@
|
|||||||
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
using BenchmarkDotNet.Attributes;
|
||||||
|
using NzbDrone.Core.Parser;
|
||||||
|
|
||||||
|
namespace NzbDrone.Benchmark.Test.ParserTests
|
||||||
|
{
|
||||||
|
[InProcess]
|
||||||
|
public class DateTimeUtilFixture
|
||||||
|
{
|
||||||
|
[Benchmark]
|
||||||
|
[Arguments("2022-08-08 02:07:39")]
|
||||||
|
public void parse_fuzzy_date(string dateInput)
|
||||||
|
{
|
||||||
|
DateTimeUtil.FromFuzzyTime(dateInput);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Benchmark]
|
||||||
|
[Arguments("18 hours ago")]
|
||||||
|
public void parse_time_ago(string dateInput)
|
||||||
|
{
|
||||||
|
DateTimeUtil.FromTimeAgo(dateInput);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Benchmark]
|
||||||
|
[Arguments("2022-08-08 02:07:39")]
|
||||||
|
public void parse_unknown_date(string dateInput)
|
||||||
|
{
|
||||||
|
DateTimeUtil.FromUnknown(dateInput);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Benchmark]
|
||||||
|
[Arguments("2022-08-08 02:07:39 -02:00", "2006-01-02 15:04:05 -07:00")]
|
||||||
|
public void parse_datetime_golang(string dateInput, string format)
|
||||||
|
{
|
||||||
|
DateTimeUtil.ParseDateTimeGoLang(dateInput, format);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Benchmark]
|
||||||
|
[Arguments("2022-08-08 02:07:39 -02:00", "yyyy-MM-dd HH:mm:ss zzz")]
|
||||||
|
public void parse_datetime_exact(string dateInput, string format)
|
||||||
|
{
|
||||||
|
DateTime.ParseExact(dateInput, format, CultureInfo.InvariantCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
15
src/Prowlarr.Benchmark.Test/Program.cs
Normal file
15
src/Prowlarr.Benchmark.Test/Program.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using BenchmarkDotNet.Attributes;
|
||||||
|
using BenchmarkDotNet.Running;
|
||||||
|
|
||||||
|
namespace NzbDrone.Benchmark.Test
|
||||||
|
{
|
||||||
|
public class Program
|
||||||
|
{
|
||||||
|
public static void Main(string[] args)
|
||||||
|
{
|
||||||
|
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
16
src/Prowlarr.Benchmark.Test/Prowlarr.Benchmark.Test.csproj
Normal file
16
src/Prowlarr.Benchmark.Test/Prowlarr.Benchmark.Test.csproj
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFrameworks>net6.0</TargetFrameworks>
|
||||||
|
<GenerateProgramFile>false</GenerateProgramFile>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="BenchmarkDotNet" Version="0.13.5" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\NzbDrone.Core\Prowlarr.Core.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
@@ -70,6 +70,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Prowlarr.Api.V1", "Prowlarr
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Prowlarr.Api.V1.Test", "Prowlarr.Api.V1.Test\Prowlarr.Api.V1.Test.csproj", "{4EB5FDB5-5908-4415-8DFD-E5740A480D92}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Prowlarr.Api.V1.Test", "Prowlarr.Api.V1.Test\Prowlarr.Api.V1.Test.csproj", "{4EB5FDB5-5908-4415-8DFD-E5740A480D92}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Prowlarr.Benchmark.Test", "Prowlarr.Benchmark.Test\Prowlarr.Benchmark.Test.csproj", "{56B0D244-4791-40EE-8C01-08C34E3733B7}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Posix = Debug|Posix
|
Debug|Posix = Debug|Posix
|
||||||
@@ -276,6 +278,14 @@ Global
|
|||||||
{4EB5FDB5-5908-4415-8DFD-E5740A480D92}.Release|Posix.Build.0 = Release|Any CPU
|
{4EB5FDB5-5908-4415-8DFD-E5740A480D92}.Release|Posix.Build.0 = Release|Any CPU
|
||||||
{4EB5FDB5-5908-4415-8DFD-E5740A480D92}.Release|Windows.ActiveCfg = Release|Any CPU
|
{4EB5FDB5-5908-4415-8DFD-E5740A480D92}.Release|Windows.ActiveCfg = Release|Any CPU
|
||||||
{4EB5FDB5-5908-4415-8DFD-E5740A480D92}.Release|Windows.Build.0 = Release|Any CPU
|
{4EB5FDB5-5908-4415-8DFD-E5740A480D92}.Release|Windows.Build.0 = Release|Any CPU
|
||||||
|
{56B0D244-4791-40EE-8C01-08C34E3733B7}.Debug|Posix.ActiveCfg = Debug|Any CPU
|
||||||
|
{56B0D244-4791-40EE-8C01-08C34E3733B7}.Debug|Posix.Build.0 = Debug|Any CPU
|
||||||
|
{56B0D244-4791-40EE-8C01-08C34E3733B7}.Debug|Windows.ActiveCfg = Debug|Any CPU
|
||||||
|
{56B0D244-4791-40EE-8C01-08C34E3733B7}.Debug|Windows.Build.0 = Debug|Any CPU
|
||||||
|
{56B0D244-4791-40EE-8C01-08C34E3733B7}.Release|Posix.ActiveCfg = Release|Any CPU
|
||||||
|
{56B0D244-4791-40EE-8C01-08C34E3733B7}.Release|Posix.Build.0 = Release|Any CPU
|
||||||
|
{56B0D244-4791-40EE-8C01-08C34E3733B7}.Release|Windows.ActiveCfg = Release|Any CPU
|
||||||
|
{56B0D244-4791-40EE-8C01-08C34E3733B7}.Release|Windows.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@@ -302,6 +312,7 @@ Global
|
|||||||
{7DA231E8-A31D-4F53-8760-820861B6CE65} = {F9E67978-5CD6-4A5F-827B-4249711C0B02}
|
{7DA231E8-A31D-4F53-8760-820861B6CE65} = {F9E67978-5CD6-4A5F-827B-4249711C0B02}
|
||||||
{0E2B067C-4A97-430C-8767-D19ACB09A63A} = {F9E67978-5CD6-4A5F-827B-4249711C0B02}
|
{0E2B067C-4A97-430C-8767-D19ACB09A63A} = {F9E67978-5CD6-4A5F-827B-4249711C0B02}
|
||||||
{4EB5FDB5-5908-4415-8DFD-E5740A480D92} = {57A04B72-8088-4F75-A582-1158CF8291F7}
|
{4EB5FDB5-5908-4415-8DFD-E5740A480D92} = {57A04B72-8088-4F75-A582-1158CF8291F7}
|
||||||
|
{56B0D244-4791-40EE-8C01-08C34E3733B7} = {57A04B72-8088-4F75-A582-1158CF8291F7}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {0D6944ED-0602-492F-9E11-0513294A4DA3}
|
SolutionGuid = {0D6944ED-0602-492F-9E11-0513294A4DA3}
|
||||||
|
Reference in New Issue
Block a user