什么是在C#中最重要的优化性能的最佳实践 [英] What are the most important optimizing performance best practices in C#

查看:372
本文介绍了什么是在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的),所以使用这些类型   柜台等频繁访问   整体变量。

解决方案
  1. 字符串是不可变
  2. 了解使用的语句。
  3. 了解拳击以及如何的泛型帮助。
  4. 了解垃圾收集是如何工作的。
  5. 并行编程在.NET 4.0中
  6. 了解如何文件IO 影响性能。

埃里克利珀谈到了很多关于优化。我会读他的博客
我想看看乔恩斯基特的博客也。

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.

解决方案

  1. Strings are Immutable.
  2. Understand the using statement.
  3. Understand Boxing and how Generics help.
  4. Understand how the Garbage Collector works.
  5. Parallel programming in .Net 4.0
  6. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆