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
37a49b4b
Commit
37a49b4b
authored
Nov 25, 2015
by
Marc Gravell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added "dnx perf" support in tests json; gave up on getting SUBSONIC
parent
b9c5d5d8
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
79 additions
and
37 deletions
+79
-37
NHibernateHelper.cs
Dapper.Tests/NHibernate/NHibernateHelper.cs
+3
-3
Post.hbm.xml
Dapper.Tests/NHibernate/Post.hbm.xml
+1
-1
hibernate.cfg.xml
Dapper.Tests/NHibernate/hibernate.cfg.xml
+1
-1
PerformanceTests.cs
Dapper.Tests/PerformanceTests.cs
+38
-20
Program.cs
Dapper.Tests/Program.cs
+10
-6
Tests.Async.cs
Dapper.Tests/Tests.Async.cs
+1
-1
Tests.cs
Dapper.Tests/Tests.cs
+2
-2
project.json
Dapper.Tests/project.json
+23
-3
No files found.
Dapper.Tests/NHibernate/NHibernateHelper.cs
View file @
37a49b4b
#
if
!
COREFX
#
if
EXTERNALS
using
NHibernate
;
using
NHibernate.Cfg
;
...
...
@@ -15,9 +15,9 @@ private static ISessionFactory SessionFactory
if
(
_sessionFactory
==
null
)
{
var
configuration
=
new
Configuration
();
configuration
.
Configure
(
@"..\
..
\NHibernate\hibernate.cfg.xml"
);
configuration
.
Configure
(
@"..\
Dapper.Tests
\NHibernate\hibernate.cfg.xml"
);
configuration
.
AddAssembly
(
typeof
(
Post
).
Assembly
);
configuration
.
AddXmlFile
(
@"..\
..
\NHibernate\Post.hbm.xml"
);
configuration
.
AddXmlFile
(
@"..\
Dapper.Tests
\NHibernate\Post.hbm.xml"
);
_sessionFactory
=
configuration
.
BuildSessionFactory
();
}
...
...
Dapper.Tests/NHibernate/Post.hbm.xml
View file @
37a49b4b
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping
namespace=
"
SqlMapper"
assembly=
"Smackdown
"
xmlns=
"urn:nhibernate-mapping-2.2"
default-lazy=
"false"
>
<hibernate-mapping
namespace=
"
Dapper.Tests"
assembly=
"Dapper.Tests
"
xmlns=
"urn:nhibernate-mapping-2.2"
default-lazy=
"false"
>
<class
name=
"Post"
table=
"Posts"
schema=
"dbo"
>
<id
name=
"Id"
access=
"property"
column=
"Id"
>
<generator
class=
"native"
/>
...
...
Dapper.Tests/NHibernate/hibernate.cfg.xml
View file @
37a49b4b
...
...
@@ -7,6 +7,6 @@
<property
name=
"connection.connection_string_name"
>
Smackdown.Properties.Settings.tempdbConnectionString
</property>
<property
name=
"proxyfactory.factory_class"
>
NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu
</property>
<property
name=
"cache.use_minimal_puts"
>
false
</property>
<
property
name=
"use_outer_join"
>
false
</property
>
<
!--<property name="use_outer_join">false</property>--
>
</session-factory>
</hibernate-configuration>
\ No newline at end of file
Dapper.Tests/PerformanceTests.cs
View file @
37a49b4b
#if EXTERNALS
using
System
;
using
System.Collections.Generic
;
using
System.Data
;
using
System.Data.Linq
;
using
System.Data.SqlClient
;
using
System.Diagnostics
;
using
System.Linq
;
using
BLToolkit.Data
;
using
Dapper.Tests.Linq2Sql
;
using
Dapper.Contrib.Extensions
;
#if EXTERNALS
using
Soma.Core
;
using
Dapper.Tests.NHibernate
;
using
System.Data.Linq
;
using
Massive
;
using
NHibernate.Criterion
;
using
NHibernate.Linq
;
using
ServiceStack.OrmLite
;
using
ServiceStack.OrmLite.SqlServer
;
using
Dapper.Tests.Linq2Sql
;
using
Dapper.Tests.NHibernate
;
using
Dapper.Contrib.Extensions
;
using
BLToolkit.Data
;
using
Dapper.Tests.EntityFramework
;
using
Susanoo
;
using
ServiceStack.OrmLite.Converters
;
using
ServiceStack.OrmLite.Dapper
;
#endif
namespace
Dapper.Tests
{
...
...
@@ -68,28 +76,31 @@ public void Run(int iterations)
}
}
}
#if EXTERNALS
static
DataClassesDataContext
GetL2SContext
(
SqlConnection
connection
)
{
return
new
DataClassesDataContext
(
connection
);
}
internal
class
SomaConfig
:
Soma
.
Core
.
MsSqlConfig
{
public
override
string
ConnectionString
=>
TestSuite
.
ConnectionString
;
public
override
void
Log
(
Soma
.
Core
.
PreparedStatement
preparedStatement
)
public
override
Action
<
PreparedStatement
>
Logger
{
// no op
get
{
return
noOp
;
}
}
static
readonly
Action
<
PreparedStatement
>
noOp
=
x
=>
{
};
}
#endif
public
void
Run
(
int
iterations
)
{
using
(
var
connection
=
TestSuite
.
GetOpenConnection
())
{
var
tests
=
new
Tests
();
#if EXTERNALS
var
l2scontext1
=
GetL2SContext
(
connection
);
tests
.
Add
(
id
=>
l2scontext1
.
Posts
.
First
(
p
=>
p
.
Id
==
id
),
"Linq 2 SQL"
);
...
...
@@ -115,7 +126,7 @@ public void Run(int iterations)
var
entityContext5
=
new
EFContext
(
connection
);
tests
.
Add
(
id
=>
entityContext5
.
Posts
.
AsNoTracking
().
First
(
p
=>
p
.
Id
==
id
),
"Entity framework No Tracking"
);
#endif
var
mapperConnection
=
TestSuite
.
GetOpenConnection
();
tests
.
Add
(
id
=>
mapperConnection
.
Query
<
Post
>(
"select * from Posts where Id = @Id"
,
new
{
Id
=
id
},
buffered
:
true
).
First
(),
"Mapper Query (buffered)"
);
tests
.
Add
(
id
=>
mapperConnection
.
Query
<
Post
>(
"select * from Posts where Id = @Id"
,
new
{
Id
=
id
},
buffered
:
false
).
First
(),
"Mapper Query (non-buffered)"
);
...
...
@@ -128,6 +139,8 @@ public void Run(int iterations)
var
mapperConnection3
=
TestSuite
.
GetOpenConnection
();
tests
.
Add
(
id
=>
mapperConnection3
.
Get
<
Post
>(
id
),
"Dapper.Cotrib"
);
#if EXTERNALS
// massive
var
massiveModel
=
new
DynamicModel
(
TestSuite
.
ConnectionString
);
var
massiveConnection
=
TestSuite
.
GetOpenConnection
();
tests
.
Add
(
id
=>
massiveModel
.
Query
(
"select * from Posts where Id = @0"
,
massiveConnection
,
id
).
First
(),
"Dynamic Massive ORM Query"
);
...
...
@@ -145,15 +158,17 @@ public void Run(int iterations)
petapocoFast
.
ForceDateTimesToUtc
=
false
;
tests
.
Add
(
id
=>
petapocoFast
.
Fetch
<
Post
>(
"SELECT * from Posts where Id=@0"
,
id
).
First
(),
"PetaPoco (Fast)"
);
#if SUBSONIC
// Subsonic ActiveRecord
tests
.
Add
(
id
=>
SubSonic
.
Post
.
SingleOrDefault
(
x
=>
x
.
Id
==
id
),
"SubSonic ActiveRecord.SingleOrDefault"
);
// Subsonic coding horror
SubSonic
.
tempdbDB
db
=
new
SubSonic
.
tempdbDB
();
tests
.
Add
(
id
=>
new
SubSonic
.
Query
.
CodingHorror
(
db
.
Provider
,
"select * from Posts where Id = @0"
,
id
).
ExecuteTypedList
<
Post
>(),
"SubSonic Coding Horror"
);
#endif
// NHibernate
#if NHIBERNATE
var
nhSession1
=
NHibernateHelper
.
OpenSession
();
tests
.
Add
(
id
=>
nhSession1
.
CreateSQLQuery
(
@"select * from Posts where Id = :id"
)
.
SetInt32
(
"id"
,
id
)
...
...
@@ -176,15 +191,16 @@ public void Run(int iterations)
var
nhSession5
=
NHibernateHelper
.
OpenSession
();
tests
.
Add
(
id
=>
nhSession5
.
Get
<
Post
>(
id
),
"NHibernate Session.Get"
);
#endif
// bltoolkit
var
db1
=
new
DbManager
(
TestSuite
.
GetOpenConnection
());
tests
.
Add
(
id
=>
db1
.
SetCommand
(
"select * from Posts where Id = @id"
,
db1
.
Parameter
(
"id"
,
id
)).
ExecuteList
<
Post
>(),
"BLToolkit"
);
#if SIMPLEDATA
// Simple.Data
var
sdb
=
Simple
.
Data
.
Database
.
OpenConnection
(
TestSuite
.
ConnectionString
);
tests
.
Add
(
id
=>
sdb
.
Posts
.
FindById
(
id
),
"Simple.Data"
);
#endif
//Susanoo
var
susanooDb
=
new
DatabaseManager
(
"Smackdown.Properties.Settings.tempdbConnectionString"
);
var
susanooDb2
=
new
DatabaseManager
(
"Smackdown.Properties.Settings.tempdbConnectionString"
);
...
...
@@ -224,11 +240,13 @@ public void Run(int iterations)
// var somadb = new Soma.Core.Db(new SomaConfig());
// tests.Add(id => somadb.Find<Post>(id), "Soma");
#if ORMLITE
//ServiceStack's OrmLite:
OrmLiteConfig
.
DialectProvider
=
SqlServerOrmLiteDialectProvider
.
Instance
;
//Using SQL Server
IDbCommand
ormLiteCmd
=
TestSuite
.
GetOpenConnection
().
CreateCommand
();
tests
.
Add
(
id
=>
ormLiteCmd
.
QueryById
<
Post
>(
id
),
"OrmLite QueryById"
);
#endif
#endif // EXTERNALS
// HAND CODED
var
postCommand
=
new
SqlCommand
();
...
...
@@ -262,6 +280,7 @@ public void Run(int iterations)
}
},
"hand coded"
);
#if !COREFX
DataTable
table
=
new
DataTable
{
Columns
=
...
...
@@ -292,7 +311,7 @@ public void Run(int iterations)
table
.
Rows
.
Add
(
values
);
}
},
"DataTable via IDataReader.GetValues"
);
#endif
tests
.
Run
(
iterations
);
}
}
...
...
@@ -322,4 +341,3 @@ public static string GetNullableString(this SqlDataReader reader, int index)
}
}
}
\ No newline at end of file
#
endif
\ No newline at end of file
Dapper.Tests/Program.cs
View file @
37a49b4b
...
...
@@ -30,10 +30,18 @@ class Program
{
static
void
Main
()
{
#if !DEBUG
#if DEBUG
var
fg
=
Console
.
ForegroundColor
;
Console
.
ForegroundColor
=
ConsoleColor
.
Red
;
Console
.
WriteLine
(
"Warning: DEBUG configuration; performance may be impacted"
);
#if DNX
Console
.
WriteLine
(
"use: dnx --configuration release perf"
);
#endif
Console
.
ForegroundColor
=
fg
;
Console
.
WriteLine
();
#endif
EnsureDBSetup
();
RunPerformanceTests
();
#endif
}
private
static
void
EnsureDBSetup
()
...
...
@@ -87,14 +95,10 @@ insert Posts ([Text],CreationDate, LastChangeDate) values (replicate('x', 2000),
static
void
RunPerformanceTests
()
{
#if PERF
var
test
=
new
PerformanceTests
();
const
int
iterations
=
500
;
Console
.
WriteLine
(
"Running {0} iterations that load up a post entity"
,
iterations
);
test
.
Run
(
iterations
);
#else
Console
.
WriteLine
(
"Performance tests have not been built; add the PERF symbol"
);
#endif
}
}
}
Dapper.Tests/Tests.Async.cs
View file @
37a49b4b
...
...
@@ -171,7 +171,7 @@ public async Task TestMultiClosedConnAsync()
public
async
Task
ExecuteReaderOpenAsync
()
{
var
dt
=
new
DataTable
();
dt
.
Load
(
await
conn
.
ExecuteReaderAsync
(
"select 3 as [three], 4 as [four]"
));
dt
.
Load
(
await
conn
ection
.
ExecuteReaderAsync
(
"select 3 as [three], 4 as [four]"
));
dt
.
Columns
.
Count
.
IsEqualTo
(
2
);
dt
.
Columns
[
0
].
ColumnName
.
IsEqualTo
(
"three"
);
dt
.
Columns
[
1
].
ColumnName
.
IsEqualTo
(
"four"
);
...
...
Dapper.Tests/Tests.cs
View file @
37a49b4b
...
...
@@ -114,7 +114,7 @@ static TestSuite()
#endif
Console
.
WriteLine
(
"Dapper: "
+
typeof
(
SqlMapper
).
AssemblyQualifiedName
);
Console
.
WriteLine
(
"Using Connectionstring: {0}"
,
ConnectionString
);
#if EXTERNALS
#if EXTERNALS
&& !DNX
Console
.
Write
(
"Loading native assemblies for SQL types..."
);
Utilities
.
LoadNativeAssemblies
(
AppDomain
.
CurrentDomain
.
BaseDirectory
);
Console
.
WriteLine
(
"done."
);
...
...
@@ -2804,7 +2804,7 @@ public void SO30435185_InvalidTypeOwner()
}
#if EXTERNALS
[
Fact
(
Skip
=
Bug
in
Firebird
;
a
PR
to
fix
it
has
been
submitted
")]
[
Fact
(
Skip
=
"
Bug in Firebird; a PR to fix it has been submitted"
)]
public
void
Issue178_Firebird
()
{
var
cs
=
@"initial catalog=localhost:database;user id=SYSDBA;password=masterkey"
;
...
...
Dapper.Tests/project.json
View file @
37a49b4b
...
...
@@ -11,9 +11,13 @@
"Dapper"
:
{
"version"
:
"1.50-*"
,
"target"
:
"project"
},
"Dapper.Contrib"
:
{
"target"
:
"project"
}
},
"commands"
:
{
"perf"
:
"Dapper.Tests"
,
"test"
:
"xunit.runner.dnx"
},
"compilationOptions"
:
{
...
...
@@ -71,7 +75,7 @@
},
"dnx451"
:
{
"compilationOptions"
:
{
"define"
:
[
"ASYNC"
]
"define"
:
[
"ASYNC"
,
"EXTERNALS"
,
"DNX"
]
},
"frameworkAssemblies"
:
{
"System.Configuration"
:
"4.0.0.0"
,
...
...
@@ -79,16 +83,32 @@
},
"dependencies"
:
{
"NHibernate"
:
"4.0.4.4000"
,
"NHibernate.ByteCode.LinFu"
:
"1.1.0"
,
"NHibernate.ByteCode.Castle"
:
"3.3.3.4000"
,
"EntityFramework"
:
"6.1.3"
,
"ServiceStack.OrmLite"
:
"4.0.48"
,
"ServiceStack.OrmLite.SqlServer"
:
"4.0.48"
,
"Microsoft.SqlServer.Compact"
:
"4.0.8876.1"
,
"Microsoft.SqlServer.Types"
:
"11.0.2"
,
"Npgsql"
:
"2.1.0"
,
"Soma"
:
"1.8.0.7"
,
"xunit"
:
"2.1.0"
,
"xunit.runner.dnx"
:
"2.1.0-*"
"xunit.runner.dnx"
:
"2.1.0-*"
,
"BLToolkit"
:
"4.1.21"
,
"Susanoo.Core"
:
"0.8.4.36"
,
"SubSonic"
:
"3.0.0.4"
,
"Simple.Data.Core"
:
"2.0.0-alpha1"
,
"Simple.Data.SqlServer"
:
"2.0.0-alpha1"
,
"FirebirdSql.Data.FirebirdClient"
:
"4.8.1.1"
,
"Dapper.EntityFramework"
:
{
"target"
:
"project"
}
}
},
"dnxcore50"
:
{
"compilationOptions"
:
{
"define"
:
[
"COREFX"
,
"ASYNC"
]
"define"
:
[
"COREFX"
,
"ASYNC"
,
"DNX"
]
},
"dependencies"
:
{
"xunit"
:
"2.1.0"
,
...
...
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