. NET performance testing and optimization 2 profiling and improvement references

Source: Internet
Author: User
Application profiling

Using profiling tools to look for potential bottlenecks during development can significantly reduce the number of problems that show up later. with the right tools and training, this can become a regular part of the development process without adding too much overhead.

Profilers retrieve performance and memory information from. Net Applications in one of three ways:

• Sample Based

The application function call stack is periodically recorded to give a low overhead, but equally low resolution analysis.

• Events based

The Common Language Runtime can be configured to send notifications to specific profiler DLLs. Key Information on function execution, CPU, memory, and garbage collection can be collected using this mechanic.

• Instrumentation

Instrumentation code that measures the application is added to it at runtime, which can give very detailed and accurate results, but also comes with a high overhead.

Http://blogs.msdn.com/ B /tvoellm/archive/2007/08/02/what-is-the-difference-between-sample-and-instrumentation-based-profilers.aspx

When to use sample vs instrumenation based profilers:

Sample Based-good for CPU bound problems,

Instrumentation Based profilers-Good For I/O, idle wait, memory ,...

Performance profiling

Performance profiling is all about discovering which parts of your application consume a disproportionate amount of time or system resource.

Memory profiling

Checking that an application doesn' t have memory leaks, and that it uses memory efficiently, together with fixing any issues found, will improve its overall stability and performance.

Tools

Clrprofier

Microsoft Visual Studio 2008 Profiling tools

Red Gate's ants memory and performance profilers

Microfocus devpartner studio professionally 9.1

SQL profiler 2005/2008

Analysis

Performance Analysis

high call count

Functions with very high call counts shoshould be treated with suspicion and investigated. often the high call count is valid, but sometimes it's due to an error in event handling, and can be a major source of unintended processing

using the call graphing facility of your performance tool, it shoshould be possible to trace back to where the callto the function originate, and decide if it is acceptable behaviour. it's a very quick and easy check, and a very quick optimization if a problem is found.

I have actually lost count of the number of times I have found this issue in live code!

slowest function excluding child CILS

This is the slowest function where the body of the function itself is responsible for the time.

it has des time spent calling. net Framework functions, but excludes time spent calling

other source code functions. in other words, it's answering the question, "What's the slowest

function we have written? "

identify the slowest functions excluding child CILS and then, if available, look for the slowest

code lines and determine if they are optimizable. you will often see slow lines waiting for

database and web service callto return.

Slowest function including child CILS

This is the slowest function where the total cost of the functions, including time spent

Callto child functions (we have written), is accounted.

Use your tool's call graph facility to operate e the slowest part of the call tree

Functions with high CPU utilization

Any function with high CPU utilization is a prime candidate for optimization, as high

Resource demands can be a key bottleneck.

Identify the most CPU-intensive lines of code within the function and determine if there are

Workable optimizations that may apply.

Functions with wait time

Functions with wait time can indicate performance problems in other application layers,

Or problems with thread locking

Identify which resource the function is waiting for, e.g. database or web service, then

Investigate the cause of the contention on that layer.

Functions generating disk Activity

A function generating disk activity needs to be investigated further, as it is demanding

Resources and is therefore a potential bottleneck

Make sure the disk activity is necessary, especially if this is a server application. Even if it is

Necessary, try to find an alternative if possible.

Functions generating network activity

A function generating network activity needs to be investigated further as another

Potential bottleneck.

Make sure the network activity is valid and not an artifact left behind from prototyping or

Developer testing. Ensure that the number of times this network activity occurs is as low

Possible, to reduce the effect of latency. If possible, get more data in one hit

Memory Analysis

Memory Leak Detection

Finding memory leaks is all about identifying objects that are allocated but never garbage collected

Excessive memory usage

Indexing the overall memory footprint

Inefficient Allocation and retention

Large Object heap fragmentation

Common areas for performance improvement

Database

Connection: connection is an expensive resource.

Cache:

Asp.net cache: for example, sqlcachedependency

Appfabric: cache farm

Indexing

Database Engine Tuning Advisor

O/R framework

Impact of dynamic SQL, separate views and functions, or perhaps a dedicated Stored Procedure

Reflection

Reflection is a very powerful mechanic

Proper Use

String manipulation

Difference between stringbuilder and string

Cryptographic functions

Encryption strength and Performance

Network call latency

Protocol

Size of payload

Serialization/deserialization

Chatty vs. Chunky: Number of requests

Synchronous vs. asynchronous

 

Web

information bound to the page http: // localhost: ***/trace. axd

outputcache

Web. config

configuration items

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.