-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Expand file tree
/
Copy pathBenchmarks.cs
More file actions
37 lines (33 loc) · 1.09 KB
/
Benchmarks.cs
File metadata and controls
37 lines (33 loc) · 1.09 KB
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
using BenchmarkDotNet.Attributes;
using System;
using System.Configuration;
using Microsoft.Data.SqlClient;
namespace Dapper.Tests.Performance
{
[BenchmarkCategory("ORM")]
public abstract class BenchmarkBase
{
protected static readonly Random _rand = new Random();
protected SqlConnection _connection;
public static ConnectionStringSettings ConnectionStringSettings { get; } = ConfigurationManager.ConnectionStrings["Main"];
public static string ConnectionString { get; } = ConnectionStringSettings.ConnectionString;
protected int i;
protected void BaseSetup()
{
i = 0;
_connection = new SqlConnection(ConnectionString);
_connection.Open();
}
protected void RegisterSqlFactory()
{
#if NETCOREAPP
System.Data.Common.DbProviderFactories.RegisterFactory("System.Data.SqlClient", SqlClientFactory.Instance);
#endif
}
protected void Step()
{
i++;
if (i > 5000) i = 1;
}
}
}