如何高速应用? [英] how high Speed Application?

查看:54
本文介绍了如何高速应用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我已经用C#编写了一个应用程序,并且对速度感到惊讶.

我想知道如何提高应用程序的速度??

例如:

  • 使用通用
  • Hi all,

    I have written an application in c# and was surprised with the speed.

    I want to know how I can increase the speed of the application???

    For example:

    • use generic
      • 使用``for循环''代替``foreach''
      • 使用StringBuilder
      • 使用线程
      <pre lang="cs">//***********************************************
             //Type
             //***********************************************
             void FillType()
             {
                 objType = new BL.BL.Type();
                 cmbType.DataSource = objType.GetType();
                 cmbType.DisplayMember = "TypeName";
                 cmbType.ValueMember = "TypeID_FK";
             }
             //***********************************************
             //Language
             //***********************************************
             void FillLanguage()
             {
                 objLanguage = new BL.BL.Language();
                 cmbLanguage.DataSource = objLanguage.GetLanguage();
                 cmbLanguage.DisplayMember = "LanguageName";
                 cmbLanguage.ValueMember = "LanguageID_FK";
             }
             //***********************************************
             //Document
             //***********************************************
             void FillDocument()
             {
                 dgvDocument.AutoGenerateColumns = false;
                 bsDocument = new BindingSource();
                 objDocument=new BL.BL.Document();
                 bsDocument.DataSource = objDocument.GetDocument();
                 dgvDocument.DataSource = bsDocument;
             }
      
       private void frm_ListDocument_Load(object sender, EventArgs e)
             {
                 FillType();
      
                 FillLanguage();
                 FillDocument();
             }

      推荐答案

      您必须分析应用程序,以分析大部分时间在代码中所花费的时间.我认为Visual Studio内置了一个探查器,但也有很多不错的探查器:

      You''ll have to profile your application to analyze where most of the time is spent in your code. Visual Studio has a profiler on board I think, but there also many good ones out in the wild:


      1. Yourkit [ ^ ]
      2. JetBrains [ RedGate ANTS [ EQUATEC [^ ]

      1. Yourkit[^]
      2. JetBrains[^]
      3. RedGate ANTS[^]
      4. EQUATEC[^]



      Google支持免费.NET Profiler",我敢肯定您可以自己提供几个免费的.

      分析代码性能将查明应用程序中的瓶颈,并且您必须分析可以应用哪种类型的调整机制.

      欢呼和快乐的剖析!

      -MRB



      Google for "Free .NET Profiler" and I''m sure you can come up with a couple of free ones yourself.

      Profiling code performance will pinpoint the bottlenecks in your application and you''ll have to analyze what kind of tuning mechanisms could be applied.

      Cheers and happy profiling!

      -MRB


      这篇关于如何高速应用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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