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
3c14c8b6
Commit
3c14c8b6
authored
Jun 02, 2017
by
James Law
Committed by
Nick Craver
Jun 02, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added EntityFrameworkCore performance tests (#778)
parent
fb443385
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
0 deletions
+64
-0
Benchmarks.EntityFrameworkCore.cs
Dapper.Tests.Performance/Benchmarks.EntityFrameworkCore.cs
+44
-0
Dapper.Tests.Performance.csproj
Dapper.Tests.Performance/Dapper.Tests.Performance.csproj
+2
-0
EFCoreContext.cs
...er.Tests.Performance/EntityFrameworkCore/EFCoreContext.cs
+18
-0
No files found.
Dapper.Tests.Performance/Benchmarks.EntityFrameworkCore.cs
0 → 100644
View file @
3c14c8b6
using
BenchmarkDotNet.Attributes
;
using
Dapper.Tests.Performance.Linq2Sql
;
using
Microsoft.EntityFrameworkCore
;
using
System
;
using
System.Data.Linq
;
using
System.Linq
;
namespace
Dapper.Tests.Performance
{
public
class
EFCoreBenchmarks
:
BenchmarkBase
{
private
EntityFrameworkCore
.
EFCoreContext
Context
;
private
static
readonly
Func
<
DataClassesDataContext
,
int
,
Linq2Sql
.
Post
>
compiledQuery
=
CompiledQuery
.
Compile
((
DataClassesDataContext
ctx
,
int
id
)
=>
ctx
.
Posts
.
First
(
p
=>
p
.
Id
==
id
));
[
Setup
]
public
void
Setup
()
{
BaseSetup
();
Context
=
new
EntityFrameworkCore
.
EFCoreContext
(
_connection
.
ConnectionString
);
}
[
Benchmark
(
Description
=
"Normal"
)]
public
Post
Normal
()
{
Step
();
return
Context
.
Posts
.
First
(
p
=>
p
.
Id
==
i
);
}
[
Benchmark
(
Description
=
"SqlQuery"
)]
public
Post
SqlQuery
()
{
Step
();
return
Context
.
Posts
.
FromSql
(
"select * from Posts where Id = {0}"
,
i
).
First
();
}
[
Benchmark
(
Description
=
"No Tracking"
)]
public
Post
NoTracking
()
{
Step
();
return
Context
.
Posts
.
AsNoTracking
().
First
(
p
=>
p
.
Id
==
i
);
}
}
}
\ No newline at end of file
Dapper.Tests.Performance/Dapper.Tests.Performance.csproj
View file @
3c14c8b6
...
...
@@ -17,6 +17,8 @@
<!--<PackageReference Include="BLToolkit" Version="4.3.6" />-->
<PackageReference Include="EntityFramework" Version="6.1.3" />
<PackageReference Include="FirebirdSql.Data.FirebirdClient" Version="5.9.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.2" />
<PackageReference Include="Microsoft.SqlServer.Compact" Version="4.0.8876.1" />
<PackageReference Include="Microsoft.SqlServer.Types" Version="14.0.314.76" />
<PackageReference Include="MySql.Data" Version="7.0.7-m61" />
...
...
Dapper.Tests.Performance/EntityFrameworkCore/EFCoreContext.cs
0 → 100644
View file @
3c14c8b6
using
Microsoft.EntityFrameworkCore
;
namespace
Dapper.Tests.Performance.EntityFrameworkCore
{
public
class
EFCoreContext
:
DbContext
{
private
readonly
string
_connectionString
;
public
EFCoreContext
(
string
connectionString
)
{
_connectionString
=
connectionString
;
}
protected
override
void
OnConfiguring
(
DbContextOptionsBuilder
optionsBuilder
)
=>
optionsBuilder
.
UseSqlServer
(
_connectionString
);
public
DbSet
<
Post
>
Posts
{
get
;
set
;
}
}
}
\ No newline at end of file
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