Performance Tips and Tricks in .NET Applications(四

Use Binary Compare for Text
When comparing text, use binary compare instead of text compare. At run time, the overhead is much lighter for binary. Minimize the Use of Format()
When you can, use toString() instead of format(). In most cases, it will provide you with the functionality you need, with much less overhead.Use Charw
Use charw instead of char. The CLR uses Unicode internally, and char must be translated at run time if it is used. This can result in a substantial performance loss, and specifying that your characters are a full word long (using charw) eliminates this conversion. Optimize Assignments
Use exp += val instead of exp = exp + val. Since exp can be arbitrarily complex, this can result in lots of unnecessary work. This forces the JIT to evaluate both copies of exp, and many times this is not needed. The first statement can be optimized far better than the second, since the JIT can avoid evaluating the exp twice.Avoid Unnecessary Indirection
When you use byRef, you pass pointers instead of the actual object. Many times this makes sense (side-effecting functions, for example), but you don't always need it. Passing pointers results in more indirection, which is slower than accessing a value that is on the stack. When you don't need to go through the heap, it is best to avoid it.Put Concatenations in One Expression
If you have multiple concatenations on multiple lines, try to stick them all on one expression. The compiler can optimize by modifying the string in place, providing a speed and memory boost. If the statements are split into multiple lines, the Visual Basic compiler will not generate the Microsoft Intermediate Language (MSIL) to allow in-place concatenation. See the StringBuilder example discussed earlier.Include Return Statements

时间: 2024-08-29 00:59:48

Performance Tips and Tricks in .NET Applications(四的相关文章

Performance Tips and Tricks in .NET Applications(一

Performance Tips and Tricks in .NET ApplicationsA .NET Developer Platform White PaperEmmanuel SchanzerMicrosoft CorporationAugust 2001Summary: This article is for developers who want to tweak their applications for optimal performance in the managed

Performance Tips and Tricks in .NET Applications(三

Use Session State Only If You Need ToOne extremely powerful feature of ASP.NET is its ability to store session state for users, such as a shopping cart on an e-commerce site or a browser history. Since this is on by default, you pay the cost in memor

Android 6.0 Marshmallow tips and tricks 棉花糖的技巧和窍门

Since you're reading these lines, chances are you're among the lucky 2 percent of Android users who happen to have Marshmallow running on their smartphone. You've either received an update to Android 6.0, or you're simply a Nexus user.从你看到这个起,你很幸运的了解

(转) How to Train a GAN? Tips and tricks to make GANs work

  How to Train a GAN? Tips and tricks to make GANs work 转自:https://github.com/soumith/ganhacks    While research in Generative Adversarial Networks (GANs) continues to improve the fundamental stability of these models, we use a bunch of tricks to tra

ASP.NET AJAX Advance Tips & Tricks (4)

ASP.NET AJAX Performance Improvement Preface I think everyone would agree that AJAX is one of the elements of "Web 2.0", every web developers should know this technology. I have been collected a list of the popular AJAX Frameworks on my chinese

ASP.NET AJAX Advance Tips & Tricks(11) 三种方法动态创建Tooltip

前言 如何动态创建提示框(Tooltip)是ASP.NET Forum里的常见问题之一,在做技术支持时,我曾在英文 博客上总结过ASP.NET和ASP.NET AJAX环境下如何动态创建提示框的三种常见方法,比较基础,收到了蛮 多老外们的commend,如今英文博客被墙,特转到这里来与大家分享. 原文地址: http://lancezhang.wordpress.com/2008/12/04/create-tooltip-dynamically/ http://lancezhang.wordpr

ASP.NET AJAX Advance Tips & Tricks (10)

解决使用AJAX Extender时的页面导出(Word/Excel)问题 前言: 有客户问到这么个问题:我们可以使用Response容易地将ASP.NET页面导出为Excel或Word.然而,如 果有AJAX Control Toolkit的Extender在页面上的话,则会发生错误(Extender control 'XXX' is not a registered extender control).我搜索了一下,ASP.NET forum里有很多这样的问题未能解决,故写了 这个解决方案,

ASP.NET AJAX Advance Tips & Tricks (9)

DropDownList在Firefox下的奇怪现象和解决方案--谁的BUG? 前言: 今天在ASP.NET Forum里面遇到了一个及其怪异的问题,一个看似非常简单的demo在IE及其它浏览器中 正常运行,然而在Firefox中却导致了奇怪的问题,使页面中的DropDownList死掉,经过研究,终于找到 了一个解决方案,但此问题是谁的Bug仍不得而知. 问题重现: 一个ScriptManager 一个DropDownList 一个UpdatePanel,内有一个Button 在按钮点击事件中

ASP.NET AJAX Advance Tips & Tricks (8) 扩展AJAX Control Toolkit中的控件

需求: TabContainer容器中的TabPanel类本身就包含了Enabled属性,也可以使用JavaScript方法 set_enabled(X)来设置Enabled属性,如果某个TabPanel的这个属性为false的话,这个TabPanel就不会显 示在TabContainer中,这与一般控件的"Enabled"属性不太一样,我认为叫它"Visiable"会更加恰当 .如下图所示: 有时候这并不符合我们的需求,所以,在本例中,我们将为其添加Disable