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
Steps and methods of exercise
(1) skillful routines and clear posture
The so-called "routine" refers to the entire architecture of Taijiquan. The so-called "posture" refers to the action structure of each type. At the beginning of the school, the primary focus is on the routine proficiency, and the orientation is correct. Pay attention to the posture specification. After a period of practice, the routine has been skilled. At this time, you must focus on the correct posture so that you can genera
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
This is jdk1.5 after the introduction of the new content, as the best memory of publishing, resolutely decided to use a blog instead of my memory:
The Java language Specification says: In many cases packaging and unpacking are done by the compiler itself (in which case the packaging becomes boxed and the solution package is called the unboxing);
In fact, according to my own understanding, automatic boxing can be easily understood to encapsulate basic
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
increase the number of garbage collections.
Although a value type is a lightweight type, if a large number of value types are used, it can also compromise the performance of your application (for example, the boxing and unboxing operations below, passing a large value type for an instance, or returning a large instance of a value type).
Because the value of a value type instance is itself, and the value of an instance of a reference type
:
When designing an application, if all are application types, the performance of the application will be significantly reduced as this will increase the pressure on the managed heap and increase the number of garbage collections.
Although a value type is a lightweight type, if a large number of value types are used, it can also compromise the performance of your application (for example, the boxing and unboxin
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
of these small expressions that result in memory allocations, these expressions can result in memory allocations of hundreds of m, or even several g. For example, before the performance Test team positions the problem in the input scenario, a minute of test simulation developers writing code in the compiler allocates several g of memory.
PackingBoxing occurs when a value type is usually assigned on a thread stack or in a data structure, or when a temporary value needs to be wrapped into an obj
heap and increase the number of garbage collections.
Although a value type is a lightweight type, if a large number of value types are used, it can also compromise the performance of your application (for example, the boxing and unboxing operations below, passing a large value type for an instance, or returning a large instance of a value type).
Because the value of a value type instance is itself, and the value of an instance of a re
The string should be one of the most frequently used underlying data types in all programming languages. If used carelessly, we will pay a price for the extra performance overhead of a string operation. This article proposes a two-part approach to how to circumvent this type of performance overhead:1. Ensure that the packing is as small as possible2. Avoid allocating additional memory space.The first aspect: make sure that the packing is as small as possibleFor unpacking, we should not be unfami
Objective C # Principle 17: minimum packing and unpackingItem 17: Minimize boxing and unboxing
The value type is the data container, and they are not too many. On the other hand, the. NET Framework is designed as a single inherited reference type, system. object, which exists as a root object in the entire inheritance relationship. The purpose of designing these two types is completely different. the. NET Framework uses packing and unpacking to link
Tag:list Staticvoidmain (String[]args) {stopwatchsw=new Stopwatch ();int[]intarray=newint[100]; Sw. Start ();for (inti=0;iEffect650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/82/7E/wKiom1dW0euBFoGtAAANEDjci8g851.png "title=" 2016-06-07_215309.png "alt=" Wkiom1dw0eubfogtaaanedjci8g851.png "/>You can see that the array is significantly faster, but must initialize the lengthVisual reason is that a boxing
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.