什么是在C#中最重要的优化性能的最佳实践 [英] What are the most important optimizing performance best practices in C#
问题描述
当我在读本教程我注意到下面的性能提示关于使用结构在C#:</ P>
除非你需要引用类型 语义,一类是小 大于16字节可以更有效地 通过该系统处理为一个结构。
我所期望的是计算器类似的问题,我发现了一些谈论性能的最佳做法<一个问题href="http://stackoverflow.com/questions/1349850/c-what-are-some-high-performance-best-practices-tips-for-ado-net">ADO.Net, <一href="http://stackoverflow.com/questions/1672249/best-practices-of-high-performance-network-applications">Networking, <一href="http://stackoverflow.com/questions/1041267/net-streams-passing-streams-between-objects-best-practices-c">Streams,但不是关于在C#中表现最佳实践(语言)
我想补充一个小窍门如何使用整数类型:
运行时优化性能 32位整数类型(的Int32和 UInt32的),所以使用这些类型 柜台等频繁访问 整体变量。
埃里克利珀谈到了很多关于优化。我会读他的博客。
我想看看乔恩斯基特的博客也。
When I was reading this tutorial I noticed the following performance tip about using structs in C#:
Unless you need reference type semantics, a class that is smaller than 16 bytes may be more efficiently handled by the system as a struct.
I looked for similar question in stackoverflow and I found some questions that talk about performance best practices in ADO.Net, Networking, Streams, but not about performance best practices in C# (The language).
I want to add another tip about using the integer types:
The runtime optimizes the performance of 32-bit integer types (Int32 and UInt32), so use those types for counters and other frequently accessed integral variables.
- Strings are Immutable.
- Understand the using statement.
- Understand Boxing and how Generics help.
- Understand how the Garbage Collector works.
- Parallel programming in .Net 4.0
- Understand how File IO affects performance.
Eric Lippert talks alot about optimization. I would read his blog.
I would check out Jon Skeet's blog also.
这篇关于什么是在C#中最重要的优化性能的最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!