Skip to content

Commit 53b0df7

Browse files
fix: adjust benchmarks parameters
1 parent 5fd924a commit 53b0df7

File tree

9 files changed

+41
-50
lines changed

9 files changed

+41
-50
lines changed

benchmark/BenchmarkRunner/Benchmarks/MysqlReadBenchmark.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ public class MysqlReadBenchmark
1616
{
1717
private readonly string _connectionString = Config.GetMysqlConnectionString();
1818
private QuerySql _sqlcImpl = null!;
19-
private const int CustomerCount = 500;
20-
private const int QueriesToRun = 500;
19+
20+
[Params(500)]
21+
public int CustomerCount { get; set; }
22+
23+
[Params(1000)]
24+
public int QueriesToRun { get; set; }
2125

2226
[Params(100, 1000)]
2327
public int Limit { get; set; }

benchmark/BenchmarkRunner/Benchmarks/MysqlWriteBenchmark.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,21 @@
88

99
namespace BenchmarkRunner.Benchmarks;
1010

11-
[SimpleJob(RuntimeMoniker.Net80, warmupCount: 2, iterationCount: 15)]
11+
[SimpleJob(RuntimeMoniker.Net80, warmupCount: 2, iterationCount: 10)]
1212
[MemoryDiagnoser]
1313
[MarkdownExporterAttribute.GitHub]
1414
[GroupBenchmarksBy(BenchmarkLogicalGroupRule.ByCategory)]
1515
[CategoriesColumn]
1616
public class MysqlWriteBenchmark
1717
{
18-
private const int TotalRecords = 3000000; // 3 million records
1918
private readonly string _connectionString = Config.GetMysqlConnectionString();
2019
private QuerySql _sqlcImpl = null!;
2120
private Queries _efCoreImpl = null!;
2221
private List<QuerySql.AddOrderItemsArgs> _testOrderItems = null!;
2322

23+
[Params(2000000)]
24+
public int TotalRecords { get; set; }
25+
2426
[Params(100, 500, 1000)]
2527
public int BatchSize { get; set; }
2628

benchmark/BenchmarkRunner/Benchmarks/PostgresqlReadBenchmark.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ public class PostgresqlReadBenchmark
1616
{
1717
private readonly string _connectionString = Config.GetPostgresConnectionString();
1818
private QuerySql _sqlcImpl = null!;
19-
private const int CustomerCount = 500;
20-
private const int QueriesToRun = 500;
19+
20+
[Params(500)]
21+
public int CustomerCount { get; set; }
22+
23+
[Params(500)]
24+
public int QueriesToRun { get; set; }
2125

2226
[Params(100, 1000)]
2327
public int Limit { get; set; }

benchmark/BenchmarkRunner/Benchmarks/PostgresqlWriteBenchmark.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,21 @@
77

88
namespace BenchmarkRunner.Benchmarks;
99

10-
[SimpleJob(RuntimeMoniker.Net80, warmupCount: 2, iterationCount: 15)]
10+
[SimpleJob(RuntimeMoniker.Net80, warmupCount: 2, iterationCount: 10)]
1111
[MemoryDiagnoser]
1212
[MarkdownExporterAttribute.GitHub]
1313
[GroupBenchmarksBy(BenchmarkLogicalGroupRule.ByCategory)]
1414
[CategoriesColumn]
1515
public class PostgresqlWriteBenchmark
1616
{
17-
private const int TotalRecords = 3000000; // 3 million records
1817
private readonly string _connectionString = Config.GetPostgresConnectionString();
1918
private QuerySql _sqlcImpl = null!;
2019
private Queries _efCoreImpl = null!;
2120
private List<QuerySql.AddOrderItemsArgs> _testOrderItems = null!;
2221

22+
[Params(2000000)]
23+
public int TotalRecords { get; set; }
24+
2325
[Params(100, 500, 1000)]
2426
public int BatchSize { get; set; }
2527

benchmark/BenchmarkRunner/Benchmarks/SqliteReadBenchmark.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ public class SqliteReadBenchmark
1616
{
1717
private readonly string _connectionString = Config.GetSqliteConnectionString();
1818
private QuerySql _sqlcImpl = null!;
19-
private const int CustomerCount = 250;
20-
private const int QueriesToRun = 500;
19+
20+
[Params(500)]
21+
public int CustomerCount { get; set; }
22+
23+
[Params(500)]
24+
public int QueriesToRun { get; set; }
2125

2226
[Params(50, 500)]
2327
public int Limit { get; set; }

benchmark/BenchmarkRunner/Benchmarks/SqliteWriteBenchmark.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,19 @@
77

88
namespace BenchmarkRunner.Benchmarks;
99

10-
[SimpleJob(RuntimeMoniker.Net80, warmupCount: 2, iterationCount: 15)]
10+
[SimpleJob(RuntimeMoniker.Net80, warmupCount: 2, iterationCount: 10)]
1111
[MemoryDiagnoser]
1212
[MarkdownExporterAttribute.GitHub]
1313
[GroupBenchmarksBy(BenchmarkLogicalGroupRule.ByCategory)]
1414
[CategoriesColumn]
1515
public class SqliteWriteBenchmark
1616
{
17-
private const int TotalRecords = 2000000; // 2 million records
1817
private readonly string _connectionString = Config.GetSqliteConnectionString();
1918
private QuerySql _sqlcImpl = null!;
2019
private Queries _efCoreImpl = null!;
20+
21+
[Params(2000000)]
22+
public int TotalRecords { get; set; }
2123
private List<QuerySql.AddOrderItemsArgs> _testOrderItems = null!;
2224

2325
[Params(50, 100, 200)]

benchmark/BenchmarkRunner/Program.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@ public class Program
2222
private static readonly Dictionary<string, Dictionary<string, Func<Task>>> _benchmarkConfigs = new()
2323
{
2424
{ "mysql", new()
25-
{
26-
{ "reads", _mysqlRunner.RunReadsAsync },
27-
{ "writes", _mysqlRunner.RunWritesAsync }
25+
{
26+
{ "reads", _mysqlRunner.RunReadsAsync },
27+
{ "writes", _mysqlRunner.RunWritesAsync }
2828
}},
2929
{ "postgresql", new()
30-
{
31-
{ "reads", _postgresqlRunner.RunReadsAsync },
32-
{ "writes", _postgresqlRunner.RunWritesAsync }
30+
{
31+
{ "reads", _postgresqlRunner.RunReadsAsync },
32+
{ "writes", _postgresqlRunner.RunWritesAsync }
3333
}},
3434
{ "sqlite", new()
35-
{
36-
{ "reads", _sqliteRunner.RunReadsAsync },
37-
{ "writes", _sqliteRunner.RunWritesAsync }
35+
{
36+
{ "reads", _sqliteRunner.RunReadsAsync },
37+
{ "writes", _sqliteRunner.RunWritesAsync }
3838
}}
3939
};
4040

@@ -49,7 +49,7 @@ public static async Task Main(string[] args)
4949
rootCommand.AddOption(typeOption);
5050

5151
rootCommand.SetHandler(
52-
async (database, type) => await _benchmarkConfigs[database][type](),
52+
async (database, type) => await _benchmarkConfigs[database][type](),
5353
databaseOption, typeOption);
5454
await rootCommand.InvokeAsync(args);
5555
}

benchmark/BenchmarkRunner/TestSqlCapture.cs

Lines changed: 0 additions & 27 deletions
This file was deleted.

benchmark/BenchmarkRunner/Utils/PostgresqlDatabaseHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public static async Task CleanupWriteTableAsync(string connectionString)
88
{
99
using var connection = new NpgsqlConnection(connectionString);
1010
await connection.OpenAsync();
11-
using var cmd = new NpgsqlCommand("TRUNCATE TABLE sales.order_items CASCADE", connection);
11+
using var cmd = new NpgsqlCommand("TRUNCATE TABLE sales.order_items", connection);
1212
await cmd.ExecuteNonQueryAsync();
1313
}
1414
public static async Task CleanupDatabaseAsync(string connectionString)

0 commit comments

Comments
 (0)