Skip to content

Commit 2f69118

Browse files
committed
Simplified the benchmarks and added documentation.
1 parent b7a29cf commit 2f69118

6 files changed

Lines changed: 37 additions & 128 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,3 +276,6 @@ __pycache__/
276276

277277
# Thumbs
278278
Thumbs.db
279+
280+
# BenchmarkDotNet report
281+
BenchmarkDotNet.Artifacts/

QueryBuilder.Benchmarks/Infrastructure/TestSupport.cs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,6 @@ namespace QueryBuilder.Benchmarks.Infrastructure;
55

66
public class TestSupport
77
{
8-
9-
public static SqlResult CompileFor(string engine, Query query, Func<Compiler, Compiler> configuration = null)
10-
{
11-
var compiler = CreateCompiler(engine);
12-
if (configuration != null)
13-
{
14-
compiler = configuration(compiler);
15-
}
16-
17-
return compiler.Compile(query);
18-
}
19-
20-
public static SqlResult CompileFor(string engine, Query query, Action<Compiler> configuration)
21-
{
22-
return CompileFor(engine, query, compiler =>
23-
{
24-
configuration(compiler);
25-
return compiler;
26-
});
27-
}
28-
298
public static Compiler CreateCompiler(string engine)
309
{
3110
return engine switch

QueryBuilder.Benchmarks/Program.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
// See https://aka.ms/new-console-template for more information
2-
1+
// BenchmarkDotNet: https://benchmarkdotnet.org/
32
using BenchmarkDotNet.Running;
4-
using QueryBuilder.Benchmarks;
5-
6-
SelectsBenchmarkTests.TestAll();
73

8-
BenchmarkRunner.Run<SelectsBenchmark>();
4+
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);

QueryBuilder.Benchmarks/REAEDME.MD

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# QueryBuilder.Benchmarks
2+
3+
This project is a benchmark suite for measuring the performance of the SqlKata query builder library. It uses [BenchmarkDotNet](https://benchmarkdotnet.org/) to provide performance metrics for various query-building scenarios.
4+
5+
## About
6+
7+
- **Purpose:** Evaluate the performance of different SqlKata query operations.
8+
- **Framework:** [BenchmarkDotNet](https://benchmarkdotnet.org/) is used for running and reporting benchmarks.
9+
- **Scope:** Includes benchmarks for a few select scenarios.
10+
11+
## How to Use
12+
13+
1. **Build the Solution:**
14+
Make sure the solution is built in Release mode for accurate results.
15+
16+
2. **Run the Benchmarks:**
17+
Execute the following command from the root of the repository:
18+
19+
```cmd
20+
dotnet run -c Release --project .\QueryBuilder.Benchmarks\QueryBuilder.Benchmarks.csproj
21+
```
22+
23+
3. **Select Benchmarks:**
24+
After running the command, a benchmark selector will appear. This is powered by BenchmarkDotNet's `BenchmarkSwitcher`, allowing you to choose which benchmarks to execute interactively.
25+
26+
4. **View Results:**
27+
BenchmarkDotNet will output the results to the console and generate detailed reports in the `BenchmarkDotNet.Artifacts` directory.
28+
29+
## References
30+
- [BenchmarkDotNet](https://benchmarkdotnet.org/)

QueryBuilder.Benchmarks/SelectsBenchmark.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using System.ComponentModel.DataAnnotations;
2-
using System.Text.RegularExpressions;
3-
using BenchmarkDotNet.Attributes;
1+
using BenchmarkDotNet.Attributes;
42
using QueryBuilder.Benchmarks.Infrastructure;
53
using SqlKata;
64
using SqlKata.Compilers;
@@ -16,8 +14,7 @@ public class SelectsBenchmark
1614

1715
public Compiler compiler;
1816

19-
[Params(
20-
EngineCodes.SqlServer)]
17+
[Params(EngineCodes.SqlServer)]
2118
public string EngineCode { get; set; }
2219

2320
[GlobalSetup]
@@ -78,5 +75,4 @@ public SqlResult SelectWith()
7875
{
7976
return compiler.Compile(selectWith);
8077
}
81-
8278
}

QueryBuilder.Benchmarks/SelectsBenchmarkTests.cs

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

0 commit comments

Comments
 (0)