Skip to content

Commit 20cb310

Browse files
committed
Added Perf project.
1 parent 8a011d2 commit 20cb310

File tree

4 files changed

+164
-0
lines changed

4 files changed

+164
-0
lines changed

Provider/src/NETProvider.sln

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FirebirdSql.EntityFramework
3333
EndProject
3434
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "FirebirdSql.Data.External", "FirebirdSql.Data.External\FirebirdSql.Data.External.shproj", "{884EE120-B22E-4940-8C1C-626F13028376}"
3535
EndProject
36+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Perf", "Perf\Perf.csproj", "{BB846245-545A-4506-A0DA-0041C535D3A9}"
37+
EndProject
38+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Perf", "Perf", "{CE2BB2BB-4639-49EA-8369-0215A1D7245D}"
39+
EndProject
3640
Global
3741
GlobalSection(SharedMSBuildProjectFiles) = preSolution
3842
FirebirdSql.Data.TestsBase\FirebirdSql.Data.TestsBase.projitems*{2f67ff6e-a6fc-44f4-9687-9e5ca05c73a3}*SharedItemsImports = 13
@@ -71,6 +75,10 @@ Global
7175
{2925DB97-5B39-4D9E-90CC-F7470F9AA8F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
7276
{2925DB97-5B39-4D9E-90CC-F7470F9AA8F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
7377
{2925DB97-5B39-4D9E-90CC-F7470F9AA8F3}.Release|Any CPU.Build.0 = Release|Any CPU
78+
{BB846245-545A-4506-A0DA-0041C535D3A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
79+
{BB846245-545A-4506-A0DA-0041C535D3A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
80+
{BB846245-545A-4506-A0DA-0041C535D3A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
81+
{BB846245-545A-4506-A0DA-0041C535D3A9}.Release|Any CPU.Build.0 = Release|Any CPU
7482
EndGlobalSection
7583
GlobalSection(SolutionProperties) = preSolution
7684
HideSolutionNode = FALSE
@@ -85,6 +93,8 @@ Global
8593
{42A00B25-673E-449A-9B89-BE89344F96F0} = {AD392B88-6637-4744-BDF9-8FB9453C9042}
8694
{2925DB97-5B39-4D9E-90CC-F7470F9AA8F3} = {AD392B88-6637-4744-BDF9-8FB9453C9042}
8795
{884EE120-B22E-4940-8C1C-626F13028376} = {C94B5B06-9023-43C1-9B0D-6BDD504F9A06}
96+
{BB846245-545A-4506-A0DA-0041C535D3A9} = {CE2BB2BB-4639-49EA-8369-0215A1D7245D}
97+
{CE2BB2BB-4639-49EA-8369-0215A1D7245D} = {C94B5B06-9023-43C1-9B0D-6BDD504F9A06}
8898
EndGlobalSection
8999
GlobalSection(ExtensibilityGlobals) = postSolution
90100
SolutionGuid = {D574B071-15C1-4024-BB37-78D690F61070}
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
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/blob/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.Attributes;
19+
using BenchmarkDotNet.Configs;
20+
using BenchmarkDotNet.Diagnosers;
21+
using BenchmarkDotNet.Environments;
22+
using BenchmarkDotNet.Jobs;
23+
using BenchmarkDotNet.Toolchains.CsProj;
24+
using FirebirdSql.Data.FirebirdClient;
25+
26+
namespace Perf
27+
{
28+
[Config(typeof(Config))]
29+
public class FetchBenchmark
30+
{
31+
class Config : ManualConfig
32+
{
33+
public Config()
34+
{
35+
var baseJob = Job.ShortRun
36+
.With(CsProjCoreToolchain.Current.Value)
37+
.With(Platform.X64)
38+
.With(Jit.RyuJit)
39+
.With(Runtime.Core);
40+
Add(MemoryDiagnoser.Default);
41+
Add(baseJob.WithCustomBuildConfiguration("Release").WithId("Project"));
42+
Add(baseJob.WithCustomBuildConfiguration("ReleaseNuGet").WithId("NuGet"));
43+
}
44+
}
45+
46+
const string ConnectionString = "database=localhost:benchmark.fdb;user=sysdba;password=masterkey";
47+
48+
[Params("int", "bigint", "varchar(10) character set utf8")]
49+
public string DataType { get; set; }
50+
51+
[GlobalSetup(Target = nameof(Fetch200k))]
52+
public void Fetch200kSetup()
53+
{
54+
FbConnection.CreateDatabase(ConnectionString, true);
55+
using (var conn = new FbConnection(ConnectionString))
56+
{
57+
conn.Open();
58+
using (var cmd = conn.CreateCommand())
59+
{
60+
cmd.CommandText = $"create table foobar (x {DataType})";
61+
cmd.ExecuteNonQuery();
62+
}
63+
using (var cmd = conn.CreateCommand())
64+
{
65+
cmd.CommandText = @"execute block as
66+
declare cnt int;
67+
begin
68+
cnt = 200000;
69+
while (cnt > 0) do
70+
begin
71+
insert into foobar values (:cnt);
72+
cnt = cnt - 1;
73+
end
74+
end";
75+
cmd.ExecuteNonQuery();
76+
}
77+
}
78+
}
79+
80+
[Benchmark]
81+
public void Fetch200k()
82+
{
83+
using (var conn = new FbConnection(ConnectionString))
84+
{
85+
conn.Open();
86+
using (var cmd = conn.CreateCommand())
87+
{
88+
cmd.CommandText = "select x from foobar";
89+
using (var reader = cmd.ExecuteReader())
90+
{
91+
while (reader.Read())
92+
{
93+
var dummy = reader[0];
94+
}
95+
}
96+
}
97+
}
98+
}
99+
100+
[GlobalCleanup(Target = nameof(Fetch200k))]
101+
public void Fetch200kCleanup()
102+
{
103+
FbConnection.ClearAllPools();
104+
FbConnection.DropDatabase(ConnectionString);
105+
}
106+
}
107+
}

Provider/src/Perf/Perf.csproj

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
<TargetFramework>netcoreapp2.2</TargetFramework>
5+
<SkipSourceLink>true</SkipSourceLink>
6+
</PropertyGroup>
7+
<ItemGroup>
8+
<PackageReference Include="BenchmarkDotNet" Version="0.11.5" />
9+
</ItemGroup>
10+
11+
<ItemGroup Condition="!$(Configuration.EndsWith('NuGet'))">
12+
<ProjectReference Include="..\FirebirdSql.Data.FirebirdClient\FirebirdSql.Data.FirebirdClient.csproj" />
13+
</ItemGroup>
14+
15+
<ItemGroup Condition="$(Configuration.EndsWith('NuGet'))">
16+
<PackageReference Include="FirebirdSql.Data.FirebirdClient" Version="7.0.0" />
17+
</ItemGroup>
18+
</Project>

Provider/src/Perf/Program.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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/blob/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.Running;
19+
20+
namespace Perf
21+
{
22+
class Program
23+
{
24+
static void Main(string[] args)
25+
{
26+
BenchmarkRunner.Run<FetchBenchmark>();
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)