.net性能测试和优化2 Profiling和提高的一些参考

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 mechanism.

• 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.

工具

CLRProfier

Microsoft Visual Studio 2008 profiling tools

Red Gate's ANTS Memory and Performance Profilers

Microfocus DevPartner Studio Professional 9.1

SQL Profiler 2005/2008

分析

Performance analysis


High call count


Functions with very high call counts should 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 should be possible to trace back to where the calls to 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 calls


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

It includes 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 calls 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 calls to return.


Slowest function including child calls


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

calls to child functions (we have written), is accounted for.


Use your tool's call graph facility to explore 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, particularly 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 as

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


Reducing the overall memory footprint


Inefficient allocation and retention


Large Object Heap fragmentation

Common Areas for Performance Improvement


数据库


连接:连接是昂贵的资源

缓存:

Asp.net Cache: 如SqlCacheDependency

AppFabric: cache farm

Indexing

Database Engine Tuning Advisor

O/R框架

动态SQL的影响,separate views and functions, or perhaps a dedicated stored procedure


Reflection


Reflection is a very powerful mechanism

恰当的使用


String manipulation


StringBuilder和String的区别


Cryptographic functions


加密强度和性能


Network call latency


Protocol

Size of payload

Serialization/deserialization

Chatty vs. chunky: 请求的次数


Synchronous vs. asynchronous

 

Web


页面绑定的信息http://localhost:***/Trace.axd

OutputCache

web.config

<system.web>下的一些配置项

<compilation debug="false">

<trace enabled="false"/>

<deployment retail="true">

<httpHandlers>

时间: 2024-10-28 06:54:53

.net性能测试和优化2 Profiling和提高的一些参考的相关文章

优化现有媒体资源提高盈利性

我始终对这家推出了无数公益广告的http://www.aliyun.com/zixun/aggregation/6277.html">广告公司有着深深的敬意. 而且它的名字是那么响亮:baidu百科里写着,广告,是广而告之的简称. 在中视金桥香港率先挂牌后不久,"广而告之MMIA"抢在奥运开幕前在美国上市了. 但发行大跌眼镜.一个07年有着2亿9001.html">人民币净利润的公司,募集了约5千万美金. 当然这里面有很多市场大环境的因素,但读罢招股书,

ControlJS优化阿里妈妈广告提高页面脚本的加载速度

文章简介:用ControlJS优化阿里妈妈广告. 长时间以来阿里妈妈的广告载入策略一直存在些问题,很多页面也因为阻塞式的广告载入而被拉低性能,影响用户体验.毕竟阿里妈妈广告的渲染依赖于诸多嵌套的document.write.ControlJS的目标就是解决js的阻塞式渲染,因此灵玉急不可耐想与同仁们共同去揭秘ControlJS-- Steve Souders在2010年12月份发布了ControlJS项目,该项目是让开发者更好的去控制javascript文件的下载和执行,从而提高了页面脚本的加载

网站优化双刃剑:如何提高网站排名

随着搜索引擎对SEO的关注,网站优化被越来越多的人认同着.但是SEO是把双刃剑,利用得当可以迅速提高网站排名,发展前景也蒸蒸日上.但是利用不当不仅仅站长一番苦功付诸东流,就连网站也可能被殃及降权就得不偿失了.不过风险虽然大,在衡量利弊之后最终还是选择了做优化.那么,如何利用好SEO扩大访问量就成为了我们今天所要说的话题. 对于网页的优化,网站的内容是优化的前提,好的内容定位标准为"新"且丰富.但是"新"不并不意味着完全的原创,专题的整合同样算式一种更新创作.好的内容

你网站优化的方法能提高工作效率吗

随着搜索引擎算法不断的改变,决定网站的排名的因素越来越多,我们的工作量往往比竞争对手多,但是网站排名并不是很理想.这时观察一下身边那些排名较好的网站,你就会发现自己的优化网站思维往往是滞后的,现在庞日泉总结一下一般站长对网站优化方法还有那些地方需要改进. 一.复制粘贴不能获得好的排名 一般网站优化新手请教一下老手自己需要在什么地方改进,一般老手回答说"多更新点原创文章,不要抄袭."真的是抄袭对网站不好吗?深圳网站建设行业就有那么一个公司,他很少去自己写文章,绝大部分都是从别的地方把和行

网站页面布局优化技巧:轻松提高用户体验

    随着搜索引擎算法不断变动,什么才是最好的网站优化方式成了网站站长关注的话题.其实很多网站优化手段只是辅助外力,确实的提高网站用户体验才是网站长期稳定发展的最好助力.在影响用户体验的众多因素中网站页面布局无疑是十分重要的一项因素. 一.网站首页布局设计 网站首页是网站给用户的第一印象,首页页面布局需从主题.导航.内容等方面入手,下面以百度百科的页面为例进行首页页面布局分析. 1.首页主题 首页是网站的核心页面,首页的主题也就是网站的主要核心.首页主题需让用户很容易的了解网站是做什么的.首页

五步详解站长如何优化内容页来提高用户体验

每个站长天天觜上说的用户体验,脑子里想的是怎么提高用户体验,但是成功的却是寥寥无几,毕竟用户体验这个东西说简单也很简单,说难也很难,更何况是摸不清道不明的,没有哪个网站说可以完美的符合用户体验的,只能是更接近完美的用户体验而已.当然笔者也不是另类,对于用户体验是否良好,其实都只是通过网站反馈的数据分析得知的,可能是比较接近完美的用户体验吧.但是不管怎么样,用户体验确实是网站发展的根本,即使不能做到完美,那么也要大概对应这个方向吧. 在用户的眼中他不会去看你使用的优化方法是什么,而且也不懂.用户能

怎样优化Microsoft Access来提高速度

介绍 作为一名数据库程序员,你的主要任务是让你的用户能快速地选择.管理和访问他们所需要的信息.其他的工作几乎都是一成不变的,只要你的数据库应用程序执行速度越快,你的程序效率越高.这篇文章的目的就是突出各种不同的技巧和策略,通过优化程序来提高速度,让你的Microsoft Access 数据库应用程序的效率更高,这样也可以帮助你完成作为一名数据库开发者的主要使命. 硬件 瞄准速度问题的根本 为了提高你的数据库程序的速度,自然而然地你会想到去注意影响速度最基本的几个部分,我们将从处理这几个部分着手.

SQL Server 性能优化之——系统化方法提高性能

原文http://www.cnblogs.com/BoyceYang/archive/2013/06/15/3138142.html 阅读导航 1. 概述 2. 规范逻辑数据库设计 3. 使用高效索引设计 4. 使用高效的查询设计 5. 使用技术分析低性能 6. 总结   1. 概述 在比较大的范围内找出能够大幅提高性能的区域,并且专注于分析这个区域,这是最有效的优化SQL Server性能的方式.否则,大量的时间和精力可能被浪费在不能提高很大性能的区域.在这里并没有讨论关于多用户并发所带来的性

深度优化内容页广告 提高网赚收入

因为现在的广告联盟日益增多,所以各自的联盟产品(http://www.aliyun.com/zixun/aggregation/11939.html">广告业务)不同,性质也不同,虽然都是广告联盟可是因为他们自身在业界里的形象,信誉,声誉,和在对待会员的宣传交易量上的对待方法不同而最后所产生的利益也不同!那么这就是联盟会员要去区别和认识的关键,选择好的联盟商是你资金快速增长的命脉! 站长的核心问题,你投放广告了,每天看着帐户后台返回数据统计,你就在想怎么这么少啊?如何提高他呢?满世界的站长