Files
Dapper/benchmarks/Dapper.Tests.Performance/Benchmarks.EntityFramework.cs
Nick Craver 78ed4b2077 Tests: move into folders
One of several moves to make this something we can dev on all platforms and build on Actions for v3 onwards.
2020-10-11 14:56:35 -04:00

41 lines
1.0 KiB
C#

using BenchmarkDotNet.Attributes;
using System.ComponentModel;
using System.Linq;
namespace Dapper.Tests.Performance
{
[Description("EF 6")]
public class EF6Benchmarks : BenchmarkBase
{
private EntityFramework.EFContext Context;
[GlobalSetup]
public void Setup()
{
BaseSetup();
Context = new EntityFramework.EFContext(_connection);
}
[Benchmark(Description = "First")]
public Post First()
{
Step();
return Context.Posts.First(p => p.Id == i);
}
[Benchmark(Description = "SqlQuery")]
public Post SqlQuery()
{
Step();
return Context.Database.SqlQuery<Post>("select * from Posts where Id = {0}", i).First();
}
[Benchmark(Description = "First (No Tracking)")]
public Post NoTracking()
{
Step();
return Context.Posts.AsNoTracking().First(p => p.Id == i);
}
}
}