Skip to content

Commit 8fa39ed

Browse files
committed
Extract shared BenchmarkConfig to eliminate duplication
1 parent 04208fe commit 8fa39ed

3 files changed

Lines changed: 55 additions & 76 deletions

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* The contents of this file are subject to the Initial
3+
* Developer's Public License Version 1.0 (the "License");
4+
* you may not use this file except in compliance with the
5+
* License. You may obtain a copy of the License at
6+
* https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.
7+
*
8+
* Software distributed under the License is distributed on
9+
* an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
10+
* express or implied. See the License for the specific
11+
* language governing rights and limitations under the License.
12+
*
13+
* All Rights Reserved.
14+
*/
15+
16+
//$Authors = Jiri Cincura (jiri@cincura.net)
17+
18+
using BenchmarkDotNet.Configs;
19+
using BenchmarkDotNet.Diagnosers;
20+
using BenchmarkDotNet.Jobs;
21+
using BenchmarkDotNet.Toolchains.CsProj;
22+
using BenchmarkDotNet.Validators;
23+
24+
namespace FirebirdSql.Data.FirebirdClient.Benchmarks;
25+
26+
class BenchmarkConfig : ManualConfig
27+
{
28+
public BenchmarkConfig()
29+
{
30+
var baseJob = Job.Default
31+
.WithWarmupCount(3);
32+
33+
AddJob(
34+
baseJob
35+
.WithToolchain(CsProjCoreToolchain.NetCoreApp80)
36+
.WithCustomBuildConfiguration("ReleaseNuGet")
37+
.WithId("NuGet80")
38+
.AsBaseline()
39+
);
40+
41+
AddJob(
42+
baseJob
43+
.WithToolchain(CsProjCoreToolchain.NetCoreApp80)
44+
.WithCustomBuildConfiguration("Release")
45+
.WithId("Core80")
46+
);
47+
48+
AddDiagnoser(MemoryDiagnoser.Default);
49+
50+
AddValidator(BaselineValidator.FailOnError);
51+
AddValidator(JitOptimizationsValidator.FailOnError);
52+
}
53+
}

src/FirebirdSql.Data.FirebirdClient.Benchmarks/CommandBenchmark.cs

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -16,49 +16,12 @@
1616
//$Authors = Jiri Cincura (jiri@cincura.net)
1717

1818
using BenchmarkDotNet.Attributes;
19-
using BenchmarkDotNet.Configs;
20-
using BenchmarkDotNet.Diagnosers;
21-
using BenchmarkDotNet.Environments;
22-
using BenchmarkDotNet.Jobs;
23-
using BenchmarkDotNet.Toolchains.CsProj;
24-
using BenchmarkDotNet.Validators;
2519

2620
namespace FirebirdSql.Data.FirebirdClient.Benchmarks;
2721

28-
[Config(typeof(Config))]
22+
[Config(typeof(BenchmarkConfig))]
2923
public partial class CommandBenchmark
3024
{
31-
class Config : ManualConfig
32-
{
33-
public Config()
34-
{
35-
var baseJob = Job.Default
36-
.WithWarmupCount(3)
37-
.WithPlatform(Platform.X64)
38-
.WithJit(Jit.RyuJit);
39-
40-
AddJob(
41-
baseJob
42-
.WithToolchain(CsProjCoreToolchain.NetCoreApp80)
43-
.WithCustomBuildConfiguration("ReleaseNuGet")
44-
.WithId("NuGet80")
45-
.AsBaseline()
46-
);
47-
48-
AddJob(
49-
baseJob
50-
.WithToolchain(CsProjCoreToolchain.NetCoreApp80)
51-
.WithCustomBuildConfiguration("Release")
52-
.WithId("Core80")
53-
);
54-
55-
AddDiagnoser(MemoryDiagnoser.Default);
56-
57-
AddValidator(BaselineValidator.FailOnError);
58-
AddValidator(JitOptimizationsValidator.FailOnError);
59-
}
60-
}
61-
6225
protected const string ConnectionString = "database=localhost:benchmark.fdb;user=sysdba;password=masterkey";
6326

6427
[Params("BIGINT", "VARCHAR(10) CHARACTER SET UTF8")]

src/FirebirdSql.Data.FirebirdClient.Benchmarks/LargeFetchBenchmark.cs

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,10 @@
11
using BenchmarkDotNet.Attributes;
2-
using BenchmarkDotNet.Configs;
3-
using BenchmarkDotNet.Diagnosers;
4-
using BenchmarkDotNet.Environments;
5-
using BenchmarkDotNet.Jobs;
6-
using BenchmarkDotNet.Toolchains.CsProj;
7-
using BenchmarkDotNet.Validators;
82

93
namespace FirebirdSql.Data.FirebirdClient.Benchmarks;
104

11-
[Config(typeof(Config))]
5+
[Config(typeof(BenchmarkConfig))]
126
public class LargeFetchBenchmark
137
{
14-
class Config : ManualConfig
15-
{
16-
public Config()
17-
{
18-
var baseJob = Job.Default
19-
.WithWarmupCount(3)
20-
.WithPlatform(Platform.X64)
21-
.WithJit(Jit.RyuJit);
22-
23-
AddJob(
24-
baseJob
25-
.WithToolchain(CsProjCoreToolchain.NetCoreApp80)
26-
.WithCustomBuildConfiguration("ReleaseNuGet")
27-
.WithId("NuGet80")
28-
.AsBaseline()
29-
);
30-
31-
AddJob(
32-
baseJob
33-
.WithToolchain(CsProjCoreToolchain.NetCoreApp80)
34-
.WithCustomBuildConfiguration("Release")
35-
.WithId("Core80")
36-
);
37-
38-
AddDiagnoser(MemoryDiagnoser.Default);
39-
40-
AddValidator(BaselineValidator.FailOnError);
41-
AddValidator(JitOptimizationsValidator.FailOnError);
42-
}
43-
}
44-
458
protected const string ConnectionString = "database=localhost:benchmark.fdb;user=sysdba;password=masterkey";
469

4710
[Params(100_000)]

0 commit comments

Comments
 (0)