Skip to content

Commit e9bdcb2

Browse files
authored
Merge pull request #1602 from vbilopav/main
2 parents b452fb1 + 60d5a05 commit e9bdcb2

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#if !NET4X
2+
using BenchmarkDotNet.Attributes;
3+
using System.ComponentModel;
4+
using System.Linq;
5+
using Norm;
6+
using System;
7+
8+
namespace Dapper.Tests.Performance
9+
{
10+
[Description("Norm")]
11+
public class NormBenchmarks : BenchmarkBase
12+
{
13+
[GlobalSetup]
14+
public void Setup()
15+
{
16+
BaseSetup();
17+
}
18+
19+
[Benchmark(Description = "Read<> (class)")]
20+
public Post Read()
21+
{
22+
Step();
23+
return _connection.Read<Post>("select * from Posts where Id = @Id", i).First();
24+
}
25+
26+
[Benchmark(Description = "Read<> (tuples)")]
27+
public (int, string, DateTime, DateTime, int?, int?, int?, int?, int?, int?, int?, int?) ReadSimpleValues()
28+
{
29+
Step();
30+
return _connection.Read<int, string, DateTime, DateTime, int?, int?, int?, int?, int?, int?, int?, int?>("select * from Posts where Id = @Id", i).First();
31+
}
32+
33+
[Benchmark(Description = "Read<()> (named tuples)")]
34+
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()
35+
{
36+
Step();
37+
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();
38+
}
39+
}
40+
}
41+
#endif

benchmarks/Dapper.Tests.Performance/Dapper.Tests.Performance.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,6 @@
4848
</ItemGroup>
4949
<ItemGroup Condition="'$(TargetFramework)' != 'net462'">
5050
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.0" />
51+
<PackageReference Include="Norm.net" Version="3.2.0" />
5152
</ItemGroup>
5253
</Project>

0 commit comments

Comments
 (0)