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
98c94c56
Commit
98c94c56
authored
Sep 14, 2017
by
Nick Craver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Misc build analyzer fixups
parent
071a3fd5
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
17 additions
and
13 deletions
+17
-13
Benchmarks.Dapper.cs
Dapper.Tests.Performance/Benchmarks.Dapper.cs
+3
-0
Benchmarks.NHibernate.cs
Dapper.Tests.Performance/Benchmarks.NHibernate.cs
+4
-4
LegacyTests.cs
Dapper.Tests.Performance/LegacyTests.cs
+2
-2
Massive.cs
Dapper.Tests.Performance/Massive/Massive.cs
+3
-3
PetaPoco.cs
Dapper.Tests.Performance/PetaPoco/PetaPoco.cs
+4
-4
Program.cs
Dapper.Tests.Performance/Program.cs
+1
-0
No files found.
Dapper.Tests.Performance/Benchmarks.Dapper.cs
View file @
98c94c56
...
@@ -18,6 +18,7 @@ public Post QueryBuffered()
...
@@ -18,6 +18,7 @@ public Post QueryBuffered()
Step
();
Step
();
return
_connection
.
Query
<
Post
>(
"select * from Posts where Id = @Id"
,
new
{
Id
=
i
},
buffered
:
true
).
First
();
return
_connection
.
Query
<
Post
>(
"select * from Posts where Id = @Id"
,
new
{
Id
=
i
},
buffered
:
true
).
First
();
}
}
[
Benchmark
(
Description
=
"Query<dyanmic> (buffered)"
)]
[
Benchmark
(
Description
=
"Query<dyanmic> (buffered)"
)]
public
dynamic
QueryBufferedDynamic
()
public
dynamic
QueryBufferedDynamic
()
{
{
...
@@ -31,6 +32,7 @@ public Post QueryUnbuffered()
...
@@ -31,6 +32,7 @@ public Post QueryUnbuffered()
Step
();
Step
();
return
_connection
.
Query
<
Post
>(
"select * from Posts where Id = @Id"
,
new
{
Id
=
i
},
buffered
:
false
).
First
();
return
_connection
.
Query
<
Post
>(
"select * from Posts where Id = @Id"
,
new
{
Id
=
i
},
buffered
:
false
).
First
();
}
}
[
Benchmark
(
Description
=
"Query<dyanmic> (unbuffered)"
)]
[
Benchmark
(
Description
=
"Query<dyanmic> (unbuffered)"
)]
public
dynamic
QueryUnbufferedDynamic
()
public
dynamic
QueryUnbufferedDynamic
()
{
{
...
@@ -44,6 +46,7 @@ public Post QueryFirstOrDefault()
...
@@ -44,6 +46,7 @@ public Post QueryFirstOrDefault()
Step
();
Step
();
return
_connection
.
QueryFirstOrDefault
<
Post
>(
"select * from Posts where Id = @Id"
,
new
{
Id
=
i
});
return
_connection
.
QueryFirstOrDefault
<
Post
>(
"select * from Posts where Id = @Id"
,
new
{
Id
=
i
});
}
}
[
Benchmark
(
Description
=
"QueryFirstOrDefault<dyanmic>"
)]
[
Benchmark
(
Description
=
"QueryFirstOrDefault<dyanmic>"
)]
public
dynamic
QueryFirstOrDefaultDynamic
()
public
dynamic
QueryFirstOrDefaultDynamic
()
{
{
...
...
Dapper.Tests.Performance/Benchmarks.NHibernate.cs
View file @
98c94c56
using
BenchmarkDotNet.Attributes
;
using
BenchmarkDotNet.Attributes
;
using
Dapper.Tests.Performance.NHibernate
;
using
Dapper.Tests.Performance.NHibernate
;
using
NHibernate
;
using
NHibernate
;
using
NHibernate.Criterion
;
using
NHibernate.Criterion
;
...
@@ -28,7 +28,7 @@ public void Setup()
...
@@ -28,7 +28,7 @@ public void Setup()
public
Post
SQL
()
public
Post
SQL
()
{
{
Step
();
Step
();
return
_sql
.
CreateSQLQuery
(
@
"select * from Posts where Id = :id"
)
return
_sql
.
CreateSQLQuery
(
"select * from Posts where Id = :id"
)
.
SetInt32
(
"id"
,
i
)
.
SetInt32
(
"id"
,
i
)
.
SetResultTransformer
(
Transformers
.
AliasToBean
<
Post
>())
.
SetResultTransformer
(
Transformers
.
AliasToBean
<
Post
>())
.
List
<
Post
>()[
0
];
.
List
<
Post
>()[
0
];
...
@@ -38,7 +38,7 @@ public Post SQL()
...
@@ -38,7 +38,7 @@ public Post SQL()
public
Post
HQL
()
public
Post
HQL
()
{
{
Step
();
Step
();
return
_hql
.
CreateQuery
(
@
"from Post as p where p.Id = :id"
)
return
_hql
.
CreateQuery
(
"from Post as p where p.Id = :id"
)
.
SetInt32
(
"id"
,
i
)
.
SetInt32
(
"id"
,
i
)
.
List
<
Post
>()[
0
];
.
List
<
Post
>()[
0
];
}
}
...
...
Dapper.Tests.Performance/LegacyTests.cs
View file @
98c94c56
...
@@ -210,12 +210,12 @@ public async Task RunAsync(int iterations)
...
@@ -210,12 +210,12 @@ public async Task RunAsync(int iterations)
Try
(()
=>
Try
(()
=>
{
{
var
nhSession1
=
NHibernateHelper
.
OpenSession
();
var
nhSession1
=
NHibernateHelper
.
OpenSession
();
tests
.
Add
(
id
=>
nhSession1
.
CreateSQLQuery
(
@
"select * from Posts where Id = :id"
)
tests
.
Add
(
id
=>
nhSession1
.
CreateSQLQuery
(
"select * from Posts where Id = :id"
)
.
SetInt32
(
"id"
,
id
)
.
SetInt32
(
"id"
,
id
)
.
List
(),
"NHibernate: SQL"
);
.
List
(),
"NHibernate: SQL"
);
var
nhSession2
=
NHibernateHelper
.
OpenSession
();
var
nhSession2
=
NHibernateHelper
.
OpenSession
();
tests
.
Add
(
id
=>
nhSession2
.
CreateQuery
(
@
"from Post as p where p.Id = :id"
)
tests
.
Add
(
id
=>
nhSession2
.
CreateQuery
(
"from Post as p where p.Id = :id"
)
.
SetInt32
(
"id"
,
id
)
.
SetInt32
(
"id"
,
id
)
.
List
(),
"NHibernate: HQL"
);
.
List
(),
"NHibernate: HQL"
);
...
...
Dapper.Tests.Performance/Massive/Massive.cs
View file @
98c94c56
...
@@ -409,7 +409,7 @@ public virtual IEnumerable<dynamic> All(string where = "", string orderBy = "",
...
@@ -409,7 +409,7 @@ public virtual IEnumerable<dynamic> All(string where = "", string orderBy = "",
string
sql
=
limit
>
0
?
"SELECT TOP "
+
limit
+
" {0} FROM {1} "
:
"SELECT {0} FROM {1} "
;
string
sql
=
limit
>
0
?
"SELECT TOP "
+
limit
+
" {0} FROM {1} "
:
"SELECT {0} FROM {1} "
;
if
(!
string
.
IsNullOrEmpty
(
where
))
if
(!
string
.
IsNullOrEmpty
(
where
))
sql
+=
where
.
Trim
().
StartsWith
(
"where"
,
StringComparison
.
CurrentCultureIgnoreCase
)
?
where
:
"WHERE "
+
where
;
sql
+=
where
.
Trim
().
StartsWith
(
"where"
,
StringComparison
.
CurrentCultureIgnoreCase
)
?
where
:
"WHERE "
+
where
;
if
(!
S
tring
.
IsNullOrEmpty
(
orderBy
))
if
(!
s
tring
.
IsNullOrEmpty
(
orderBy
))
sql
+=
orderBy
.
Trim
().
StartsWith
(
"order by"
,
StringComparison
.
CurrentCultureIgnoreCase
)
?
orderBy
:
" ORDER BY "
+
orderBy
;
sql
+=
orderBy
.
Trim
().
StartsWith
(
"order by"
,
StringComparison
.
CurrentCultureIgnoreCase
)
?
orderBy
:
" ORDER BY "
+
orderBy
;
return
Query
(
string
.
Format
(
sql
,
columns
,
TableName
),
args
);
return
Query
(
string
.
Format
(
sql
,
columns
,
TableName
),
args
);
}
}
...
@@ -421,7 +421,7 @@ public virtual dynamic Paged(string where = "", string orderBy = "", string colu
...
@@ -421,7 +421,7 @@ public virtual dynamic Paged(string where = "", string orderBy = "", string colu
{
{
dynamic
result
=
new
ExpandoObject
();
dynamic
result
=
new
ExpandoObject
();
var
countSQL
=
string
.
Format
(
"SELECT COUNT({0}) FROM {1}"
,
PrimaryKeyField
,
TableName
);
var
countSQL
=
string
.
Format
(
"SELECT COUNT({0}) FROM {1}"
,
PrimaryKeyField
,
TableName
);
if
(
S
tring
.
IsNullOrEmpty
(
orderBy
))
if
(
s
tring
.
IsNullOrEmpty
(
orderBy
))
orderBy
=
PrimaryKeyField
;
orderBy
=
PrimaryKeyField
;
if
(!
string
.
IsNullOrEmpty
(
where
))
if
(!
string
.
IsNullOrEmpty
(
where
))
...
...
Dapper.Tests.Performance/PetaPoco/PetaPoco.cs
View file @
98c94c56
...
@@ -1399,17 +1399,17 @@ public Sql Where(string sql, params object[] args)
...
@@ -1399,17 +1399,17 @@ public Sql Where(string sql, params object[] args)
public
Sql
OrderBy
(
params
object
[]
args
)
public
Sql
OrderBy
(
params
object
[]
args
)
{
{
return
Append
(
new
Sql
(
"ORDER BY "
+
S
tring
.
Join
(
", "
,
(
from
x
in
args
select
x
.
ToString
()).
ToArray
())));
return
Append
(
new
Sql
(
"ORDER BY "
+
s
tring
.
Join
(
", "
,
(
from
x
in
args
select
x
.
ToString
()).
ToArray
())));
}
}
public
Sql
Select
(
params
object
[]
args
)
public
Sql
Select
(
params
object
[]
args
)
{
{
return
Append
(
new
Sql
(
"SELECT "
+
S
tring
.
Join
(
", "
,
(
from
x
in
args
select
x
.
ToString
()).
ToArray
())));
return
Append
(
new
Sql
(
"SELECT "
+
s
tring
.
Join
(
", "
,
(
from
x
in
args
select
x
.
ToString
()).
ToArray
())));
}
}
public
Sql
From
(
params
object
[]
args
)
public
Sql
From
(
params
object
[]
args
)
{
{
return
Append
(
new
Sql
(
"FROM "
+
S
tring
.
Join
(
", "
,
(
from
x
in
args
select
x
.
ToString
()).
ToArray
())));
return
Append
(
new
Sql
(
"FROM "
+
s
tring
.
Join
(
", "
,
(
from
x
in
args
select
x
.
ToString
()).
ToArray
())));
}
}
private
static
bool
Is
(
Sql
sql
,
string
sqltype
)
private
static
bool
Is
(
Sql
sql
,
string
sqltype
)
...
@@ -1419,7 +1419,7 @@ private static bool Is(Sql sql, string sqltype)
...
@@ -1419,7 +1419,7 @@ private static bool Is(Sql sql, string sqltype)
public
void
Build
(
StringBuilder
sb
,
List
<
object
>
args
,
Sql
lhs
)
public
void
Build
(
StringBuilder
sb
,
List
<
object
>
args
,
Sql
lhs
)
{
{
if
(!
S
tring
.
IsNullOrEmpty
(
_sql
))
if
(!
s
tring
.
IsNullOrEmpty
(
_sql
))
{
{
// Add SQL to the string
// Add SQL to the string
if
(
sb
.
Length
>
0
)
if
(
sb
.
Length
>
0
)
...
...
Dapper.Tests.Performance/Program.cs
View file @
98c94c56
...
@@ -111,6 +111,7 @@ public static void WriteLineColor(string message, ConsoleColor color)
...
@@ -111,6 +111,7 @@ public static void WriteLineColor(string message, ConsoleColor color)
WriteLine
(
message
);
WriteLine
(
message
);
ForegroundColor
=
orig
;
ForegroundColor
=
orig
;
}
}
public
static
void
WriteColor
(
string
message
,
ConsoleColor
color
)
public
static
void
WriteColor
(
string
message
,
ConsoleColor
color
)
{
{
var
orig
=
ForegroundColor
;
var
orig
=
ForegroundColor
;
...
...
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