Solved

Program counting classes and methods in C# files

Posted on 2008-10-08
4
218 Views
Last Modified: 2013-12-17
Hello,

do you know about some program that takes as the input some Solution in .Net (many C# files in projects), and the output is some chart of most frequently used classes (were instantiated many times) and methods (were callsed many times).

e.g.

ranking | method name | number of calls
1             method1()         2045
2             hello()                191
3             yes()                   3

thanks
0
Comment
Question by:xRalf
  • 2
4 Comments
 
LVL 26

Assisted Solution

by:Anurag Thakur
Anurag Thakur earned 240 total points
ID: 22670990
dont really know of any such tool but what you can do is get the information for one assembly
you can use reflection to load the assemnbly at run time and then can find all the types in the assembly their methods etc
http://www.dotnetspider.com/resources/19318-Reflection-C.aspx
http://articles.directorym.net/_NET_Tip_Display_Public_Information_for_an_Assembly-a923981.html
0
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 260 total points
ID: 22671046
I don't think reflection will help too much here as what he seems to be asking for is how often the calls were made at runtime... unless I am mistaken (there is no way to find out how many times an object will be instantiated at runtime by analyzing source code, just how many times it will be instantiated).


For this I would recommend (costs money) ants profiler http://www.red-gate.com/Products/ants_profiler/index.htm
or free CLR Profiler http://msdn.microsoft.com/en-us/netframework/aa569269.aspx

Both use the profiler API to access this information.


If you are just looking for source analysis there is a great product out there called ndepend http://www.ndepend.com/ that will do all that you are asking and a *whole* lot more.

Cheers,

Greg Young
0
 
LVL 6

Author Comment

by:xRalf
ID: 22672826
Thanks both a lot, I haven't thought about profiling at runtime but I'm blad that you expanded my question...
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 22672873
also ragi... to look for instantiations/method calls etc you would actually have to start parsing IL not just use reflections ... this is not actually too tough to do if you are familiar with IL but is non-trivial for most.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

863 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

25 Experts available now in Live!

Get 1:1 Help Now