Connell
Connell

Reputation: 14411

Winforms profile/coverage find number of times a method has been called

I have a feeling this is going to be really simple. I don't know if I'm just missing a trick here, or searching for the wrong phrases.

I'm looking for a profiling or code coverage (don't really know which category this falls in) that can monitor an application (preferably let me start and stop the monitoring) and count the number of times a method has been called. I've been tasked with optimising some old code and whilst doing so, I've found a few methods that are being called twice or even 3 times, where they only need to be called once.

I have a feeling there could be more of these..

On a side note: I'm actually a big fan of the JetBrains .NET tools. I'm using ReSharper, dotPeek and dotTrace at the moment (but can't find a way to do this). Is it worth looking into dotCover?

Upvotes: 0

Views: 670

Answers (4)

Daniel Mann
Daniel Mann

Reputation: 58980

Visual Studio 2010 Premium and above have performance profiling tools built in that can do exactly what you're asking.

Here's a blog about the performance tools available in VS2010 Premium/Ultimate.

Upvotes: 1

Sandy
Sandy

Reputation: 11687

I don't have any touch or knowledge of dotcover that you are talking about. But regarding number of times a method called, a dumb method to calculate this is create a static integer and increment it in the method. I am not sure what "profiling or code coverage" means. This may sound really stupid if you are asking something else.

Upvotes: 0

SmartBear's AQTime Standard (free version) and Pro (pay version) can both track hit counts of methods. I've used AQTime for years and have found it quite useful.

http://smartbear.com/products/free-tools/aqtime-standard/

Not only will it tell you how many times a method is called, but it also can display call trees.

The free version (Standard) really is free - no strings. It is just like the pay version but some of the more advanced features are disabled. But it has enough functionality that it stands on its own as very useful tool.

Upvotes: 1

tomahawk
tomahawk

Reputation: 249

You're right to consider using 'dotCover'. That's if you want more in-depth code coverage analysis and are willing to invest, then this will be more than suitable. Another alternative is 'NDepend' (http://www.ndepend.com) which I have greater experience with and outputs a large array of metrics.

Upvotes: 1

Related Questions