locked
How to improve .net app performance ? RRS feed

  • Question

  • Hi
    i'm looking for a way to improve .net app performance, i've used ngen.exe to perform this, but i didn't get good result.
    can anybody help me about this issue ?
    thanks
    this is my Signature
    Monday, June 15, 2009 9:07 PM

Answers

  • NGen will only help startup time - it doesn't make the code execute any faster than it would after JITting.

    Read more here



    codevanced.net
    • Marked as answer by Harry Zhu Tuesday, June 23, 2009 8:49 AM
    Monday, June 15, 2009 9:28 PM
  • Hi

    as per David's reply, your question is way too generic.
    .net doesn't (always) automatically run slower then other technologies / languages 
    A slow app mostly means that there is an issue with the application architecture

    if revisiting the architecture is an option then
    - go find yourself a profiler (eg dotTrace)
    - see where the issues lay

    If it's not
    - ngen is an option, but this won't help you too much.. it just pre-compiles the code for your specific system..
      if you have leak, that's not going to be stopped



    KR

    Frederik


    Please close the thread if your question is answered, and don't forget to rate the best responses!
    • Marked as answer by Harry Zhu Tuesday, June 23, 2009 8:49 AM
    Monday, June 15, 2009 9:28 PM
  • .NET is slow going as all who program with it know.

    Especially if you have a monolithic application or an application with many dependencies. I use NGEN, it helps startup's a hair, but not much on a cold boot, just after it is cached is it faster. I created a NGEN Gui, simply select the EXE and NGEN will do its thing.

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Diagnostics;
    using System.Runtime.InteropServices;
    using System.IO;





    namespace
    NgenInstaller { public partial class MainForm : Form { private Process ngenProcess = new Process(); private string runtimeStr = RuntimeEnvironment.GetRuntimeDirectory(); private string ngenStr; public MainForm() { InitializeComponent(); ngenStr = Path.Combine(runtimeStr, "ngen.exe"); } private void btnSelect_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "EXE files (*.exe)|*.exe"; ofd.FilterIndex = 1; ofd.RestoreDirectory = true; DialogResult dr = DialogResult.OK; if (ofd.ShowDialog() == dr) { ngenProcess.StartInfo.UseShellExecute = false; ngenProcess.StartInfo.FileName = ngenStr; ngenProcess.StartInfo.Arguments = string.Format("install \"{0}\"", ofd.FileName); ngenProcess.Start(); ngenProcess.WaitForExit(); } } } }
    Best advice, loosely couple your application as much as you can. Using Ninject may be a start for you. Takes some getting used to, but once you get the hang of it, it helps.

    http://ninject.org/
    John Grove - TFD Group, Senior Software Engineer, EI Division, http://www.tfdg.com
    • Marked as answer by Harry Zhu Tuesday, June 23, 2009 8:50 AM
    Tuesday, June 16, 2009 3:32 AM

All replies

  • This is about as generic a question as "What should I do for a living?"  Performance can be impeded by several things.  The first thing you should do is try to figure out where the performance is impeded.  Try using breakpoints in your code often to determine which operations take the longest, then start refactoring those operations to try to speed them up. 

    There's not alot more I can tell you here without knowing more about what the specific problem is.
    David Morton - http://blog.davemorton.net/ - @davidmmorton - ForumsBrowser, a WPF Forums Client
    Monday, June 15, 2009 9:11 PM
  • This is about as generic a question as "What should I do for a living?"  Performance can be impeded by several things.  The first thing you should do is try to figure out where the performance is impeded.  Try using breakpoints in your code often to determine which operations take the longest, then start refactoring those operations to try to speed them up. 

    There's not alot more I can tell you here without knowing more about what the specific problem is.
    David Morton - http://blog.davemorton.net/ - @davidmmorton - ForumsBrowser, a WPF Forums Client

    Hi David
    i mean generally .net app performance, not my app, my main question is about when u run a .net app, it compile by JIT, then load in memory and execute. this operations is slower than other technologies (like delphi compiled app), i also improved it by ngen.exe but i think i didn't get good result.
    this is my Signature
    Monday, June 15, 2009 9:23 PM
  • NGen will only help startup time - it doesn't make the code execute any faster than it would after JITting.

    Read more here



    codevanced.net
    • Marked as answer by Harry Zhu Tuesday, June 23, 2009 8:49 AM
    Monday, June 15, 2009 9:28 PM
  • Hi

    as per David's reply, your question is way too generic.
    .net doesn't (always) automatically run slower then other technologies / languages 
    A slow app mostly means that there is an issue with the application architecture

    if revisiting the architecture is an option then
    - go find yourself a profiler (eg dotTrace)
    - see where the issues lay

    If it's not
    - ngen is an option, but this won't help you too much.. it just pre-compiles the code for your specific system..
      if you have leak, that's not going to be stopped



    KR

    Frederik


    Please close the thread if your question is answered, and don't forget to rate the best responses!
    • Marked as answer by Harry Zhu Tuesday, June 23, 2009 8:49 AM
    Monday, June 15, 2009 9:28 PM
  • I'm not sure there's anything else you can do to speed it up.  I honestly would take a look at the code you're writing.  Most people haven't had huge performance issues with their code, unless they've typically missed seeing some opportunity to improve it within their code. 
    David Morton - http://blog.davemorton.net/ - @davidmmorton - ForumsBrowser, a WPF Forums Client
    Monday, June 15, 2009 9:29 PM
  • NGen will only help startup time - it doesn't make the code execute any faster than it would after JITting.

    Read more here



    codevanced.net

    OK
    i mean improve stratup time of .net app, is there any tips & tricks to do this by ngen (a btter way or technic or article)?
    thanks
    this is my Signature
    Monday, June 15, 2009 10:05 PM
  • .NET is slow going as all who program with it know.

    Especially if you have a monolithic application or an application with many dependencies. I use NGEN, it helps startup's a hair, but not much on a cold boot, just after it is cached is it faster. I created a NGEN Gui, simply select the EXE and NGEN will do its thing.

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Diagnostics;
    using System.Runtime.InteropServices;
    using System.IO;





    namespace
    NgenInstaller { public partial class MainForm : Form { private Process ngenProcess = new Process(); private string runtimeStr = RuntimeEnvironment.GetRuntimeDirectory(); private string ngenStr; public MainForm() { InitializeComponent(); ngenStr = Path.Combine(runtimeStr, "ngen.exe"); } private void btnSelect_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "EXE files (*.exe)|*.exe"; ofd.FilterIndex = 1; ofd.RestoreDirectory = true; DialogResult dr = DialogResult.OK; if (ofd.ShowDialog() == dr) { ngenProcess.StartInfo.UseShellExecute = false; ngenProcess.StartInfo.FileName = ngenStr; ngenProcess.StartInfo.Arguments = string.Format("install \"{0}\"", ofd.FileName); ngenProcess.Start(); ngenProcess.WaitForExit(); } } } }
    Best advice, loosely couple your application as much as you can. Using Ninject may be a start for you. Takes some getting used to, but once you get the hang of it, it helps.

    http://ninject.org/
    John Grove - TFD Group, Senior Software Engineer, EI Division, http://www.tfdg.com
    • Marked as answer by Harry Zhu Tuesday, June 23, 2009 8:50 AM
    Tuesday, June 16, 2009 3:32 AM
  • Hi,
      To improve the performance of .NET applications, Microsoft recomended certain way of coding practices, that are refered in the patterns and practices session. Here are the links. Please feel free to read and understand the best practices must be followed while devoleping a .NET targeting application.
     
      http://msdn.microsoft.com/en-us/library/ms998530.aspx
      http://msdn.microsoft.com/en-us/library/ms979199.aspx

     You will get most of the patterns & Practices documents from the above links & sublinks.

    -- Thanks Ajith R
    Tuesday, June 16, 2009 4:16 AM
  • Use for loops instead of foreach.

    use the byte cheking in enumeration.

    Use the Analyze in Visual Studio 2008.
    Regards, Nikolay
    • Proposed as answer by Doaji Tuesday, June 16, 2009 2:21 PM
    Tuesday, June 16, 2009 7:54 AM