22using BenchmarkDotNet . Configs ;
33using BenchmarkDotNet . Jobs ;
44using BenchmarkRunner . Utils ;
5+ using EndToEndTests ;
6+ using Microsoft . Data . Sqlite ;
57using SqliteEFCoreImpl ;
68using SqliteSqlcImpl ;
79
@@ -43,13 +45,20 @@ public override async Task EFCore_NoTracking_GetCustomerOrders()
4345 {
4446 await ExecuteConcurrentlyAsync ( QueriesToRun , ConcurrentQueries , async _ =>
4547 {
46- await using var dbContext = new SalesDbContext ( _connectionString ) ;
47- var queries = new Queries ( dbContext , useTracking : false ) ;
48- return await queries . GetCustomerOrders ( new Queries . GetCustomerOrdersArgs (
49- CustomerId : Random . Shared . Next ( 1 , CustomerCount ) ,
50- Offset : 0 ,
51- Limit : Limit
52- ) ) ;
48+ try
49+ {
50+ await using var dbContext = new SalesDbContext ( _connectionString ) ;
51+ var queries = new Queries ( dbContext , useTracking : false ) ;
52+ return await queries . GetCustomerOrders ( new Queries . GetCustomerOrdersArgs (
53+ CustomerId : Random . Shared . Next ( 1 , CustomerCount ) ,
54+ Offset : 0 ,
55+ Limit : Limit
56+ ) ) ;
57+ }
58+ catch ( SqliteException e )
59+ {
60+ throw new Exception ( $ "Sqlite connection string: { _connectionString } , error: { e . Message } ", e ) ;
61+ }
5362 } ) ;
5463 }
5564
@@ -59,22 +68,28 @@ public override async Task EFCore_WithTracking_GetCustomerOrders()
5968 {
6069 await ExecuteConcurrentlyAsync ( QueriesToRun , ConcurrentQueries , async _ =>
6170 {
62- await using var dbContext = new SalesDbContext ( _connectionString ) ;
63- var queries = new Queries ( dbContext , useTracking : true ) ;
64- return await queries . GetCustomerOrders ( new Queries . GetCustomerOrdersArgs (
65- CustomerId : Random . Shared . Next ( 1 , CustomerCount ) ,
66- Offset : 0 ,
67- Limit : Limit
68- ) ) ;
71+ try
72+ {
73+ await using var dbContext = new SalesDbContext ( _connectionString ) ;
74+ var queries = new Queries ( dbContext , useTracking : true ) ;
75+ return await queries . GetCustomerOrders ( new Queries . GetCustomerOrdersArgs (
76+ CustomerId : Random . Shared . Next ( 1 , CustomerCount ) ,
77+ Offset : 0 ,
78+ Limit : Limit
79+ ) ) ;
80+ }
81+ catch ( SqliteException e )
82+ {
83+ throw new Exception ( $ "Sqlite connection string: { _connectionString } , error: { e . Message } ", e ) ;
84+ }
6985 } ) ;
7086 }
7187
7288 public static Func < Task > GetSeedMethod ( )
7389 {
7490 return async ( ) =>
7591 {
76- SqliteDatabaseHelper . CleanupDatabase ( _connectionString ) ;
77- await SqliteDatabaseHelper . InitializeDatabaseAsync ( _connectionString ) ;
92+ EndToEndCommon . SetupBenchmarkSqliteDb ( ) ;
7893 var seeder = new SqliteDatabaseSeeder ( _connectionString ) ;
7994 await seeder . SeedAsync (
8095 customerCount : 500 , // with customer_id filter, this is 1/500 of the table returned
0 commit comments