Skip to content

Commit

Permalink
Added more use cases RepoDB benchmarks (#1710)
Browse files Browse the repository at this point in the history
  • Loading branch information
SergerGood authored Oct 10, 2021
1 parent a4b1c56 commit 80719d0
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
36 changes: 32 additions & 4 deletions benchmarks/Dapper.Tests.Performance/Benchmarks.RepoDB.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using BenchmarkDotNet.Attributes;
using System.ComponentModel;
using System.ComponentModel;
using System.Linq;
using BenchmarkDotNet.Attributes;
using RepoDb;

namespace Dapper.Tests.Performance
Expand All @@ -16,11 +16,39 @@ public void Setup()
ClassMapper.Add<Post>("Posts");
}

[Benchmark(Description = "Query")]
[Benchmark(Description = "Query<T>")]
public Post Query()
{
Step();
return _connection.Query<Post>(i).FirstOrDefault();
return _connection.Query<Post>(i).First();
}

[Benchmark(Description = "QueryWhere<T>")]
public Post QueryWhere()
{
Step();
return _connection.Query<Post>(x => x.Id == i).First();
}

[Benchmark(Description = "QueryDynamic<T>")]
public Post QueryDynamic()
{
Step();
return _connection.Query<Post>(new { Id = i }).First();
}

[Benchmark(Description = "QueryField<T>")]
public Post QueryField()
{
Step();
return _connection.Query<Post>(new QueryField[] { new(nameof(Post.Id), i) }).First();
}

[Benchmark(Description = "ExecuteQuery<T>")]
public Post ExecuteQuery()
{
Step();
return _connection.ExecuteQuery<Post>("select * from Posts where Id = @Id", new { Id = i }).First();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
<PackageReference Include="Mighty" Version="3.1.3" />
<PackageReference Include="Npgsql" Version="5.0.0" />
<PackageReference Include="PetaPoco" Version="5.1.306" />
<PackageReference Include="RepoDb.SqlServer" Version="1.1.3" />
<PackageReference Include="RepoDb.SqlServer" Version="1.1.4" />
<PackageReference Include="ServiceStack.OrmLite.SqlServer" Version="5.10.2" />
<PackageReference Include="SqlMarshal" Version="0.2.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.2" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.3" />
<PackageReference Include="System.Data.SQLite" Version="1.0.113.6" />
</ItemGroup>
<ItemGroup>
Expand Down

0 comments on commit 80719d0

Please sign in to comment.