* Update gitignore * Move csproj * Update project references * Update solutions * Update build scripts * Tests used to share editorconfig with projects in src * Fix broken tests. * Stop copying around .editorconfig merged root one with linting * csharp_style_expression_bodied -> suggestion * Move StyleCop rulesets to matching directories and update shared build properties * Remove legacy build files, update NuGet.cofig and solution files * Restore myget source * Clean up .gitignore * Update .gitignore * Move new test classes to tests after merge * Gitignore + nuget config * Move new test Co-authored-by: Ronald Barendse <ronald@barend.se>
46 lines
1.3 KiB
C#
46 lines
1.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using BenchmarkDotNet.Attributes;
|
|
using Umbraco.Extensions;
|
|
|
|
namespace Umbraco.Tests.Benchmarks
|
|
{
|
|
[MemoryDiagnoser]
|
|
public class TryConvertToBenchmarks
|
|
{
|
|
private static readonly List<string> List = new List<string>() { "hello", "world", "awesome" };
|
|
private static readonly string Date = "Saturday 10, November 2012";
|
|
|
|
[Benchmark(Description = "List<string> to IEnumerable<string>")]
|
|
public IList<string> TryConvertToEnumerable()
|
|
{
|
|
return List.TryConvertTo<IEnumerable<string>>().Result.ToList();
|
|
}
|
|
|
|
[Benchmark(Description = "Int to Double")]
|
|
public double TryConvertToDouble()
|
|
{
|
|
return 1.TryConvertTo<double>().Result;
|
|
}
|
|
|
|
[Benchmark(Description = "Float to Decimal")]
|
|
public decimal TryConvertToDecimal()
|
|
{
|
|
return 1F.TryConvertTo<decimal>().Result;
|
|
}
|
|
|
|
[Benchmark(Description = "String to Boolean")]
|
|
public bool TryConvertToBoolean()
|
|
{
|
|
return "1".TryConvertTo<bool>().Result;
|
|
}
|
|
|
|
[Benchmark(Description = "String to DateTime")]
|
|
public DateTime TryConvertToDateTime()
|
|
{
|
|
return Date.TryConvertTo<DateTime>().Result;
|
|
}
|
|
}
|
|
}
|