forked from DapperLib/Dapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Benchmarks.cs
58 lines (54 loc) · 1.69 KB
/
Benchmarks.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Attributes.Columns;
using BenchmarkDotNet.Columns;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Diagnosers;
using BenchmarkDotNet.Horology;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Order;
using Dapper.Tests.Performance.Helpers;
using System;
using System.Configuration;
using System.Data.SqlClient;
namespace Dapper.Tests.Performance
{
[OrderProvider(SummaryOrderPolicy.FastestToSlowest)]
[RankColumn]
[Config(typeof(Config))]
public abstract class BenchmarkBase
{
public const int Iterations = 50;
protected static readonly Random _rand = new Random();
protected SqlConnection _connection;
public static string ConnectionString { get; } = ConfigurationManager.ConnectionStrings["Main"].ConnectionString;
protected int i;
protected void BaseSetup()
{
i = 0;
_connection = new SqlConnection(ConnectionString);
_connection.Open();
}
protected void Step()
{
i++;
if (i > 5000) i = 1;
}
}
public class Config : ManualConfig
{
public Config()
{
Add(new MemoryDiagnoser());
Add(new ORMColum());
Add(new ReturnColum());
Add(Job.Default
.WithUnrollFactor(BenchmarkBase.Iterations)
//.WithIterationTime(new TimeInterval(500, TimeUnit.Millisecond))
.WithLaunchCount(1)
.WithWarmupCount(0)
.WithTargetCount(5)
.WithRemoveOutliers(true)
);
}
}
}