In. before Net Framework 2.0, array representation can be represented by array and arraylist of collection classes. After 2.0 ,. NET introduces the generic concept list
2.0 the intention of introducing generic models is to reduce the performance consumption caused by packing and unpacking of types.
For example;
Private void compareto
{
....
}
The list
Today, we mainly discuss what kind of performance is higher when the type is determined. arraylist does not need to be considered. It must be
1. Use the stopwatch class (system. Diagnostics. stopwatch)
The stopwatch instance can measure the running time at one interval or the total running time at multiple intervals. In a typical stopwatch solution, call the start method, call the stop method, and use the elapsed attribute to check the running time.
The
int count = 1000000; // Number of inserted itemsStatic void Main (string [] args){// Long commonInsertRunTime = CommonInsert ();// Console. WriteLine (string. Format ("the time used to insert {1} pieces of data in normal mode is {0} millisecond", commonInsertRunTime, count ));Long sqlBulkCopyInsertRunTime = SqlBulkCopyInsert ();Console. WriteLine (string. Format ("the time used to insert {1} pieces of data using SqlBulkCopy is {0} millisecond", sqlBulkCopyInsertRunTime, count ));Long TVPInsertR
;Using System. Diagnostics;Using System. Data;Using System. Data. SqlClient;Using com. DataAccess;Namespace ConsoleAppInsertTest{Class Program{Static string connectionString = SqlHelper. ConnectionStringLocalTransaction; // database connection stringStatic int count = 1000000; // Number of inserted itemsStatic void Main (string [] args){// Long commonInsertRunTime = CommonInsert ();// Console. WriteLine (string. Format ("the time used to insert {1} pieces of data in normal mode is {0} millisecon
= Sqlhelper.connectionstringlocaltransaction; Database connection stringstatic int count = 1000000; Number of bars insertedstatic void Main (string[] args){Long commoninsertruntime = Commoninsert ();Console.WriteLine (String. Format (the time spent in the normal way to insert {1} data is {0} milliseconds, Commoninsertruntime, count));Long sqlbulkcopyinsertruntime = Sqlbulkcopyinsert ();Console.WriteLine (String. Format ("The time used to insert {1} data using SqlBulkCopy is {0} milliseconds", S
comments.
Copy Code code as follows:
Using System;
Using System.Diagnostics;
Using System.Data;
Using System.Data.SqlClient;
Using COM. DataAccess;
Namespace Consoleappinserttest
{
Class Program
{
static string connectionString = Sqlhelper.connectionstringlocaltransaction; Database connection string
static int count = 1000000; Number of bars inserted
static void Main (string[] args)
{
Long commoninsertruntime = Commoninsert ();
Console.WriteLine (String. Format (the ti
Program{Static string connectionstring = sqlhelper. connectionstringlocaltransaction; // database connection stringStatic int COUNT = 1000000; // Number of inserted itemsStatic void main (string [] ARGs){// Long commoninsertruntime = commoninsert ();// Console. writeline (string. Format ("the time used to insert {1} pieces of data in normal mode is {0} millisecond", commoninsertruntime, count ));Long sqlbulkcopyinsertruntime = sqlbulkcopyinsert ();Console. writeline (string. Format ("the time u
I talked with others about the performance of linq yesterday. I feel that the performance of linq is not good, but in fact it is still outstanding in terms of performance, except for the ability to write data to SQL, the following is a simple performance test comparison code. Here I will explain that the execution speed of the Code cannot be tested using datetime. I am still a little white, just starting with datetime, the results showed that the performance of the linq service was not good, but
I talked with others about the performance of LINQ yesterday. I feel that the performance of LINQ is not good, but in fact it is still outstanding in terms of performance, except for the ability to write data to SQL, the following is a simple performance test comparison code. Here I will explain that the execution speed of the Code cannot be tested using datetime. I am still a little white, just starting with datetime, the results showed that the performance of the LINQ service was not good, but
In a project, it is often necessary to log records of execution performance (time spent) of some methods, which are implemented in two ways.StopWatchUsing the Stopwatch class to measure time is very simple. Like the stopwatch in real life, this class of objects can start, stop, zero (reset) operations on the counter, but it is much more accurate than the average stopwat
The paging method is displayed on the Internet. It is said that datareader has the fastest paging speed. So I did some tests.
First, I use the ACCESS database, use socancode to automatically generate code pagination (socancode generates not in statements for paging), and use datareader paging. the test time is as follows:
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->Stopwatch Sw = new
It seems boring, but no one is doing it. Let me work hard.
Below are some simple tests. The Unit is ms. Note that the number of loops used here is 100, and the number of loops is.
These records can be used as a reference for programming.
Test Platform:
Pentium 1.6g dual-core CPU1 GB memoryTest the debugging environment of vs2008.
1. arraylist (100 W, 1 W)
Stopwatch Timer
=
New
Stopwatch
method for obtaining objects. This method is used with constructor, factory, and service locator (such as JNDI )) compared with traditional methods, these methods provide better reusability, testability, and maintainability. The processing process of this method is a well-known dependency injection, which is very valuable to most applications.
In our program, many types depend on other types. For example, a stopwatch may depend on a timesource. If so
(...) insert into XXX values (...). form of SQL execution and returns the execution time of SQL, Batchinsert also uses stitching SQL to generate INSERT into XXX values (...), (...). Resembles SQL and returns the execution time of the SQL. Use the console program to execute two functions multiple times and output execution results.Table structure:CREATE TABLE tqrcode ( ID INT PRIMARY KEY IDENTITY (1, 1), Name NVARCHAR, Remark NVARCHAR (300) ) C # implementation code:1
In this way, our Fashui ticket time will be 10 minutes-->20 seconds, which is amazing.
As a then, the next demo, testing, change to their own general methods of testing, NND, can really say is the speed.
Put my Demo:SqlBulkCopy.rar in here.
Copy Code code as follows:
Using System;
Using System.Diagnostics;
Using System.Data;
Using System.Data.SqlClient;
Using Microsoft.ApplicationBlocks.Data;
Namespace Consoleappinserttest
{
Class Program
{
static int count = 1000000; Numbe
In this case, the time for issuing the ticket will be 10 minutes-> 20 seconds. This is amazing.
Now, let's go to the demo, test, and change it to a method test that we generally use. nnd is really fast.
Paste my demo: sqlbulkcopy.rar here
CopyCode The Code is as follows:
Using system;
Using system. diagnostics;
Using system. Data;
Using system. Data. sqlclient;
Using Microsoft. applicationblocks. Data;
Namespace consoleappinserttest
{
Class Program
{
Static int COUNT = 1000000; // Number of in
Many times it takes time for the output program to be recorded,always start recording the current point of time at the beginning of the program execution, at the end of the record end point in time, and then subtract two times,so is there any other way to be a little bit more presentable? Tell you, there is a drop; )the subject of this method is StopwatchHis description is: For accurate measurement of the running time, you need to record time-consuming students who applause?Specific use:System.D
insert {1} pieces of data using SqlBulkCopy is {0} millisecond", sqlBulkCopyInsertRunTime, count ));
Long commonInsertRunTime = CommonInsert ();
Console. WriteLine (string. Format ("the time taken to insert {1} pieces of data in normal mode is {0} millisecond", commonInsertRunTime, count ));
Console. ReadKey ();
}
///
/// Insert data normally///
///
Private static long CommonInsert ()
{
Stopwatch stopwatch
In this case, the time for issuing the ticket will be 10 minutes-> 20 seconds. This is amazing.
Now, let's go to the demo, test, and change it to a method test that we generally use. nnd is really fast.
Paste my demo: sqlbulkcopy.rar here
CopyCode The Code is as follows: using system;
Using system. diagnostics;
Using system. Data;
Using system. Data. sqlclient;
Using Microsoft. applicationblocks. Data;
Namespace consoleappinserttest
{
Class Program
{
Static int COUNT = 1000000; // Number of ins
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.