Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix benchmarks for older EF Core versions #16419

Merged
merged 1 commit into from
Jul 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,21 @@
</ItemGroup>

<ItemGroup Condition=" '$(Configuration)' == 'Release22' ">
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.4" />
</ItemGroup>

<ItemGroup Condition=" '$(Configuration)' == 'Release21' ">
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.11" />
</ItemGroup>

<ItemGroup Condition=" '$(Configuration)' == 'Release20' ">
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.3" />
</ItemGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Release22' Or '$(Configuration)' == 'Release21' Or '$(Configuration)' == 'Release20' ">
<DefineConstants>$(DefineConstants);OLD_FROM_SQL</DefineConstants>
</PropertyGroup>

<ItemGroup>
<None Update="config.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,21 @@
</ItemGroup>

<ItemGroup Condition=" '$(Configuration)' == 'Release22' ">
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.4" />
</ItemGroup>

<ItemGroup Condition=" '$(Configuration)' == 'Release21' ">
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.11" />
</ItemGroup>

<ItemGroup Condition=" '$(Configuration)' == 'Release20' ">
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.0.3" />
</ItemGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Release22' Or '$(Configuration)' == 'Release21' Or '$(Configuration)' == 'Release20' ">
<DefineConstants>$(DefineConstants);OLD_FROM_SQL</DefineConstants>
</PropertyGroup>

<ItemGroup>
<None Update="AdventureWorks2014.db">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
Expand Down
32 changes: 28 additions & 4 deletions benchmark/Shared.EFCore/Query/RawSqlQueryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ public virtual void CreateContext()
{
if (!string.IsNullOrEmpty(StoredProcedureCreationScript))
{
#if OLD_FROM_SQL
ctx.Database.ExecuteSqlCommand(StoredProcedureCreationScript);
#else
ctx.Database.ExecuteSqlRaw(StoredProcedureCreationScript);
#endif
}
});

Expand All @@ -58,8 +62,13 @@ public virtual void CleanupContext()
[Benchmark]
public virtual async Task SelectAll()
{
var sql = @"SELECT * FROM ""Products""";
var query = _context.Products
.FromSqlRaw(@"SELECT * FROM ""Products""")
#if OLD_FROM_SQL
.FromSql(sql)
#else
.FromSqlRaw(sql)
#endif
.ApplyTracking(Tracking);

if (Async)
Expand All @@ -75,8 +84,13 @@ public virtual async Task SelectAll()
[Benchmark]
public virtual async Task SelectParameterized()
{
var sql = @"SELECT * FROM ""Products"" WHERE ""CurrentPrice"" >= @p0 AND ""CurrentPrice"" <= @p1";
var query = _context.Products
.FromSqlRaw(@"SELECT * FROM ""Products"" WHERE ""CurrentPrice"" >= @p0 AND ""CurrentPrice"" <= @p1", 10, 14)
#if OLD_FROM_SQL
.FromSql(sql, 10, 14)
#else
.FromSqlRaw(sql, 10, 14)
#endif
.ApplyTracking(Tracking);

if (Async)
Expand All @@ -92,8 +106,13 @@ public virtual async Task SelectParameterized()
[Benchmark]
public virtual async Task SelectComposed()
{
var sql = @"SELECT * FROM ""Products""";
var query = _context.Products
.FromSqlRaw(@"SELECT * FROM ""Products""")
#if OLD_FROM_SQL
.FromSql(sql)
#else
.FromSqlRaw(sql)
#endif
.ApplyTracking(Tracking)
.Where(p => p.ActualStockLevel >= 2 && p.ActualStockLevel <= 6)
.OrderBy(p => p.Name);
Expand All @@ -111,8 +130,13 @@ public virtual async Task SelectComposed()
[Benchmark]
public virtual async Task StoredProcedure()
{
var sql = @"EXECUTE dbo.SearchProducts @p0, @p1";
var query = _context.Products
.FromSqlRaw(@"EXECUTE dbo.SearchProducts @p0, @p1", 10, 14)
#if OLD_FROM_SQL
.FromSql(sql, 10, 14)
#else
.FromSqlRaw(sql, 10, 14)
#endif
.ApplyTracking(Tracking);

if (Async)
Expand Down