Commit 37a49b4b authored by Marc Gravell's avatar Marc Gravell

Added "dnx perf" support in tests json; gave up on getting SUBSONIC

parent b9c5d5d8
#if !COREFX #if EXTERNALS
using NHibernate; using NHibernate;
using NHibernate.Cfg; using NHibernate.Cfg;
...@@ -15,9 +15,9 @@ private static ISessionFactory SessionFactory ...@@ -15,9 +15,9 @@ private static ISessionFactory SessionFactory
if (_sessionFactory == null) if (_sessionFactory == null)
{ {
var configuration = new Configuration(); var configuration = new Configuration();
configuration.Configure(@"..\..\NHibernate\hibernate.cfg.xml"); configuration.Configure(@"..\Dapper.Tests\NHibernate\hibernate.cfg.xml");
configuration.AddAssembly(typeof(Post).Assembly); configuration.AddAssembly(typeof(Post).Assembly);
configuration.AddXmlFile(@"..\..\NHibernate\Post.hbm.xml"); configuration.AddXmlFile(@"..\Dapper.Tests\NHibernate\Post.hbm.xml");
_sessionFactory = configuration.BuildSessionFactory(); _sessionFactory = configuration.BuildSessionFactory();
} }
......
<?xml version="1.0" encoding="utf-8" ?> <?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"> <class name="Post" table="Posts" schema="dbo">
<id name="Id" access="property" column="Id"> <id name="Id" access="property" column="Id">
<generator class="native" /> <generator class="native" />
......
...@@ -7,6 +7,6 @@ ...@@ -7,6 +7,6 @@
<property name="connection.connection_string_name">Smackdown.Properties.Settings.tempdbConnectionString</property> <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="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property>
<property name="cache.use_minimal_puts">false</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> </session-factory>
</hibernate-configuration> </hibernate-configuration>
\ No newline at end of file
#if EXTERNALS
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.Data.Linq;
using System.Data.SqlClient; using System.Data.SqlClient;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; 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 Massive;
using NHibernate.Criterion; using NHibernate.Criterion;
using NHibernate.Linq; using NHibernate.Linq;
using ServiceStack.OrmLite; using ServiceStack.OrmLite;
using ServiceStack.OrmLite.SqlServer; using ServiceStack.OrmLite.SqlServer;
using Dapper.Tests.Linq2Sql; using BLToolkit.Data;
using Dapper.Tests.NHibernate;
using Dapper.Contrib.Extensions;
using Dapper.Tests.EntityFramework; using Dapper.Tests.EntityFramework;
using Susanoo; using Susanoo;
using ServiceStack.OrmLite.Converters;
using ServiceStack.OrmLite.Dapper;
#endif
namespace Dapper.Tests namespace Dapper.Tests
{ {
...@@ -68,28 +76,31 @@ public void Run(int iterations) ...@@ -68,28 +76,31 @@ public void Run(int iterations)
} }
} }
} }
#if EXTERNALS
static DataClassesDataContext GetL2SContext(SqlConnection connection) static DataClassesDataContext GetL2SContext(SqlConnection connection)
{ {
return new DataClassesDataContext(connection); return new DataClassesDataContext(connection);
} }
internal class SomaConfig : Soma.Core.MsSqlConfig internal class SomaConfig : Soma.Core.MsSqlConfig
{ {
public override string ConnectionString => TestSuite.ConnectionString; 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) public void Run(int iterations)
{ {
using (var connection = TestSuite.GetOpenConnection()) using (var connection = TestSuite.GetOpenConnection())
{ {
var tests = new Tests(); var tests = new Tests();
#if EXTERNALS
var l2scontext1 = GetL2SContext(connection); var l2scontext1 = GetL2SContext(connection);
tests.Add(id => l2scontext1.Posts.First(p => p.Id == id), "Linq 2 SQL"); tests.Add(id => l2scontext1.Posts.First(p => p.Id == id), "Linq 2 SQL");
...@@ -115,7 +126,7 @@ public void Run(int iterations) ...@@ -115,7 +126,7 @@ public void Run(int iterations)
var entityContext5 = new EFContext(connection); var entityContext5 = new EFContext(connection);
tests.Add(id => entityContext5.Posts.AsNoTracking().First(p => p.Id == id), "Entity framework No Tracking"); tests.Add(id => entityContext5.Posts.AsNoTracking().First(p => p.Id == id), "Entity framework No Tracking");
#endif
var mapperConnection = TestSuite.GetOpenConnection(); 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: 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)"); 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) ...@@ -128,6 +139,8 @@ public void Run(int iterations)
var mapperConnection3 = TestSuite.GetOpenConnection(); var mapperConnection3 = TestSuite.GetOpenConnection();
tests.Add(id => mapperConnection3.Get<Post>(id), "Dapper.Cotrib"); tests.Add(id => mapperConnection3.Get<Post>(id), "Dapper.Cotrib");
#if EXTERNALS
// massive
var massiveModel = new DynamicModel(TestSuite.ConnectionString); var massiveModel = new DynamicModel(TestSuite.ConnectionString);
var massiveConnection = TestSuite.GetOpenConnection(); var massiveConnection = TestSuite.GetOpenConnection();
tests.Add(id => massiveModel.Query("select * from Posts where Id = @0", massiveConnection, id).First(), "Dynamic Massive ORM Query"); 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) ...@@ -145,15 +158,17 @@ public void Run(int iterations)
petapocoFast.ForceDateTimesToUtc = false; petapocoFast.ForceDateTimesToUtc = false;
tests.Add(id => petapocoFast.Fetch<Post>("SELECT * from Posts where Id=@0", id).First(), "PetaPoco (Fast)"); tests.Add(id => petapocoFast.Fetch<Post>("SELECT * from Posts where Id=@0", id).First(), "PetaPoco (Fast)");
#if SUBSONIC
// Subsonic ActiveRecord // Subsonic ActiveRecord
tests.Add(id => SubSonic.Post.SingleOrDefault(x => x.Id == id), "SubSonic ActiveRecord.SingleOrDefault"); tests.Add(id => SubSonic.Post.SingleOrDefault(x => x.Id == id), "SubSonic ActiveRecord.SingleOrDefault");
// Subsonic coding horror // Subsonic coding horror
SubSonic.tempdbDB db = new SubSonic.tempdbDB(); 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"); tests.Add(id => new SubSonic.Query.CodingHorror(db.Provider, "select * from Posts where Id = @0", id).ExecuteTypedList<Post>(), "SubSonic Coding Horror");
#endif
// NHibernate // NHibernate
#if NHIBERNATE
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)
...@@ -176,15 +191,16 @@ public void Run(int iterations) ...@@ -176,15 +191,16 @@ public void Run(int iterations)
var nhSession5 = NHibernateHelper.OpenSession(); var nhSession5 = NHibernateHelper.OpenSession();
tests.Add(id => nhSession5.Get<Post>(id), "NHibernate Session.Get"); tests.Add(id => nhSession5.Get<Post>(id), "NHibernate Session.Get");
#endif
// bltoolkit // bltoolkit
var db1 = new DbManager(TestSuite.GetOpenConnection()); var db1 = new DbManager(TestSuite.GetOpenConnection());
tests.Add(id => db1.SetCommand("select * from Posts where Id = @id", db1.Parameter("id", id)).ExecuteList<Post>(), "BLToolkit"); tests.Add(id => db1.SetCommand("select * from Posts where Id = @id", db1.Parameter("id", id)).ExecuteList<Post>(), "BLToolkit");
#if SIMPLEDATA
// Simple.Data // Simple.Data
var sdb = Simple.Data.Database.OpenConnection(TestSuite.ConnectionString); var sdb = Simple.Data.Database.OpenConnection(TestSuite.ConnectionString);
tests.Add(id => sdb.Posts.FindById(id), "Simple.Data"); tests.Add(id => sdb.Posts.FindById(id), "Simple.Data");
#endif
//Susanoo //Susanoo
var susanooDb = new DatabaseManager("Smackdown.Properties.Settings.tempdbConnectionString"); var susanooDb = new DatabaseManager("Smackdown.Properties.Settings.tempdbConnectionString");
var susanooDb2 = new DatabaseManager("Smackdown.Properties.Settings.tempdbConnectionString"); var susanooDb2 = new DatabaseManager("Smackdown.Properties.Settings.tempdbConnectionString");
...@@ -224,11 +240,13 @@ public void Run(int iterations) ...@@ -224,11 +240,13 @@ public void Run(int iterations)
// var somadb = new Soma.Core.Db(new SomaConfig()); // var somadb = new Soma.Core.Db(new SomaConfig());
// tests.Add(id => somadb.Find<Post>(id), "Soma"); // tests.Add(id => somadb.Find<Post>(id), "Soma");
#if ORMLITE
//ServiceStack's OrmLite: //ServiceStack's OrmLite:
OrmLiteConfig.DialectProvider = SqlServerOrmLiteDialectProvider.Instance; //Using SQL Server OrmLiteConfig.DialectProvider = SqlServerOrmLiteDialectProvider.Instance; //Using SQL Server
IDbCommand ormLiteCmd = TestSuite.GetOpenConnection().CreateCommand(); IDbCommand ormLiteCmd = TestSuite.GetOpenConnection().CreateCommand();
tests.Add(id => ormLiteCmd.QueryById<Post>(id), "OrmLite QueryById"); tests.Add(id => ormLiteCmd.QueryById<Post>(id), "OrmLite QueryById");
#endif
#endif // EXTERNALS
// HAND CODED // HAND CODED
var postCommand = new SqlCommand(); var postCommand = new SqlCommand();
...@@ -262,6 +280,7 @@ public void Run(int iterations) ...@@ -262,6 +280,7 @@ public void Run(int iterations)
} }
}, "hand coded"); }, "hand coded");
#if !COREFX
DataTable table = new DataTable DataTable table = new DataTable
{ {
Columns = Columns =
...@@ -292,7 +311,7 @@ public void Run(int iterations) ...@@ -292,7 +311,7 @@ public void Run(int iterations)
table.Rows.Add(values); table.Rows.Add(values);
} }
}, "DataTable via IDataReader.GetValues"); }, "DataTable via IDataReader.GetValues");
#endif
tests.Run(iterations); tests.Run(iterations);
} }
} }
...@@ -322,4 +341,3 @@ public static string GetNullableString(this SqlDataReader reader, int index) ...@@ -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
...@@ -30,10 +30,18 @@ class Program ...@@ -30,10 +30,18 @@ class Program
{ {
static void Main() 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(); EnsureDBSetup();
RunPerformanceTests(); RunPerformanceTests();
#endif
} }
private static void EnsureDBSetup() private static void EnsureDBSetup()
...@@ -87,14 +95,10 @@ insert Posts ([Text],CreationDate, LastChangeDate) values (replicate('x', 2000), ...@@ -87,14 +95,10 @@ insert Posts ([Text],CreationDate, LastChangeDate) values (replicate('x', 2000),
static void RunPerformanceTests() static void RunPerformanceTests()
{ {
#if PERF
var test = new PerformanceTests(); var test = new PerformanceTests();
const int iterations = 500; const int iterations = 500;
Console.WriteLine("Running {0} iterations that load up a post entity", iterations); Console.WriteLine("Running {0} iterations that load up a post entity", iterations);
test.Run(iterations); test.Run(iterations);
#else
Console.WriteLine("Performance tests have not been built; add the PERF symbol");
#endif
} }
} }
} }
...@@ -171,7 +171,7 @@ public async Task TestMultiClosedConnAsync() ...@@ -171,7 +171,7 @@ public async Task TestMultiClosedConnAsync()
public async Task ExecuteReaderOpenAsync() public async Task ExecuteReaderOpenAsync()
{ {
var dt = new DataTable(); var dt = new DataTable();
dt.Load(await conn.ExecuteReaderAsync("select 3 as [three], 4 as [four]")); dt.Load(await connection.ExecuteReaderAsync("select 3 as [three], 4 as [four]"));
dt.Columns.Count.IsEqualTo(2); dt.Columns.Count.IsEqualTo(2);
dt.Columns[0].ColumnName.IsEqualTo("three"); dt.Columns[0].ColumnName.IsEqualTo("three");
dt.Columns[1].ColumnName.IsEqualTo("four"); dt.Columns[1].ColumnName.IsEqualTo("four");
......
...@@ -114,7 +114,7 @@ static TestSuite() ...@@ -114,7 +114,7 @@ static TestSuite()
#endif #endif
Console.WriteLine("Dapper: " + typeof(SqlMapper).AssemblyQualifiedName); Console.WriteLine("Dapper: " + typeof(SqlMapper).AssemblyQualifiedName);
Console.WriteLine("Using Connectionstring: {0}", ConnectionString); Console.WriteLine("Using Connectionstring: {0}", ConnectionString);
#if EXTERNALS #if EXTERNALS && !DNX
Console.Write("Loading native assemblies for SQL types..."); Console.Write("Loading native assemblies for SQL types...");
Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory); Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory);
Console.WriteLine("done."); Console.WriteLine("done.");
...@@ -2804,7 +2804,7 @@ public void SO30435185_InvalidTypeOwner() ...@@ -2804,7 +2804,7 @@ public void SO30435185_InvalidTypeOwner()
} }
#if EXTERNALS #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() public void Issue178_Firebird()
{ {
var cs = @"initial catalog=localhost:database;user id=SYSDBA;password=masterkey"; var cs = @"initial catalog=localhost:database;user id=SYSDBA;password=masterkey";
......
...@@ -11,9 +11,13 @@ ...@@ -11,9 +11,13 @@
"Dapper": { "Dapper": {
"version": "1.50-*", "version": "1.50-*",
"target": "project" "target": "project"
},
"Dapper.Contrib": {
"target": "project"
} }
}, },
"commands": { "commands": {
"perf": "Dapper.Tests",
"test": "xunit.runner.dnx" "test": "xunit.runner.dnx"
}, },
"compilationOptions": { "compilationOptions": {
...@@ -71,7 +75,7 @@ ...@@ -71,7 +75,7 @@
}, },
"dnx451": { "dnx451": {
"compilationOptions": { "compilationOptions": {
"define": [ "ASYNC" ] "define": [ "ASYNC", "EXTERNALS", "DNX" ]
}, },
"frameworkAssemblies": { "frameworkAssemblies": {
"System.Configuration": "4.0.0.0", "System.Configuration": "4.0.0.0",
...@@ -79,16 +83,32 @@ ...@@ -79,16 +83,32 @@
}, },
"dependencies": { "dependencies": {
"NHibernate": "4.0.4.4000", "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": "4.0.48",
"ServiceStack.OrmLite.SqlServer": "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", "Soma": "1.8.0.7",
"xunit": "2.1.0", "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": { "dnxcore50": {
"compilationOptions": { "compilationOptions": {
"define": [ "COREFX", "ASYNC" ] "define": [ "COREFX", "ASYNC", "DNX" ]
}, },
"dependencies": { "dependencies": {
"xunit": "2.1.0", "xunit": "2.1.0",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment