mirror of
https://github.com/DapperLib/Dapper.git
synced 2026-10-17 05:12:13 +08:00
Add Norm benchmarks tests
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
#if NET4X
|
||||
#else
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using Norm;
|
||||
using System;
|
||||
|
||||
namespace Dapper.Tests.Performance
|
||||
{
|
||||
[Description("Norm")]
|
||||
public class NormBenchmarks : BenchmarkBase
|
||||
{
|
||||
[GlobalSetup]
|
||||
public void Setup()
|
||||
{
|
||||
BaseSetup();
|
||||
}
|
||||
|
||||
[Benchmark(Description = "Read<T> (class)")]
|
||||
public Post Read()
|
||||
{
|
||||
Step();
|
||||
return _connection.Read<Post>("select * from Posts where Id = @Id", i).First();
|
||||
}
|
||||
|
||||
[Benchmark(Description = "Read<T1, T2, ...> (simple values in a tuple)")]
|
||||
public (int, string, DateTime, DateTime, int?, int?, int?, int?, int?, int?, int?, int?) ReadSimpleValues()
|
||||
{
|
||||
Step();
|
||||
return _connection.Read<int, string, DateTime, DateTime, int?, int?, int?, int?, int?, int?, int?, int?>("select * from Posts where Id = @Id", i).First();
|
||||
}
|
||||
|
||||
[Benchmark(Description = "Read<(T1, T2, ...)> (named tuple)")]
|
||||
public (int Id, string Text, DateTime CreationDate, DateTime LastChangeDate, int? Counter1, int? Counter2, int? Counter3, int? Counter4, int? Counter5, int? Counter6, int? Counter7, int? Counter8) ReadTuple()
|
||||
{
|
||||
Step();
|
||||
return _connection.Read<(int Id, string Text, DateTime CreationDate, DateTime LastChangeDate, int? Counter1, int? Counter2, int? Counter3, int? Counter4, int? Counter5, int? Counter6, int? Counter7, int? Counter8)>("select * from Posts where Id = @Id", i).First();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -48,4 +48,9 @@
|
||||
<ItemGroup Condition="'$(TargetFramework)' != 'net462'">
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
|
||||
<PackageReference Include="Norm.net">
|
||||
<Version>3.1.0</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user