how to debug the app taking a long time to run?

Posted on 2011-10-10
Last Modified: 2013-12-16

I have this visual c# app doing some calculation and give out the output.
It used to take a few seconds not it is taking at least 20 min to finish.
The original author fixed a few things.

How can I debug and test it why it is taking so long?
Question by:dkim18
    LVL 43

    Expert Comment

    >>The original author fixed a few things.

    Sounds like someone has written in a new bug - any documentation as to what 'fixes' were implemented?
    LVL 40

    Expert Comment

    by:Jacques Bourgeois (James Burger)
    Without the code, it's hard to tell.

    You might want to put a few lines like the following in the code and test the application in debug mode:
    DateTime stepStart;
    stepStart = DateTime.Now;
    // First part of your calculation
    Debug.WriteLine ( "Step 1 : " + DateTime.Now.Subtract ( stepStart ).TotalSeconds.ToString() );
    stepStart = DateTime.Now;
    // Second part of your calculation
    Debug.WriteLine ( "Step 2 : " + DateTime.Now.Subtract ( stepStart ).TotalSeconds.ToString ( ) );

    Open in new window

    When the calculation is over, the Output window will indicate the time in seconds that you spent in each step of the calculation. That will help you to spot where you should look for the slowdown.
    LVL 13

    Expert Comment

    by:Naman Goel

    Author Comment

    I forgto mention that I am vs 2010 ide.
    Is there any tool I can use from VS?
    LVL 13

    Accepted Solution

    LVL 40

    Assisted Solution

    by:Jacques Bourgeois (James Burger)
    If you have the Premium edition of Visual Studio, you can use the performance tools under the Analyze menu.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
    Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now