Commit ee0b246f authored by Nick Craver's avatar Nick Craver

Perf: add EntityFramework Core to legacy tests

parent 3c14c8b6
using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Attributes;
using Dapper.Tests.Performance.Linq2Sql;
using System;
using System.Data.Linq;
using System.Linq; using System.Linq;
namespace Dapper.Tests.Performance namespace Dapper.Tests.Performance
...@@ -9,8 +6,6 @@ namespace Dapper.Tests.Performance ...@@ -9,8 +6,6 @@ namespace Dapper.Tests.Performance
public class EF6Benchmarks : BenchmarkBase public class EF6Benchmarks : BenchmarkBase
{ {
private EntityFramework.EFContext Context; private EntityFramework.EFContext Context;
private static readonly Func<DataClassesDataContext, int, Linq2Sql.Post> compiledQuery =
CompiledQuery.Compile((DataClassesDataContext ctx, int id) => ctx.Posts.First(p => p.Id == id));
[Setup] [Setup]
public void Setup() public void Setup()
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
using Susanoo; using Susanoo;
using System.Configuration; using System.Configuration;
using System.Threading.Tasks; using System.Threading.Tasks;
using Dapper.Tests.Performance.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
namespace Dapper.Tests.Performance namespace Dapper.Tests.Performance
{ {
...@@ -143,16 +145,23 @@ public async Task RunAsync(int iterations) ...@@ -143,16 +145,23 @@ public async Task RunAsync(int iterations)
var entityContext2 = new EFContext(connection); var entityContext2 = new EFContext(connection);
tests.Add(id => entityContext2.Database.SqlQuery<Post>("select * from Posts where Id = {0}", id).First(), "Entity Framework: SqlQuery"); tests.Add(id => entityContext2.Database.SqlQuery<Post>("select * from Posts where Id = {0}", id).First(), "Entity Framework: SqlQuery");
var entityContext3 = new EFContext(connection);
tests.Add(id => entityContext3.Posts.AsNoTracking().First(p => p.Id == id), "Entity Framework: No Tracking");
}, "Entity Framework");
//var entityContext3 = new EFContext(connection); // Entity Framework Core
//tests.Add(id => entityFrameworkCompiled(entityContext3, id), "Entity Framework CompiledQuery"); Try(() =>
{
var entityContext = new EFCoreContext(ConnectionString);
tests.Add(id => entityContext.Posts.First(p => p.Id == id), "Entity Framework Core");
//var entityContext4 = new EFContext(connection); var entityContext2 = new EFCoreContext(ConnectionString);
//tests.Add(id => entityContext4.Posts.Where("it.Id = @id", new System.Data.Objects.ObjectParameter("id", id)).First(), "Entity Framework ESQL"); tests.Add(id => entityContext2.Posts.FromSql("select * from Posts where Id = {0}", id).First(), "Entity Framework Core: FromSql");
var entityContext5 = new EFContext(connection); var entityContext3 = new EFContext(connection);
tests.Add(id => entityContext5.Posts.AsNoTracking().First(p => p.Id == id), "Entity Framework: No Tracking"); tests.Add(id => entityContext3.Posts.AsNoTracking().First(p => p.Id == id), "Entity Framework Core: No Tracking");
}, "Entity Framework"); }, "Entity Framework Core");
// Dapper // Dapper
Try(() => Try(() =>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment