Created
May 8, 2024 03:46
-
-
Save sa-es-ir/bfd1e7a2e245835334c6824a727121c4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using BenchmarkDotNet.Attributes; | |
using BenchmarkDotNet.Columns; | |
using BenchmarkDotNet.Configs; | |
using BenchmarkDotNet.Reports; | |
using DatabaseNight.Context; | |
using System.Linq; | |
namespace DatabaseNight; | |
[Config(typeof(Config))] | |
[HideColumns(Column.RatioSD, Column.AllocRatio)] | |
[MemoryDiagnoser(false)] | |
public class EFTuningService | |
{ | |
private class Config : ManualConfig | |
{ | |
public Config() | |
{ | |
SummaryStyle = SummaryStyle.Default.WithRatioStyle(RatioStyle.Trend); | |
} | |
} | |
[Benchmark(Baseline = true)] | |
public bool Count() | |
{ | |
var context = new ApplicationContext(); | |
return context.Employees | |
.Count(x => x.DepartmentId == 7) > 0; | |
} | |
[Benchmark] | |
public bool Any() | |
{ | |
var context = new ApplicationContext(); | |
return context.Employees | |
.Any(x => x.DepartmentId == 7); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment