Click here to Skip to main content
14,669,686 members
Rate this:
Please Sign up or sign in to vote.
See more:
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

  • use 'for loop' instead of 'foreach'

  • use StringBuilder

  • use threading


But, the speed of my application is still very slow??


<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();
       }
Posted
Updated 19-May-11 4:16am
v4
Comments
Groulien 19-May-11 9:36am
   
Slow app = slow code
1. What kind of program are you working on?
2. Post the code.
Programm3r 19-May-11 9:42am
   
I agree, you'll have to post some code...

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 2

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[^]
  3. RedGate ANTS[^]
  4. EQUATEC[^]


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
   
Comments
fjdiewornncalwe 19-May-11 10:26am
   
Excellent Suggestions. +5.
thatraja 23-May-11 22:54pm
   
Good bunch
   
Agree, my 5.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100