4

I recently installed (the eval of) Visual Studio 2008 TS in order to be able to get some profiling of an application done. Now I only find out how little I know about (real world) profiling, when applications are more complex than "Hello World".

My main problem is that the integrated debugger seems to add the time spent by all threads, so I get several times the total runtime, also certain functions (like sleep) show up several times, I assume since they are called by several threads.

Now my problem is: how can I make this easier to examine? There is only one thread I am interested in (the main one doing all the work), the others are simply waiting for certain stuff and are totally limited by the running time of my main thread. (They are in the same modules though and sometimes call the same functions.)

Is there any way to setup the profiling? Any way to handle the results in order to make them more meaningful for my scenario? Any other solution than VS 2008 (like 2010 or an external profiler)?

I am using instrumentation right now (gave me better results than sampling in my view) with C# under .net 3.5.

Mehdi LAMRANI
  • 11,289
  • 14
  • 88
  • 130
Andreas Reiff
  • 7,961
  • 10
  • 50
  • 104
  • 1
    Is there a reason why you chose 2008 over 2010 ? The latter comes with a rock solid profiler – Mehdi LAMRANI Mar 08 '12 at 11:25
  • 1
    JetBrains also makes a very good profiler. http://www.jetbrains.com/profiler/ – Ioannis Karadimas Mar 08 '12 at 11:48
  • What is your goal? Is it to use a profiler, or to get speedup? If you want speedup, *[there's a better way](http://stackoverflow.com/questions/2473666/tips-for-optimizing-c-net-programs/2474118#2474118)*. Profiling carries a lot of myths *[explained here](http://stackoverflow.com/questions/1777556/alternatives-to-gprof/1779343#1779343)*. – Mike Dunlavey Mar 08 '12 at 12:43
  • @Mika The project is set up for 2008. No other reason. I suppose going to 2010 should be smooth - unlike with older versions (I had problems with C++ 6 -> 2003) – Andreas Reiff Mar 08 '12 at 12:58
  • @Ioannis Does it support mulithreading? I had a look here http://stackoverflow.com/questions/3927/what-are-some-good-net-profilers and checked most products if they said anything about mt. Semms like only Intel VTune can do it. :) But it's not .net. – Andreas Reiff Mar 08 '12 at 13:07
  • @Mike Yes, I want to improve performance. I started out without a profiler and didn't get too far. Application is too complex and not my code and my knowledge is limited to optimizing obvious points (Sleep, loops, Harddrive, ...). – Andreas Reiff Mar 08 '12 at 13:07
  • @Andreas Yes, of course. I have used it extensively to improve performance of a particular mt app that uses background workers succesfully. – Ioannis Karadimas Mar 08 '12 at 13:16
  • @Andreas: Obvious things do not take you very far. To find unobvious things you should take manual samples, and look at each one to see if what it's doing is really necessary. If for example, you take 5 manual samples, and 2 of them show something you could do better or not at all, then you're looking at a time reduction in the range of 20% - 60%, or a speedup percentage in the range 25% - 150%. – Mike Dunlavey Mar 08 '12 at 13:23
  • I am going to have a look at JetBrains then, many thanks. As for the manual sampling: why should I make my life (even) more complicated? Setting the profiler/projects up was quite a bit of work, but it is running now. And it does the samples automatically. Plus, with 40+ projects and several hundred functions I don't think the manual sampling method will get me very far. Also, I am close to a point where there are even with a profiler no obvious performance problems anymore. It is not 100-1000 lines of code I have written myself for which your approach (in my view) would work well. – Andreas Reiff Mar 08 '12 at 19:56

1 Answers1

5

The ANTS Performance Profiler from Red Gate can filter profiling results by thread.

The documentation on Working with the call tree (specifically, the section "Changing the call-tree display options") shows a screenshot of where you can access the filter.

  • Thanks for all answers! I actually ended up rewriting some code to prevent not vital threads from starting, also put some logic into seperate functions to better get a fast overview. Worked ok. Oh, and I did not get around to testing anything but the inbuilt profiler.. too little time. – Andreas Reiff Jun 26 '12 at 09:40
  • The link is now out of date. I think this is the new one: http://documentation.red-gate.com/display/APP8/Working+with+the+call+tree – ijb109 Jan 13 '15 at 20:09