|
| 1 | +# Benchmarks |
| 2 | + |
| 3 | +The benchmark project (`FirebirdSql.Data.FirebirdClient.Benchmarks`) measures performance of the Firebird .NET provider using [BenchmarkDotNet](https://benchmarkdotnet.org/). |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +- A running Firebird server accessible at `localhost` (default configuration) |
| 8 | +- .NET 10 SDK |
| 9 | + |
| 10 | +## Running Benchmarks |
| 11 | + |
| 12 | +Use the convenience script from the repository root: |
| 13 | + |
| 14 | +```powershell |
| 15 | +.\run-benchmark.ps1 |
| 16 | +``` |
| 17 | + |
| 18 | +By default this runs `CommandBenchmark`. To select a different benchmark class: |
| 19 | + |
| 20 | +```powershell |
| 21 | +.\run-benchmark.ps1 -Benchmark ConnectionBenchmark |
| 22 | +.\run-benchmark.ps1 -Benchmark LargeFetchBenchmark |
| 23 | +``` |
| 24 | + |
| 25 | +### Advanced Options |
| 26 | + |
| 27 | +Enable JIT disassembly output: |
| 28 | + |
| 29 | +```powershell |
| 30 | +.\run-benchmark.ps1 -Disasm |
| 31 | +``` |
| 32 | + |
| 33 | +Enable ETW profiling (Windows only): |
| 34 | + |
| 35 | +```powershell |
| 36 | +.\run-benchmark.ps1 -Profile |
| 37 | +``` |
| 38 | + |
| 39 | +Options can be combined: |
| 40 | + |
| 41 | +```powershell |
| 42 | +.\run-benchmark.ps1 -Benchmark LargeFetchBenchmark -Disasm |
| 43 | +``` |
| 44 | + |
| 45 | +### Running Directly with BenchmarkDotNet |
| 46 | + |
| 47 | +For full control over BenchmarkDotNet options, pass arguments directly after `--`: |
| 48 | + |
| 49 | +```powershell |
| 50 | +dotnet run --project src\FirebirdSql.Data.FirebirdClient.Benchmarks\FirebirdSql.Data.FirebirdClient.Benchmarks.csproj --configuration Release -- --list flat |
| 51 | +dotnet run --project src\FirebirdSql.Data.FirebirdClient.Benchmarks\FirebirdSql.Data.FirebirdClient.Benchmarks.csproj --configuration Release -- --filter "*Fetch*" |
| 52 | +``` |
| 53 | + |
| 54 | +## Connection String |
| 55 | + |
| 56 | +By default the benchmark connects to: |
| 57 | + |
| 58 | +``` |
| 59 | +database=localhost:benchmark.fdb;user=sysdba;password=masterkey |
| 60 | +``` |
| 61 | + |
| 62 | +Override this with the `FIREBIRD_BENCHMARK_CS` environment variable: |
| 63 | + |
| 64 | +```powershell |
| 65 | +$env:FIREBIRD_BENCHMARK_CS = "database=myhost:benchmark.fdb;user=sysdba;password=masterkey" |
| 66 | +.\run-benchmark.ps1 |
| 67 | +``` |
| 68 | + |
| 69 | +## Configuration |
| 70 | + |
| 71 | +All benchmarks share a common configuration (`BenchmarkConfig`): |
| 72 | + |
| 73 | +- **Baseline job**: `ReleaseNuGet` build configuration — references the latest published `FirebirdSql.Data.FirebirdClient` NuGet package. |
| 74 | +- **Candidate job**: `Release` build configuration — references the local project source. |
| 75 | +- **Runtime**: .NET 10 |
| 76 | +- **Diagnostics**: Memory allocations (`MemoryDiagnoser`) |
| 77 | +- **Export**: GitHub-flavored Markdown table (written to `BenchmarkDotNet.Artifacts/`) |
| 78 | +- **Ordering**: Fastest to slowest |
| 79 | + |
| 80 | +The NuGet baseline lets you compare the locally built provider against the published release to detect regressions or measure improvements. |
| 81 | + |
| 82 | +## Available Benchmarks |
| 83 | + |
| 84 | +### `CommandBenchmark` |
| 85 | + |
| 86 | +Measures command execution over two data types (`BIGINT`, `VARCHAR(10) CHARACTER SET UTF8`): |
| 87 | + |
| 88 | +| Benchmark | Description | |
| 89 | +|-----------|-------------| |
| 90 | +| `Execute` / `ExecuteAsync` | Inserts 100 rows using `ExecuteNonQuery` / `ExecuteNonQueryAsync` | |
| 91 | +| `Fetch` / `FetchAsync` | Reads 100 rows using `ExecuteReader` / `ExecuteReaderAsync` | |
| 92 | + |
| 93 | +### `ConnectionBenchmark` |
| 94 | + |
| 95 | +Measures connection pool throughput: |
| 96 | + |
| 97 | +| Benchmark | Description | |
| 98 | +|-----------|-------------| |
| 99 | +| `OpenClose` / `OpenCloseAsync` | Opens and closes a pooled connection | |
| 100 | + |
| 101 | +### `LargeFetchBenchmark` |
| 102 | + |
| 103 | +Measures bulk read throughput for 100,000 rows across five data types: |
| 104 | + |
| 105 | +| Data Type | Notes | |
| 106 | +|-----------|-------| |
| 107 | +| `BIGINT` | Fixed-size integer | |
| 108 | +| `CHAR(255) CHARACTER SET UTF8` | Fixed-length string | |
| 109 | +| `CHAR(255) CHARACTER SET OCTETS` | Fixed-length binary | |
| 110 | +| `BLOB SUB_TYPE TEXT CHARACTER SET UTF8` | Text blob | |
| 111 | +| `BLOB SUB_TYPE BINARY` | Binary blob | |
| 112 | + |
| 113 | +## Results |
| 114 | + |
| 115 | +BenchmarkDotNet writes results to `BenchmarkDotNet.Artifacts/` in the repository root. This directory is listed in `.gitignore`. Each run produces: |
| 116 | + |
| 117 | +- A summary table in the console |
| 118 | +- A GitHub-flavored Markdown file (`.md`) suitable for pasting into issues or pull requests |
| 119 | +- An HTML report |
| 120 | +- CSV data |
0 commit comments