Skip to content

Commit c9c1fb8

Browse files
fix: adjust read benchmarks params
1 parent 9946029 commit c9c1fb8

4 files changed

Lines changed: 17 additions & 10 deletions

File tree

benchmark/BenchmarkRunner/Benchmarks/MysqlReadBenchmark.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ public class MysqlReadBenchmark
1717
private readonly string _connectionString = Config.GetMysqlConnectionString();
1818
private QuerySql _sqlcImpl = null!;
1919
private const int CustomerCount = 500;
20-
private const int QueriesToRun = 10000;
20+
private const int QueriesToRun = 1000;
2121

22-
[Params(5000, 10000, 20000)]
22+
[Params(50, 500, 5000)]
2323
public int Limit { get; set; }
2424

25-
[Params(10, 100)]
25+
[Params(10, 50)]
2626
public int ConcurrentQueries { get; set; }
2727

2828
[GlobalSetup]

benchmark/BenchmarkRunner/Benchmarks/PostgresqlReadBenchmark.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ public class PostgresqlReadBenchmark
1717
private readonly string _connectionString = Config.GetPostgresConnectionString();
1818
private QuerySql _sqlcImpl = null!;
1919
private const int CustomerCount = 500;
20-
private const int QueriesToRun = 10000;
20+
private const int QueriesToRun = 1000;
2121

22-
[Params(5000, 10000, 20000)]
22+
[Params(50, 500, 5000)]
2323
public int Limit { get; set; }
2424

25-
[Params(10, 100)]
25+
[Params(10, 50)]
2626
public int ConcurrentQueries { get; set; }
2727

2828
[GlobalSetup]

benchmark/BenchmarkRunner/Benchmarks/SqliteReadBenchmark.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ public class SqliteReadBenchmark
1616
{
1717
private readonly string _connectionString = Config.GetSqliteConnectionString();
1818
private QuerySql _sqlcImpl = null!;
19-
private const int CustomerCount = 500;
20-
private const int QueriesToRun = 1000;
19+
private const int CustomerCount = 250;
20+
private const int QueriesToRun = 500;
2121

22-
[Params(5000, 10000, 20000)]
22+
[Params(50, 500, 5000)]
2323
public int Limit { get; set; }
2424

25-
[Params(5, 50)]
25+
[Params(5, 25)]
2626
public int ConcurrentQueries { get; set; }
2727

2828
[GlobalSetup]

benchmark/BenchmarkRunner/Utils/Helpers.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,18 @@ public static async Task InsertInBatchesAsync<T>(List<T> items, int batchSize, F
2020
}
2121
}
2222

23+
private static int CalculateMaxConcurrency(int totalTasks, int maxConcurrency)
24+
{
25+
return new int[] {
26+
maxConcurrency, totalTasks, Environment.ProcessorCount
27+
}.Min(x => x);
28+
}
2329
public static async Task<List<T>> ExecuteConcurrentlyAsync<T>(
2430
int totalTasks,
2531
int maxConcurrency,
2632
Func<int, Task<List<T>>> taskFactory)
2733
{
34+
maxConcurrency = CalculateMaxConcurrency(totalTasks, maxConcurrency);
2835
var semaphore = new SemaphoreSlim(maxConcurrency, maxConcurrency);
2936
var tasks = new List<Task<List<T>>>();
3037
for (int i = 0; i < totalTasks; i++)

0 commit comments

Comments
 (0)