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.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();
}
......
<?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" />
......
......@@ -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
#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
......@@ -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
}
}
}
......@@ -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 connection.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");
......
......@@ -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";
......
......@@ -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",
......
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