mirror of
https://github.com/DapperLib/Dapper.git
synced 2026-10-17 05:12:13 +08:00
Added Dashing Benchmarks (#1126)
Adds Dashing benchmarks to Dapper.Tests.Performance
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using Dapper.Tests.Performance.Dashing;
|
||||
using Dashing;
|
||||
|
||||
namespace Dapper.Tests.Performance
|
||||
{
|
||||
public class DashingBenchmarks : BenchmarkBase
|
||||
{
|
||||
private ISession session;
|
||||
|
||||
[GlobalSetup]
|
||||
public void Setup()
|
||||
{
|
||||
BaseSetup();
|
||||
var configuration = new DashingConfiguration();
|
||||
var database = new SqlDatabase(configuration, ConnectionString);
|
||||
this.session = database.BeginTransactionLessSession(_connection);
|
||||
}
|
||||
|
||||
[Benchmark(Description = "Get By Id")]
|
||||
public Dashing.Post QueryBuffered()
|
||||
{
|
||||
Step();
|
||||
return session.Get<Dashing.Post>(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project>
|
||||
<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.props" />
|
||||
<PropertyGroup>
|
||||
<AssemblyName>Dapper.Tests.Performance</AssemblyName>
|
||||
<Title>Dapper.Tests.Performance</Title>
|
||||
@@ -11,6 +12,8 @@
|
||||
<ProjectReference Include="..\Dapper\Dapper.csproj" />
|
||||
<ProjectReference Include="..\Dapper.Contrib\Dapper.Contrib.csproj" />
|
||||
<ProjectReference Include="..\Dapper.EntityFramework\Dapper.EntityFramework.csproj" />
|
||||
<PackageReference Include="Dashing" Version="2.0.7" />
|
||||
<PackageReference Include="Dashing.Weaver" Version="2.0.7" />
|
||||
<PackageReference Include="Belgrade.Sql.Client" Version="1.1.4" />
|
||||
<PackageReference Include="BenchmarkDotNet" Version="0.11.1" />
|
||||
<!--<PackageReference Include="BLToolkit" Version="4.3.6" />-->
|
||||
@@ -45,4 +48,8 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Update="SourceLink.Create.GitHub" Version="2.8.3" />
|
||||
</ItemGroup>
|
||||
<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.targets" />
|
||||
<PropertyGroup>
|
||||
<WeaveArguments>-p "$(MSBuildThisFileDirectory)$(OutputPath)$(AssemblyName).exe" -t "Dapper.Tests.Performance.Dashing.DashingConfiguration"</WeaveArguments>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
using Dashing.Configuration;
|
||||
|
||||
namespace Dapper.Tests.Performance.Dashing
|
||||
{
|
||||
public class DashingConfiguration : BaseConfiguration
|
||||
{
|
||||
public DashingConfiguration()
|
||||
{
|
||||
this.Add<Post>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
|
||||
namespace Dapper.Tests.Performance.Dashing
|
||||
{
|
||||
public class Post
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Text { get; set; }
|
||||
public DateTime CreationDate { get; set; }
|
||||
public DateTime LastChangeDate { get; set; }
|
||||
public int? Counter1 { get; set; }
|
||||
public int? Counter2 { get; set; }
|
||||
public int? Counter3 { get; set; }
|
||||
public int? Counter4 { get; set; }
|
||||
public int? Counter5 { get; set; }
|
||||
public int? Counter6 { get; set; }
|
||||
public int? Counter7 { get; set; }
|
||||
public int? Counter8 { get; set; }
|
||||
public int? Counter9 { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,9 @@ using ServiceStack.OrmLite.Dapper;
|
||||
using Susanoo;
|
||||
using System.Configuration;
|
||||
using System.Threading.Tasks;
|
||||
using Dapper.Tests.Performance.Dashing;
|
||||
using Dapper.Tests.Performance.EntityFrameworkCore;
|
||||
using Dashing;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Belgrade.SqlClient;
|
||||
|
||||
@@ -186,6 +188,15 @@ namespace Dapper.Tests.Performance
|
||||
tests.Add(id => mapperConnection3.Get<Post>(id), "Dapper.Contrib");
|
||||
}, "Dapper");
|
||||
|
||||
// Dashing
|
||||
Try(() =>
|
||||
{
|
||||
var config = new DashingConfiguration();
|
||||
var database = new SqlDatabase(config, ConnectionString);
|
||||
var session = database.BeginTransactionLessSession(GetOpenConnection());
|
||||
tests.Add(id => session.Get<Dashing.Post>(id), "Dashing Get");
|
||||
}, "Dashing");
|
||||
|
||||
// Massive
|
||||
Try(() =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user