3

How can I profile a C# app which does a lot of IO

I have tried ANTS and JetBrains but they dont seem to work well with IO bound applications and instead report CPU intensive tasks

Jack Kada
  • 24,474
  • 29
  • 82
  • 106
  • By I/O bound: do you mean that you do a lot of (intentionally) reading/writing to files or that you are dealing with enormous amounts of data that do not fit in memory, therefore you want to analyze its external memory behavior? – dcn Jun 19 '11 at 10:49

2 Answers2

3

The Concurrency Visualizer in Visual Studio 2010 can help identify areas of significant IO bottlenecks.

The "Threads View" shows a timeline of all of the threads in your application with colors indicating different types of activity. A thread will show purple when it is blocking on IO (e.g. file, network, etc). If you click on one of these segments, you'll see the call stack on which the thread is blocking on IO. In the image below, a synchronization (red) segment was selected and the stack is displayed in the "Current stack" panel.

There are also channels representing each of your disks and they will show reads/writes, and clicking on one of these segments will show the file operation represented by that segment.

For example,

Concurrency Visualizer Threads View

Below the timeline are a number of reports that you can access by clicking on the items in the "Visible Timeline Profile". They will show you the aggregated stacks for the various activities within the visible timeline, so you can see the stacks where most of your blocking on IO was happening. Similarly, the "File Operations" report will show you the reads/writes in the visible timeline.

The "File Operations" report looks like this:

Concurrency Visualizer File Operations

For more information, check out the team blog, MSDN or Hazim Shafi's blog or MSDN magazine article.

Matt
  • 4,318
  • 1
  • 27
  • 28
1

I find it useful to distinguish two goals - just measuring, versus actually locating bottlenecks in the code.

For the latter, I've found this technique to be most effective.

Much of my work is in a large C# application, and as people work performance problems always creep in - sometimes I/O bound, sometimes not. Regardless, that method finds them immediately.

Community
  • 1
  • 1
Mike Dunlavey
  • 40,059
  • 14
  • 91
  • 135