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
0ec089b7
Commit
0ec089b7
authored
Sep 11, 2018
by
Nick Craver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Benchmarks: normalize names and give ORMs better names via [Description]
parent
b262cb33
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
78 additions
and
45 deletions
+78
-45
Benchmarks.Belgrade.cs
Dapper.Tests.Performance/Benchmarks.Belgrade.cs
+2
-1
Benchmarks.Dapper.cs
Dapper.Tests.Performance/Benchmarks.Dapper.cs
+2
-0
Benchmarks.Dashing.cs
Dapper.Tests.Performance/Benchmarks.Dashing.cs
+8
-6
Benchmarks.EntityFramework.cs
Dapper.Tests.Performance/Benchmarks.EntityFramework.cs
+7
-5
Benchmarks.EntityFrameworkCore.cs
Dapper.Tests.Performance/Benchmarks.EntityFrameworkCore.cs
+7
-4
Benchmarks.HandCoded.cs
Dapper.Tests.Performance/Benchmarks.HandCoded.cs
+3
-2
Benchmarks.Linq2DB.cs
Dapper.Tests.Performance/Benchmarks.Linq2DB.cs
+7
-5
Benchmarks.Linq2Sql.cs
Dapper.Tests.Performance/Benchmarks.Linq2Sql.cs
+8
-5
Benchmarks.Massive.cs
Dapper.Tests.Performance/Benchmarks.Massive.cs
+4
-2
Benchmarks.PetaPoco.cs
Dapper.Tests.Performance/Benchmarks.PetaPoco.cs
+6
-4
Benchmarks.ServiceStack.cs
Dapper.Tests.Performance/Benchmarks.ServiceStack.cs
+5
-3
Benchmarks.Susanoo.cs
Dapper.Tests.Performance/Benchmarks.Susanoo.cs
+10
-6
ORMColum.cs
Dapper.Tests.Performance/Helpers/ORMColum.cs
+9
-2
No files found.
Dapper.Tests.Performance/Benchmarks.Belgrade.cs
View file @
0ec089b7
using
BenchmarkDotNet.Attributes
;
using
Belgrade.SqlClient.SqlDb
;
using
System.Threading.Tasks
;
using
Belgrade.SqlClient
;
using
System.ComponentModel
;
namespace
Dapper.Tests.Performance
{
[
Description
(
"Belgrade"
)]
public
class
BelgradeBenchmarks
:
BenchmarkBase
{
private
QueryMapper
_mapper
;
...
...
Dapper.Tests.Performance/Benchmarks.Dapper.cs
View file @
0ec089b7
using
BenchmarkDotNet.Attributes
;
using
Dapper.Contrib.Extensions
;
using
System.ComponentModel
;
using
System.Linq
;
namespace
Dapper.Tests.Performance
{
[
Description
(
"Dapper"
)]
public
class
DapperBenchmarks
:
BenchmarkBase
{
[
GlobalSetup
]
...
...
Dapper.Tests.Performance/Benchmarks.Dashing.cs
View file @
0ec089b7
using
BenchmarkDotNet.Attributes
;
using
System.ComponentModel
;
using
BenchmarkDotNet.Attributes
;
using
Dapper.Tests.Performance.Dashing
;
using
Dashing
;
namespace
Dapper.Tests.Performance
{
[
Description
(
"Dashing"
)]
public
class
DashingBenchmarks
:
BenchmarkBase
{
private
ISession
s
ession
;
private
ISession
S
ession
;
[
GlobalSetup
]
public
void
Setup
()
...
...
@@ -14,14 +16,14 @@ public void Setup()
BaseSetup
();
var
configuration
=
new
DashingConfiguration
();
var
database
=
new
SqlDatabase
(
configuration
,
ConnectionString
);
this
.
s
ession
=
database
.
BeginTransactionLessSession
(
_connection
);
S
ession
=
database
.
BeginTransactionLessSession
(
_connection
);
}
[
Benchmark
(
Description
=
"Get
By Id
"
)]
public
Dashing
.
Post
QueryBuffered
()
[
Benchmark
(
Description
=
"Get"
)]
public
Dashing
.
Post
Get
()
{
Step
();
return
s
ession
.
Get
<
Dashing
.
Post
>(
i
);
return
S
ession
.
Get
<
Dashing
.
Post
>(
i
);
}
}
}
Dapper.Tests.Performance/Benchmarks.EntityFramework.cs
View file @
0ec089b7
using
BenchmarkDotNet.Attributes
;
using
BenchmarkDotNet.Attributes
;
using
System.ComponentModel
;
using
System.Linq
;
namespace
Dapper.Tests.Performance
{
[
Description
(
"EF 6"
)]
public
class
EF6Benchmarks
:
BenchmarkBase
{
private
EntityFramework
.
EFContext
Context
;
...
...
@@ -14,8 +16,8 @@ public void Setup()
Context
=
new
EntityFramework
.
EFContext
(
_connection
);
}
[
Benchmark
(
Description
=
"
Normal
"
)]
public
Post
Normal
()
[
Benchmark
(
Description
=
"
First
"
)]
public
Post
First
()
{
Step
();
return
Context
.
Posts
.
First
(
p
=>
p
.
Id
==
i
);
...
...
@@ -28,11 +30,11 @@ public Post SqlQuery()
return
Context
.
Database
.
SqlQuery
<
Post
>(
"select * from Posts where Id = {0}"
,
i
).
First
();
}
[
Benchmark
(
Description
=
"
No Tracking
"
)]
[
Benchmark
(
Description
=
"
First (No Tracking)
"
)]
public
Post
NoTracking
()
{
Step
();
return
Context
.
Posts
.
AsNoTracking
().
First
(
p
=>
p
.
Id
==
i
);
}
}
}
\ No newline at end of file
}
Dapper.Tests.Performance/Benchmarks.EntityFrameworkCore.cs
View file @
0ec089b7
...
...
@@ -2,13 +2,16 @@
using
Dapper.Tests.Performance.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore
;
using
System
;
using
System.ComponentModel
;
using
System.Linq
;
namespace
Dapper.Tests.Performance
{
[
Description
(
"EF Core"
)]
public
class
EFCoreBenchmarks
:
BenchmarkBase
{
private
EFCoreContext
Context
;
private
static
readonly
Func
<
EFCoreContext
,
int
,
Post
>
compiledQuery
=
EF
.
CompileQuery
((
EFCoreContext
ctx
,
int
id
)
=>
ctx
.
Posts
.
First
(
p
=>
p
.
Id
==
id
));
...
...
@@ -19,14 +22,14 @@ public void Setup()
Context
=
new
EFCoreContext
(
_connection
.
ConnectionString
);
}
[
Benchmark
(
Description
=
"
Normal
"
)]
public
Post
Normal
()
[
Benchmark
(
Description
=
"
First
"
)]
public
Post
First
()
{
Step
();
return
Context
.
Posts
.
First
(
p
=>
p
.
Id
==
i
);
}
[
Benchmark
(
Description
=
"
Compiled
"
)]
[
Benchmark
(
Description
=
"
First (Compiled)
"
)]
public
Post
Compiled
()
{
Step
();
...
...
@@ -40,7 +43,7 @@ public Post SqlQuery()
return
Context
.
Posts
.
FromSql
(
"select * from Posts where Id = {0}"
,
i
).
First
();
}
[
Benchmark
(
Description
=
"
No Tracking
"
)]
[
Benchmark
(
Description
=
"
First (No Tracking)
"
)]
public
Post
NoTracking
()
{
Step
();
...
...
Dapper.Tests.Performance/Benchmarks.HandCoded.cs
View file @
0ec089b7
using
BenchmarkDotNet.Attributes
;
using
System
;
using
System.ComponentModel
;
using
System.Data
;
using
System.Data.SqlClient
;
namespace
Dapper.Tests.Performance
{
[
Description
(
"Hand Coded"
)]
public
class
HandCodedBenchmarks
:
BenchmarkBase
{
private
SqlCommand
_postCommand
;
...
...
@@ -56,7 +58,7 @@ public Post SqlCommand()
using
(
var
reader
=
_postCommand
.
ExecuteReader
())
{
reader
.
Read
();
var
post
=
new
Post
return
new
Post
{
Id
=
reader
.
GetInt32
(
0
),
Text
=
reader
.
GetNullableString
(
1
),
...
...
@@ -73,7 +75,6 @@ public Post SqlCommand()
Counter8
=
reader
.
IsDBNull
(
11
)
?
null
:
(
int
?)
reader
.
GetInt32
(
11
),
Counter9
=
reader
.
IsDBNull
(
12
)
?
null
:
(
int
?)
reader
.
GetInt32
(
12
)
};
return
post
;
}
}
...
...
Dapper.Tests.Performance/Benchmarks.Linq2DB.cs
View file @
0ec089b7
...
...
@@ -5,9 +5,11 @@
using
Dapper.Tests.Performance.Linq2Db
;
using
LinqToDB
;
using
LinqToDB.Data
;
using
System.ComponentModel
;
namespace
Dapper.Tests.Performance
{
[
Description
(
"LINQ to DB"
)]
public
class
Linq2DBBenchmarks
:
BenchmarkBase
{
private
Linq2DBContext
_dbContext
;
...
...
@@ -22,22 +24,22 @@ public void Setup()
_dbContext
=
new
Linq2DBContext
();
}
[
Benchmark
(
Description
=
"
Normal
"
)]
public
Post
Normal
()
[
Benchmark
(
Description
=
"
First
"
)]
public
Post
First
()
{
Step
();
return
_dbContext
.
Posts
.
First
(
p
=>
p
.
Id
==
i
);
}
[
Benchmark
(
Description
=
"
Compiled
"
)]
[
Benchmark
(
Description
=
"
First (Compiled)
"
)]
public
Post
Compiled
()
{
Step
();
return
compiledQuery
(
_dbContext
,
i
);
}
[
Benchmark
(
Description
=
"
SqlQuery
"
)]
public
Post
Sql
Query
()
[
Benchmark
(
Description
=
"
Query<T>
"
)]
public
Post
Query
()
{
Step
();
return
_dbContext
.
Query
<
Post
>(
"select * from Posts where Id = @id"
,
new
{
id
=
i
}).
First
();
...
...
Dapper.Tests.Performance/Benchmarks.Linq2Sql.cs
View file @
0ec089b7
using
BenchmarkDotNet.Attributes
;
using
BenchmarkDotNet.Attributes
;
using
Dapper.Tests.Performance.Linq2Sql
;
using
System
;
using
System.ComponentModel
;
using
System.Data.Linq
;
using
System.Linq
;
namespace
Dapper.Tests.Performance
{
[
Description
(
"LINQ to SQL"
)]
public
class
Linq2SqlBenchmarks
:
BenchmarkBase
{
private
DataClassesDataContext
Linq2SqlContext
;
private
static
readonly
Func
<
DataClassesDataContext
,
int
,
Linq2Sql
.
Post
>
compiledQuery
=
CompiledQuery
.
Compile
((
DataClassesDataContext
ctx
,
int
id
)
=>
ctx
.
Posts
.
First
(
p
=>
p
.
Id
==
id
));
...
...
@@ -19,14 +22,14 @@ public void Setup()
Linq2SqlContext
=
new
DataClassesDataContext
(
_connection
);
}
[
Benchmark
(
Description
=
"
Normal
"
)]
public
Linq2Sql
.
Post
Normal
()
[
Benchmark
(
Description
=
"
First
"
)]
public
Linq2Sql
.
Post
First
()
{
Step
();
return
Linq2SqlContext
.
Posts
.
First
(
p
=>
p
.
Id
==
i
);
}
[
Benchmark
(
Description
=
"
Compiled
"
)]
[
Benchmark
(
Description
=
"
First (Compiled)
"
)]
public
Linq2Sql
.
Post
Compiled
()
{
Step
();
...
...
@@ -40,4 +43,4 @@ public Post ExecuteQuery()
return
Linq2SqlContext
.
ExecuteQuery
<
Post
>(
"select * from Posts where Id = {0}"
,
i
).
First
();
}
}
}
\ No newline at end of file
}
Dapper.Tests.Performance/Benchmarks.Massive.cs
View file @
0ec089b7
using
BenchmarkDotNet.Attributes
;
using
BenchmarkDotNet.Attributes
;
using
Massive
;
using
System.ComponentModel
;
using
System.Linq
;
namespace
Dapper.Tests.Performance
{
[
Description
(
"Massive"
)]
public
class
MassiveBenchmarks
:
BenchmarkBase
{
private
DynamicModel
_model
;
...
...
@@ -22,4 +24,4 @@ public dynamic QueryDynamic()
return
_model
.
Query
(
"select * from Posts where Id = @0"
,
_connection
,
i
).
First
();
}
}
}
\ No newline at end of file
}
Dapper.Tests.Performance/Benchmarks.PetaPoco.cs
View file @
0ec089b7
using
BenchmarkDotNet.Attributes
;
using
BenchmarkDotNet.Attributes
;
using
PetaPoco
;
using
System.ComponentModel
;
using
System.Linq
;
namespace
Dapper.Tests.Performance
{
[
Description
(
"PetaPoco"
)]
public
class
PetaPocoBenchmarks
:
BenchmarkBase
{
private
Database
_db
,
_dbFast
;
...
...
@@ -21,18 +23,18 @@ public void Setup()
_dbFast
.
ForceDateTimesToUtc
=
false
;
}
[
Benchmark
(
Description
=
"Fetch<
Post
>"
)]
[
Benchmark
(
Description
=
"Fetch<
T
>"
)]
public
Post
Fetch
()
{
Step
();
return
_db
.
Fetch
<
Post
>(
"SELECT * from Posts where Id=@0"
,
i
).
First
();
}
[
Benchmark
(
Description
=
"Fetch<
Post
> (Fast)"
)]
[
Benchmark
(
Description
=
"Fetch<
T
> (Fast)"
)]
public
Post
FetchFast
()
{
Step
();
return
_dbFast
.
Fetch
<
Post
>(
"SELECT * from Posts where Id=@0"
,
i
).
First
();
}
}
}
\ No newline at end of file
}
Dapper.Tests.Performance/Benchmarks.ServiceStack.cs
View file @
0ec089b7
using
BenchmarkDotNet.Attributes
;
using
BenchmarkDotNet.Attributes
;
using
ServiceStack.OrmLite
;
using
System.ComponentModel
;
using
System.Data
;
namespace
Dapper.Tests.Performance
{
[
Description
(
"ServiceStack"
)]
public
class
ServiceStackBenchmarks
:
BenchmarkBase
{
private
IDbConnection
_db
;
...
...
@@ -16,11 +18,11 @@ public void Setup()
_db
=
dbFactory
.
Open
();
}
[
Benchmark
(
Description
=
"SingleById"
)]
[
Benchmark
(
Description
=
"SingleById
<T>
"
)]
public
Post
Query
()
{
Step
();
return
_db
.
SingleById
<
Post
>(
i
);
}
}
}
\ No newline at end of file
}
Dapper.Tests.Performance/Benchmarks.Susanoo.cs
View file @
0ec089b7
using
BenchmarkDotNet.Attributes
;
using
BenchmarkDotNet.Attributes
;
using
Susanoo
;
using
Susanoo.Processing
;
using
System.ComponentModel
;
using
System.Data
;
using
System.Linq
;
namespace
Dapper.Tests.Performance
{
[
Description
(
"Susanoo"
)]
public
class
SusanooBenchmarks
:
BenchmarkBase
{
private
DatabaseManager
_db
;
private
static
readonly
ISingleResultSetCommandProcessor
<
dynamic
,
Post
>
_cmd
=
CommandManager
.
Instance
.
DefineCommand
(
"SELECT * FROM Posts WHERE Id = @Id"
,
CommandType
.
Text
)
.
DefineResults
<
Post
>()
.
Realize
();
private
static
readonly
ISingleResultSetCommandProcessor
<
dynamic
,
dynamic
>
_cmdDynamic
=
CommandManager
.
Instance
.
DefineCommand
(
"SELECT * FROM Posts WHERE Id = @Id"
,
CommandType
.
Text
)
.
DefineResults
<
dynamic
>()
...
...
@@ -25,7 +29,7 @@ public void Setup()
_db
=
new
DatabaseManager
(
_connection
);
}
[
Benchmark
(
Description
=
"
Mapping Cache
"
)]
[
Benchmark
(
Description
=
"
Execute<T> (Cache)
"
)]
public
Post
MappingCache
()
{
Step
();
...
...
@@ -35,7 +39,7 @@ public Post MappingCache()
.
Execute
(
_db
,
new
{
Id
=
i
}).
First
();
}
[
Benchmark
(
Description
=
"
Mapping Cache (dynamic
)"
)]
[
Benchmark
(
Description
=
"
Execute<dynamic> (Cache
)"
)]
public
dynamic
MappingCacheDynamic
()
{
Step
();
...
...
@@ -45,18 +49,18 @@ public dynamic MappingCacheDynamic()
.
Execute
(
_db
,
new
{
Id
=
i
}).
First
();
}
[
Benchmark
(
Description
=
"
Mapping Static
"
)]
[
Benchmark
(
Description
=
"
Execute<T> (Static)
"
)]
public
Post
MappingStatic
()
{
Step
();
return
_cmd
.
Execute
(
_db
,
new
{
Id
=
i
}).
First
();
}
[
Benchmark
(
Description
=
"
Mapping Static (dynam
ic)"
)]
[
Benchmark
(
Description
=
"
Execut<dynamic> (Stat
ic)"
)]
public
dynamic
MappingStaticDynamic
()
{
Step
();
return
_cmdDynamic
.
Execute
(
_db
,
new
{
Id
=
i
}).
First
();
}
}
}
\ No newline at end of file
}
Dapper.Tests.Performance/Helpers/ORMColum.cs
View file @
0ec089b7
using
BenchmarkDotNet.Columns
;
using
System.ComponentModel
;
using
System.Reflection
;
using
BenchmarkDotNet.Columns
;
using
BenchmarkDotNet.Reports
;
using
BenchmarkDotNet.Running
;
...
...
@@ -11,7 +13,12 @@ public class ORMColum : IColumn
public
string
Legend
=>
"The object/relational mapper being tested"
;
public
bool
IsDefault
(
Summary
summary
,
BenchmarkCase
benchmarkCase
)
=>
false
;
public
string
GetValue
(
Summary
summary
,
BenchmarkCase
benchmarkCase
)
=>
benchmarkCase
.
Descriptor
.
WorkloadMethod
.
DeclaringType
.
Name
.
Replace
(
"Benchmarks"
,
string
.
Empty
);
public
string
GetValue
(
Summary
summary
,
BenchmarkCase
benchmarkCase
)
{
var
type
=
benchmarkCase
.
Descriptor
.
WorkloadMethod
.
DeclaringType
;
return
type
.
GetCustomAttribute
<
DescriptionAttribute
>()?.
Description
??
type
.
Name
.
Replace
(
"Benchmarks"
,
string
.
Empty
);
}
public
string
GetValue
(
Summary
summary
,
BenchmarkCase
benchmarkCase
,
ISummaryStyle
style
)
=>
GetValue
(
summary
,
benchmarkCase
);
public
bool
IsAvailable
(
Summary
summary
)
=>
true
;
...
...
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