Skip to content

Commit c12627e

Browse files
committed
Add connection open/close benchmark
1 parent 3c3ce6e commit c12627e

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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 System.Threading.Tasks;
19+
using BenchmarkDotNet.Attributes;
20+
21+
namespace FirebirdSql.Data.FirebirdClient.Benchmarks;
22+
23+
[Config(typeof(BenchmarkConfig))]
24+
public class ConnectionBenchmark : BenchmarkBase
25+
{
26+
[GlobalSetup]
27+
public void GlobalSetup()
28+
{
29+
CreateDatabase();
30+
}
31+
32+
[Benchmark]
33+
public void OpenClose()
34+
{
35+
using var conn = new FbConnection(ConnectionString);
36+
conn.Open();
37+
}
38+
39+
[Benchmark]
40+
public async Task OpenCloseAsync()
41+
{
42+
await using var conn = new FbConnection(ConnectionString);
43+
await conn.OpenAsync();
44+
}
45+
}

0 commit comments

Comments
 (0)