-
-
Save dcomartin/3c38566eda1da789c4f1499b706accbf to your computer and use it in GitHub Desktop.
This file contains 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 Microsoft.EntityFrameworkCore; | |
namespace FirstSingle; | |
[SimpleJob] | |
public class BenchmarkDb | |
{ | |
private readonly TestDbContext _db; | |
private readonly int _orderId; | |
public BenchmarkDb() | |
{ | |
_db = new TestDbContext(); | |
var rnd = new Random(); | |
_orderId = rnd.Next(1, 1_000_000); | |
} | |
[Benchmark] | |
public async Task Single() => await _db.Orders.SingleAsync(x => x.OrderId == _orderId); | |
[Benchmark] | |
public async Task First() => await _db.Orders.FirstAsync(x => x.OrderId == _orderId); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment