weixin_33728708 2011-04-22 12:32 采纳率: 0%
浏览 24

如何提升asp.net的性能?

Q:

在我以前使用asp.net的工作中,我考虑的只是如何完成所需的任务,不在乎 性能,但是现在我想,在我已经学到很多有关如何在某种程度上处理这种语言的知识之后,我应该专注于性能问题。 当我学习概念和语法时,我的老师告诉我,性能问题并不那么重要,首要任务始终是及时完成所需的任务,而且硬件和网络基础设施的革命将为你解决代码中的巨大性能差距! 现在,我想了解有关asp.net和整个Web中性能问题的一些技巧。如果有关于此想法的示例,我将不胜感激。 例如,有人告诉我:
int count = dataTable.Rows.Count;
for(int i = 0 ; i<count ; i++)
{
   //Do some thing
} 

比这个更重要:

for(int i = 0 ; i<dataTable.Rows.Count ; i++)
{
   //Do some thing
} 
  • 写回答

2条回答 默认 最新

  • weixin_33675507 2011-04-22 12:35
    关注

    The first version can be more performant, since you don't re-evaluate dataTable.Rows.Count in every iteration of the loop.

    If every call to dataTable.Rows.Count is expensive (and potentially can be), the first version will indeed be better.


    As for general tips about performance:

    • Always decide what performance means for you (latency? throughput? something else?)
    • Always figure out how you measure it.
    • Figure out when your code is performant enough (when are you done).
    • Profile your code to find the worst performance points.
    • Fix these and reprofile.
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog