parent
d397cdf5fb
commit
0f11f414b6
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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>
|
Loading…
Reference in new issue