mirror of
https://github.com/DapperLib/Dapper.git
synced 2026-10-18 22:31:08 +08:00
78ed4b2077
One of several moves to make this something we can dev on all platforms and build on Actions for v3 onwards.
38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
using BenchmarkDotNet.Attributes;
|
|
using System;
|
|
using System.Configuration;
|
|
using System.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;
|
|
}
|
|
}
|
|
}
|