驳Fish的ORM性能问题.如有疑问大家公测.
一下是测试代码.代码采用fish给的.数据库也是他给的./Files/humble/TestFish.7z
//
/*
* 由SharpDevelop创建。
* 用户: Administrator
* 日期: 2012/8/20
* 时间: 10:50
*
* 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
*/
using System;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using ClownFish;
using Dapper;
using Moon.Orm;
namespace TestFish
{
public class OrderInfo
{
public int OrderID { get; set; }
public DateTime OrderDate { get; set; }
public decimal SumMoney { get; set; }
public string Comment { get; set; }
public bool Finished { get; set; }
public int ProductID { get; set; }
public decimal UnitPrice { get; set; }
public int Quantity { get; set; }
public string ProductName { get; set; }
public int CategoryID { get; set; }
public string Unit { get; set; }
public string Remark { get; set; }
// 注意:客户信息有可能会是DBNull
public int? CustomerID { get; set; }
public string CustomerName { get; set; }
public string ContactName { get; set; }
public string Address { get; set; }
public string PostalCode { get; set; }
public string Tel { get; set; }
}
class Program
{
static void AppInit()
{
ConnectionStringSettings setting = ConfigurationManager.ConnectionStrings["MyNorthwind"];
ConnectionString = setting.ConnectionString;
// 配置 ClownFish
ClownFish.DbContext.RegisterDbConnectionInfo("default", setting.ProviderName, "@", setting.ConnectionString);
Type[] types = ClownFish.BuildManager.FindModelTypesFromCurrentApplication(x => x.Namespace == "PerformanceTestApp.Model");
ClownFish.BuildManager.CompileModelTypesSync(types, true);
// 配置 FishWebLib
FishWebLib.FishDbContext.Init(setting.ProviderName, "@", setting.ConnectionString);
}
protected static string ConnectionString;
private static ClownFish.DbContext db;
public static readonly string QueryText2 = @"
select top (1000) d.OrderID, d.OrderDate, d.SumMoney, d.Comment, d.Finished,
dt.ProductID, dt.UnitPrice, dt.Quantity,
p.ProductName, p.CategoryID, p.Unit, p.Remark,
c.CustomerID, c.CustomerName, c.ContactName, c.Address, c.PostalCode, c.Tel
from Orders d
inner join [Order Details] dt on d.OrderId = dt.OrderId
inner join Products p on dt.ProductId = p.ProductId
left join Customers c on d.CustomerId = c.CustomerId
";
public static SqlConnection GetSqlConnection()
{
var connection = new SqlConnection(ConfigurationManager.AppSettings["linkString"]);
connection.Open();
return connection;
}
public static void Main(string[] args)
{
//-------------这些可以不理会
var t1=DateTime.Now.Ticks;
AppInit();
db = new ClownFish.DbContext(false);
var parameter = new { TopN =1000 };
var list= ClownFish.DbHelper.FillList<OrderInfo>(
QueryText2, null, db, ClownFish.CommandKind.SqlTextWithParams);
var t2=DateTime.Now.Ticks;
Console.WriteLine(t2-t1);
var t3=DateTime.Now.Ticks;
var list2=DBFactory.GetEntities<OrderInfo>(QueryText2);
var t4=DateTime.Now.Ticks;
Console.WriteLine(t4-t3);
SqlConnection connection = Program.GetSqlConnection();
//--------------------------------------------------------------------------------------
var dd = connection.Query<OrderInfo>(QueryText2, null).ToList<OrderInfo>();
//--------------------前面的可以不算,咱们正式开始
var tFish1=DateTime.Now.Ticks;
for (int i = 0; i < 1000; i++) {
var listFish= ClownFish.DbHelper.FillList<OrderInfo>(
QueryText2, null, db, ClownFish.CommandKind.SqlTextWithParams);
}
var tFish2=DateTime.Now.Ticks;
Console.WriteLine("小鱼的时间:"+(tFish2-tFish1));
//------------------
var tMoon1=DateTime.Now.Ticks;
for (int i = 0; i < 1000; i++) {
var listMoon=DBFactory.GetEntities<OrderInfo>(QueryText2);
}
var tMoon2=DateTime.Now.Ticks;
Console.WriteLine("MOON的时间:"+(tMoon2-tMoon1));
var tRapper1=DateTime.Now.Ticks;
for (int i = 0; i < 1000; i++) {
var listRapper = connection.Query<OrderInfo>(QueryText2, null).ToList<OrderInfo>();
}
var tRapper2=DateTime.Now.Ticks;
Console.WriteLine("datarapper的时间:"+(tRapper2-tRapper1));
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
}
* 由SharpDevelop创建。
* 用户: Administrator
* 日期: 2012/8/20
* 时间: 10:50
*
* 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
*/
using System;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using ClownFish;
using Dapper;
using Moon.Orm;
namespace TestFish
{
public class OrderInfo
{
public int OrderID { get; set; }
public DateTime OrderDate { get; set; }
public decimal SumMoney { get; set; }
public string Comment { get; set; }
public bool Finished { get; set; }
public int ProductID { get; set; }
public decimal UnitPrice { get; set; }
public int Quantity { get; set; }
public string ProductName { get; set; }
public int CategoryID { get; set; }
public string Unit { get; set; }
public string Remark { get; set; }
// 注意:客户信息有可能会是DBNull
public int? CustomerID { get; set; }
public string CustomerName { get; set; }
public string ContactName { get; set; }
public string Address { get; set; }
public string PostalCode { get; set; }
public string Tel { get; set; }
}
class Program
{
static void AppInit()
{
ConnectionStringSettings setting = ConfigurationManager.ConnectionStrings["MyNorthwind"];
ConnectionString = setting.ConnectionString;
// 配置 ClownFish
ClownFish.DbContext.RegisterDbConnectionInfo("default", setting.ProviderName, "@", setting.ConnectionString);
Type[] types = ClownFish.BuildManager.FindModelTypesFromCurrentApplication(x => x.Namespace == "PerformanceTestApp.Model");
ClownFish.BuildManager.CompileModelTypesSync(types, true);
// 配置 FishWebLib
FishWebLib.FishDbContext.Init(setting.ProviderName, "@", setting.ConnectionString);
}
protected static string ConnectionString;
private static ClownFish.DbContext db;
public static readonly string QueryText2 = @"
select top (1000) d.OrderID, d.OrderDate, d.SumMoney, d.Comment, d.Finished,
dt.ProductID, dt.UnitPrice, dt.Quantity,
p.ProductName, p.CategoryID, p.Unit, p.Remark,
c.CustomerID, c.CustomerName, c.ContactName, c.Address, c.PostalCode, c.Tel
from Orders d
inner join [Order Details] dt on d.OrderId = dt.OrderId
inner join Products p on dt.ProductId = p.ProductId
left join Customers c on d.CustomerId = c.CustomerId
";
public static SqlConnection GetSqlConnection()
{
var connection = new SqlConnection(ConfigurationManager.AppSettings["linkString"]);
connection.Open();
return connection;
}
public static void Main(string[] args)
{
//-------------这些可以不理会
var t1=DateTime.Now.Ticks;
AppInit();
db = new ClownFish.DbContext(false);
var parameter = new { TopN =1000 };
var list= ClownFish.DbHelper.FillList<OrderInfo>(
QueryText2, null, db, ClownFish.CommandKind.SqlTextWithParams);
var t2=DateTime.Now.Ticks;
Console.WriteLine(t2-t1);
var t3=DateTime.Now.Ticks;
var list2=DBFactory.GetEntities<OrderInfo>(QueryText2);
var t4=DateTime.Now.Ticks;
Console.WriteLine(t4-t3);
SqlConnection connection = Program.GetSqlConnection();
//--------------------------------------------------------------------------------------
var dd = connection.Query<OrderInfo>(QueryText2, null).ToList<OrderInfo>();
//--------------------前面的可以不算,咱们正式开始
var tFish1=DateTime.Now.Ticks;
for (int i = 0; i < 1000; i++) {
var listFish= ClownFish.DbHelper.FillList<OrderInfo>(
QueryText2, null, db, ClownFish.CommandKind.SqlTextWithParams);
}
var tFish2=DateTime.Now.Ticks;
Console.WriteLine("小鱼的时间:"+(tFish2-tFish1));
//------------------
var tMoon1=DateTime.Now.Ticks;
for (int i = 0; i < 1000; i++) {
var listMoon=DBFactory.GetEntities<OrderInfo>(QueryText2);
}
var tMoon2=DateTime.Now.Ticks;
Console.WriteLine("MOON的时间:"+(tMoon2-tMoon1));
var tRapper1=DateTime.Now.Ticks;
for (int i = 0; i < 1000; i++) {
var listRapper = connection.Query<OrderInfo>(QueryText2, null).ToList<OrderInfo>();
}
var tRapper2=DateTime.Now.Ticks;
Console.WriteLine("datarapper的时间:"+(tRapper2-tRapper1));
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
}
测试结果图:
//
少侠,我看你气度不凡天赋异禀,骨骼精奇,这么帅,来了就帮推荐一把吧
我的最近更新