forked from DapperLib/Dapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Benchmarks.PetaPoco.cs
38 lines (34 loc) · 1.11 KB
/
Benchmarks.PetaPoco.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using BenchmarkDotNet.Attributes;
using PetaPoco;
using System.Linq;
namespace Dapper.Tests.Performance
{
public class PetaPocoBenchmarks : BenchmarkBase
{
private Database _db, _dbFast;
[Setup]
public void Setup()
{
BaseSetup();
_db = new Database(ConnectionString, "System.Data.SqlClient");
_db.OpenSharedConnection();
_dbFast = new Database(ConnectionString, "System.Data.SqlClient");
_dbFast.OpenSharedConnection();
_dbFast.EnableAutoSelect = false;
_dbFast.EnableNamedParams = false;
_dbFast.ForceDateTimesToUtc = false;
}
[Benchmark(Description = "Fetch<Post>")]
public Post Fetch()
{
Step();
return _db.Fetch<Post>("SELECT * from Posts where Id=@0", i).First();
}
[Benchmark(Description = "Fetch<Post> (Fast)")]
public Post FetchFast()
{
Step();
return _dbFast.Fetch<Post>("SELECT * from Posts where Id=@0", i).First();
}
}
}