Talk about ORM performance (continued) Moon. ORM4.1 revision release

Source: Internet
Author: User
This version uses a brand new data acquisition engine, which combines automatic compilation with dynamic proxy, and effectively improves performance. The following data shows: currently, except for pure ADO.net, moon's performance is almost the highest among all orm currently. Regarding fish, I reiterate that the main purpose is to refute its statement of higher performance than that of pure ADO. I admit that the test results on that day are relatively floating. Maybe we can say that day is slightly lower than fish. today, I have no point but to try again.

/*
* The test code is as follows:
*/
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 ;}

// Note: the customer information may be 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;
// Configure ClownFish
ClownFish. DbContext. RegisterDbConnectionInfo ("default", setting. ProviderName, "@", setting. ConnectionString );
Type [] types = ClownFish. BuildManager. FindModelTypesFromCurrentApplication (x => x. Namespace = "TestFish ");
ClownFish. BuildManager. CompileModelTypesSync (types, true );
// Configure FishWebLib
FishWebLib. FishDbContext. Init (setting. ProviderName, "@", setting. ConnectionString );
}
Public static SqlConnection GetSqlConnection ()
{
Var connection = new SqlConnection (ConfigurationManager. receivettings ["linkString"]);
Connection. Open ();
Return connection;
}

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 MERs c on d. CustomerId = c. CustomerId
";
Public static void Main (string [] args)
{
// ------------- Ignore these questions
Var t1 = DateTime. Now. Ticks;
AppInit ();
Db = new ClownFish. DbContext (false );
Var parameter = new {TopN = 1000 };
Var list = ClownFish. DbHelper. FillList <OrderInfo> (
QueryText2, parameter, 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 );
// Configure //--------------------------------------------------------------------------------------

// -------------------- The previous one is not counted. Let's officially start
Var tFish1 = DateTime. Now. Ticks;
For (int I = 0; I <2000; I ++ ){
Var listFish = ClownFish. DbHelper. FillList <OrderInfo> (
QueryText2, null, db, ClownFish. CommandKind. SqlTextNoParams );
}

Var tFish2 = DateTime. Now. Ticks;
Console. WriteLine ("ainemo time:" + (tFish2-tFish1 ));

Var tMoon1 = DateTime. Now. Ticks;
For (int I = 0; I <2000; I ++ ){
Var listMoon = DBFactory. GetEntities <OrderInfo> (QueryText2 );
}
Var tMoon2 = DateTime. Now. Ticks;
Console. WriteLine ("MOON time:" + (tMoon2-tMoon1 ));
SqlConnection connection = Program. GetSqlConnection ();
Var tRapper1 = DateTime. Now. Ticks;
For (int I = 0; I <2000; I ++ ){
Var listRapper = connection. Query <OrderInfo> (QueryText2, null). ToList <OrderInfo> ();
}
Var tRapper2 = DateTime. Now. Ticks;
Console. WriteLine ("datarapper time:" + (tRapper2-tRapper1 ));
Console. Write ("Press any key to continue ...");
Console. ReadKey (true );
}
}
}

Welcome to Public Beta./Files/humble/test project .zip

Moon details:

About MOON. ORM

QQ: 216965349

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.