Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
Dapper
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
Dapper
Commits
9313e9f1
Commit
9313e9f1
authored
Sep 12, 2018
by
ifle
Committed by
Nick Craver
Sep 11, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Linq2DB benchmarks (#1125)
Added Linq2DB benchmarks
parent
0b867bbf
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
106 additions
and
1 deletion
+106
-1
Benchmarks.Linq2DB.cs
Dapper.Tests.Performance/Benchmarks.Linq2DB.cs
+46
-0
Dapper.Tests.Performance.csproj
Dapper.Tests.Performance/Dapper.Tests.Performance.csproj
+2
-1
ConnectionStringSettings.cs
Dapper.Tests.Performance/Linq2DB/ConnectionStringSettings.cs
+12
-0
Linq2DBContext.cs
Dapper.Tests.Performance/Linq2DB/Linq2DBContext.cs
+10
-0
Linq2DbSettings.cs
Dapper.Tests.Performance/Linq2DB/Linq2DbSettings.cs
+34
-0
Post.cs
Dapper.Tests.Performance/Post.cs
+2
-0
No files found.
Dapper.Tests.Performance/Benchmarks.Linq2DB.cs
0 → 100644
View file @
9313e9f1
using
BenchmarkDotNet.Attributes
;
using
System
;
using
System.Linq
;
using
Dapper.Tests.Performance.Linq2Db
;
using
LinqToDB
;
using
LinqToDB.Data
;
namespace
Dapper.Tests.Performance
{
public
class
Liq2DbBenchmarks
:
BenchmarkBase
{
private
Linq2DBContext
_dbContext
;
private
static
Func
<
Linq2DBContext
,
int
,
Post
>
compiledQuery
=
CompiledQuery
.
Compile
((
Linq2DBContext
db
,
int
id
)
=>
db
.
Posts
.
First
(
c
=>
c
.
Id
==
id
));
[
GlobalSetup
]
public
void
Setup
()
{
BaseSetup
();
DataConnection
.
DefaultSettings
=
new
Linq2DBSettings
(
_connection
.
ConnectionString
);
_dbContext
=
new
Linq2DBContext
();
}
[
Benchmark
(
Description
=
"Normal"
)]
public
Post
Normal
()
{
Step
();
return
_dbContext
.
Posts
.
First
(
p
=>
p
.
Id
==
i
);
}
[
Benchmark
(
Description
=
"Compiled"
)]
public
Post
Compiled
()
{
Step
();
return
compiledQuery
(
_dbContext
,
i
);
}
[
Benchmark
(
Description
=
"SqlQuery"
)]
public
Post
SqlQuery
()
{
Step
();
return
_dbContext
.
Query
<
Post
>(
"select * from Posts where Id = @id"
,
new
{
id
=
i
}).
First
();
}
}
}
Dapper.Tests.Performance/Dapper.Tests.Performance.csproj
View file @
9313e9f1
...
...
@@ -16,6 +16,7 @@
<!--<PackageReference Include="BLToolkit" Version="4.3.6" />-->
<PackageReference Include="EntityFramework" Version="6.2.0" />
<PackageReference Include="FirebirdSql.Data.FirebirdClient" Version="6.3.0" />
<PackageReference Include="linq2db.SqlServer" Version="2.3.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.2" />
<PackageReference Include="Microsoft.SqlServer.Types" Version="14.0.314.76" />
<PackageReference Include="MySqlConnector" Version="0.44.1" />
...
...
@@ -40,7 +41,7 @@
<ItemGroup>
<None Update="NHibernate\*.xml" CopyToOutputDirectory="Always" />
<Compile Update="Benchmarks.*.cs" DependentUpon="Benchmarks.cs" />
</ItemGroup>
</ItemGroup>
<ItemGroup>
<PackageReference Update="SourceLink.Create.GitHub" Version="2.8.3" />
</ItemGroup>
...
...
Dapper.Tests.Performance/Linq2DB/ConnectionStringSettings.cs
0 → 100644
View file @
9313e9f1
using
LinqToDB.Configuration
;
namespace
Dapper.Tests.Performance.Linq2Db
{
public
class
ConnectionStringSettings
:
IConnectionStringSettings
{
public
string
ConnectionString
{
get
;
set
;
}
public
string
Name
{
get
;
set
;
}
public
string
ProviderName
{
get
;
set
;
}
public
bool
IsGlobal
=>
false
;
}
}
\ No newline at end of file
Dapper.Tests.Performance/Linq2DB/Linq2DBContext.cs
0 → 100644
View file @
9313e9f1
using
LinqToDB
;
using
Microsoft.EntityFrameworkCore
;
namespace
Dapper.Tests.Performance.Linq2Db
{
public
class
Linq2DBContext
:
LinqToDB
.
Data
.
DataConnection
{
public
ITable
<
Post
>
Posts
=>
GetTable
<
Post
>();
}
}
Dapper.Tests.Performance/Linq2DB/Linq2DbSettings.cs
0 → 100644
View file @
9313e9f1
using
System.Collections.Generic
;
using
System.Linq
;
using
LinqToDB.Configuration
;
namespace
Dapper.Tests.Performance.Linq2Db
{
public
class
Linq2DBSettings
:
ILinqToDBSettings
{
private
readonly
string
_connectionString
;
public
IEnumerable
<
IDataProviderSettings
>
DataProviders
=>
Enumerable
.
Empty
<
IDataProviderSettings
>();
public
string
DefaultConfiguration
=>
"SqlServer"
;
public
string
DefaultDataProvider
=>
"SqlServer"
;
public
Linq2DBSettings
(
string
connectionString
)
{
_connectionString
=
connectionString
;
}
public
IEnumerable
<
IConnectionStringSettings
>
ConnectionStrings
{
get
{
yield
return
new
ConnectionStringSettings
{
Name
=
"SqlServer"
,
ProviderName
=
"SqlServer"
,
ConnectionString
=
_connectionString
};
}
}
}
}
Dapper.Tests.Performance/Post.cs
View file @
9313e9f1
...
...
@@ -5,9 +5,11 @@ namespace Dapper.Tests.Performance
{
[
ServiceStack
.
DataAnnotations
.
Alias
(
"Posts"
)]
[
Table
(
Name
=
"Posts"
)]
[
LinqToDB
.
Mapping
.
Table
(
Name
=
"Posts"
)]
public
class
Post
{
[
Id
(
IdKind
.
Identity
)]
[
LinqToDB
.
Mapping
.
PrimaryKey
,
LinqToDB
.
Mapping
.
Identity
]
public
int
Id
{
get
;
set
;
}
public
string
Text
{
get
;
set
;
}
public
DateTime
CreationDate
{
get
;
set
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment