Recently, some netizens have been paying attention to CYQ. Data performance issues. Although they have been paying attention to, they have not found anyone who has actively Written Performance Evaluation articles with other frameworks.
I am usually busy with writing a simple performance test for CYQ. Data for a long time.
Today, I wrote an article for it.
Miscellaneous:
When many people asked me about CYQ. Data performance, I said: it is better than other ORM frameworks.
Of course, I did not give any test data to prove it. Because I have never used other frameworks, I cannot give data, so I can only serve as a netizen: Believe it or not.
It is better than other frameworks. Of course, it is not because of the sweetness of melons, but based on the following Cognition:
The data framework is normally composed of these processes: encapsulate external representations-> Generate SQL-> call ADO. NET for execution.
Among them, the execution of ADO. NET is basically the same. Therefore, the performance difference of the Framework is manifested in the external form of encapsulation and the process of generating SQL. The performance difference depends mostly on the complexity of encapsulation.
CYQ. data is only packaged with one more layer on SQLHelper and adopts the native index form. Therefore, the speed of SQL encapsulation and generation is faster than other nhib.pdf and Spring. net, Entity Framework, and Linq.
Therefore, I will give a simple but not rigorous conclusion.
Note:
Since there is no habit of using other frameworks, we will not compare the evaluation with other frameworks.
Compared with native ADO. NET, CYQ. Data will be used to test the performance differences between the native framework and CYQ. Data.
People who know other frameworks, compared with native ADO. NET, can naturally find performance differences with CYQ. Data.
This test only writes data, and the test code is displayed later.
I. Write a loop call to insert data to see the result first.
1: Insert 10 data records:
2: insert 100 data records:
3: insert 1000 data records:
From the data in the above three figures, the temporary conclusion is as follows:
When the Data volume is small, the performance of CYQ. Data is superior to that of native ADO. NET.
As the Data volume increases, the performance of CYQ. Data begins to decline.
Conclusion:
This conclusion is confusing and even unlikely. There are several questions:
1: The CYQ. Data framework is encapsulated based on ADO. NET. How can it be executed faster than ADO. NET?
2: When CYQ. Data increases in the number of cycles, the performance will decrease?
3: Why is the MAction performance of CYQ. Data far worse than MProc?
Q &:
1: The transaction mechanism enabled by default by CYQ. Data, resulting in higher performance than the ADO. NET call without transactions in the example.
2: The DebugInfo attribute inside CYQ. Data is continuously executed by loop auto-increment records, resulting in a reduction in performance.
The difference between string and StringBuilder that people often test.
3: MAction has an internal anti-fill, that is, after the data is inserted, the data queried by ID is filled with downstream data, so the test is unfair to it.
Ii. Fair Test
CYQ. Data: Disable debugging information, close transactions, and MAction to disable anti-filling.
At the same time, to avoid performance impact caused by execution sequence, each of them is executed independently. After execution, the truncate table executes another one.
The output information cannot be seen because it is not executed together, and the results can only be copied separately.
The result is as follows:
1: Insert 10 data records:
ADO.net [ADO.net]: 0.15625 [seconds] -- 10
CYQ. Data [MProc #]: 0.171875 [seconds] -- 10
CYQ. Data [MAction]: 0.265625 [seconds] -- 10
2: insert 100 data records:
ADO.net [ADO.net]: 0.203125 [seconds] -- 100
CYQ. Data [MProc #]: 0.234375 [seconds] -- 100
CYQ. Data [MAction]: 0.3125 [seconds] -- 100
3: insert 1000 data records:
ADO.net [ADO.net]: 0.53125 [seconds] -- 1000
CYQ. Data [MProc #]: 0.859375 [seconds] -- 1000
CYQ. Data [MAction]: 1.015625 [seconds] -- 1000
From the above three groups of data, we can see that:
The performance of CYQ. Data is almost the same as that of ADO. NET. When the Data volume increases by 1000, it is only less than twice.
Therefore, CYQ. Data is similar to the original ADO. NET in terms of performance, because it does not encapsulate ADO. NET much.
It is only a simple encapsulation, but can be used so easily. This is the biggest advantage of distinguishing other frameworks.
Of course, this is only a small test and does not mean that the overall solution is rigorous.
However, in a certain aspect, I also gave some answers to some netizens who have doubts about the framework performance.
At least, it is worth it.
: Http://www.cyqdata.com/download/article-detail-426
Iii. Sample Code for testing:
1: original ADO. NETTest code:
Public static void ADO_NET ()
{
DateTime start = DateTime. Now;
SqlConnection con = new SqlConnection ("server = ..; database = abc; uid = sa; pwd = 123456 ");
SqlCommand com = new SqlCommand ();
Com. Connection = con;
Com. CommandText = "insert into Users (UserName, Password) values (@ UserName, @ Password )";
Con. Open ();
For (int I = 0; I <count; I ++)
{
Com. Parameters. Clear ();
Com. Parameters. AddWithValue ("@ UserName", "U _" + System. Threading. Thread. CurrentThread. ManagedThreadId );
Com. Parameters. AddWithValue ("@ Password", "P _" + I );
If (com. ExecuteNonQuery ()>-1)
{
Ok2 ++;
}
}
Con. Close ();
TimeSpan ts = DateTime. Now-start;
Console. WriteLine ("ADO.net [ADO.net]:" + ts. TotalSeconds + "[seconds] --" + ok2 );
}
2: MProc test code for CYQ. Data:
Public static void MProc ()
{
DateTime start = DateTime. Now;
MProc proc = new MProc ("insert into Users (UserName, Password) values (@ UserName, @ Password )");
Proc. EndTransation (); // close the transaction
For (int I = 0; I <count; I ++)
{
Proc. Clear ();
Proc. Set ("@ UserName", "U _" + System. Threading. Thread. CurrentThread. ManagedThreadId );
Proc. Set ("@ Password", "P _" + I );
If (proc. ExeNonQuery ()>-1)
{
Ok3 ++;
}
}
Proc. Close ();
TimeSpan ts = DateTime. Now-start;
Console. WriteLine ("CYQ. Data [MProc #]:" + ts. TotalSeconds + "[seconds] --" + ok3 );
}
3: MAction test code for CYQ. Data:
Public static void MAction ()
{
DateTime start = DateTime. Now;
MAction action = new MAction ("Users ");
Action. EndTransation (); // close the transaction
For (int I = 0; I <count; I ++)
{
Action. Set ("UserName", "U _" + System. Threading. Thread. CurrentThread. ManagedThreadId );
Action. Set ("Password", "P _" + I );
If (action. Insert ())
{
OK ++;
}
}
Action. Close ();
TimeSpan ts = DateTime. Now-start;
Console. WriteLine ("CYQ. Data [MAction]:" + ts. TotalSeconds + "[seconds] --" + OK );
}