Skip to content

Commit

Permalink
Added Dashing Benchmarks (#1126)
Browse files Browse the repository at this point in the history
Adds Dashing benchmarks to Dapper.Tests.Performance
  • Loading branch information
markjerz authored and NickCraver committed Sep 11, 2018
1 parent 5256f2e commit b262cb3
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 1 deletion.
27 changes: 27 additions & 0 deletions Dapper.Tests.Performance/Benchmarks.Dashing.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
9 changes: 8 additions & 1 deletion Dapper.Tests.Performance/Dapper.Tests.Performance.csproj
Original file line number Diff line number Diff line change
@@ -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>
Expand All @@ -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" />-->
Expand Down Expand Up @@ -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>
12 changes: 12 additions & 0 deletions Dapper.Tests.Performance/Dashing/DashingConfiguration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Dashing.Configuration;

namespace Dapper.Tests.Performance.Dashing
{
public class DashingConfiguration : BaseConfiguration
{
public DashingConfiguration()
{
this.Add<Post>();
}
}
}
21 changes: 21 additions & 0 deletions Dapper.Tests.Performance/Dashing/Post.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
}
11 changes: 11 additions & 0 deletions Dapper.Tests.Performance/LegacyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
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;

Expand Down Expand Up @@ -186,6 +188,15 @@ public async Task RunAsync(int iterations)
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(() =>
{
Expand Down

0 comments on commit b262cb3

Please sign in to comment.