Jack Kada
Jack Kada

Reputation: 25262

Profiling IO Bound C# Applications

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

Upvotes: 3

Views: 2243

Answers (2)

Matt
Matt

Reputation: 4334

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.

Upvotes: 3

Mike Dunlavey
Mike Dunlavey

Reputation: 40699

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.

Upvotes: 1

Related Questions