如何分析我的C#代码(以及一些SQL代码)的使用 - 根据方法/类的数量和它们被调用的次数

时间:2022-09-13 08:27:10

On high level my problem is -

在高层次我的问题是 -

We have couple of applications which have millions of lines of legacy code (C# and SQL). I need to figure out code areas which are being used most?

我们有几个应用程序,它们有数百万行遗留代码(C#和SQL)。我需要弄清楚最常用的代码区域?

It may not be possible to find exact figures (especially in apps when code is being called based on user's action in GUI). However, to get some rough figures few thoughts I have are to find out:

可能无法找到确切的数字(特别是在根据用户在GUI中的操作调用代码时的应用程序中)。然而,为了得到一些粗略的数字,我的一些想法是要找出:

1) Find out List of Classes and Methods

1)找出类和方法列表

2) Find out number of time they are called from within the code. (by means of direct method calls/delegates etc)

2)找出代码中调用它们的时间。 (通过直接方法调用/委托等)

3) Find out all the stored procs/db functions (this would be bit staright forward)

3)找出所有存储的proc / db函数(这将是一个明星前进的位置)

4) Find out all the calls to stored procs

4)找出存储过程的所有调用

Could you please let me know - if you are aware of any tools to achive this? Or any other idea to fetch above 4 details? Also, apart from these any other way to to do this analysis?

能不能让我知道 - 如果你知道有什么工具可以实现这个目标吗?或者获取4个以上细节的任何其他想法?另外,除了这些任何其他方式来做这个分析?

Thanks in advance!

提前致谢!

2 个解决方案

#1


1  

I have used Red Gate's ANTS Profiler before:

我之前使用过Red Gate的ANTS Profiler:

http://www.red-gate.com/products/dotnet-development/ants-performance-profiler/

http://www.red-gate.com/products/dotnet-development/ants-performance-profiler/

It's powerful and very easy to use (comes with a visual studio plugin). 14 days free!

它功能强大且易于使用(附带可视工作室插件)。 14天免费!

#2


0  

One way you could achieve this is using Aspect Oriented Programming (AOP). I have used this previously in Java with the Spring Framework, but haven't used it before on .NET projects.

实现这一目标的一种方法是使用面向方面编程(AOP)。我之前在Java中使用过Spring Framework,但之前没有在.NET项目中使用它。

You could check out something like;

你可以查看类似的东西;

http://blogs.msdn.com/b/morgan/archive/2008/12/18/method-entry-exit-logging.aspx

http://blogs.msdn.com/b/morgan/archive/2008/12/18/method-entry-exit-logging.aspx

This will give you an idea of how frequently methods are being called. Your will need simply need to collate the data in the logs into some form giving you an overall idea of usage patterns of the codebase.

这将让您了解方法的调用频率。您只需要将日志中的数据整理成某种形式,从而全面了解代码库的使用模式。

Edit: Further information on using this method can be found on other SO posts;

编辑:有关使用此方法的更多信息可以在其他SO帖子中找到;

#1


1  

I have used Red Gate's ANTS Profiler before:

我之前使用过Red Gate的ANTS Profiler:

http://www.red-gate.com/products/dotnet-development/ants-performance-profiler/

http://www.red-gate.com/products/dotnet-development/ants-performance-profiler/

It's powerful and very easy to use (comes with a visual studio plugin). 14 days free!

它功能强大且易于使用(附带可视工作室插件)。 14天免费!

#2


0  

One way you could achieve this is using Aspect Oriented Programming (AOP). I have used this previously in Java with the Spring Framework, but haven't used it before on .NET projects.

实现这一目标的一种方法是使用面向方面编程(AOP)。我之前在Java中使用过Spring Framework,但之前没有在.NET项目中使用它。

You could check out something like;

你可以查看类似的东西;

http://blogs.msdn.com/b/morgan/archive/2008/12/18/method-entry-exit-logging.aspx

http://blogs.msdn.com/b/morgan/archive/2008/12/18/method-entry-exit-logging.aspx

This will give you an idea of how frequently methods are being called. Your will need simply need to collate the data in the logs into some form giving you an overall idea of usage patterns of the codebase.

这将让您了解方法的调用频率。您只需要将日志中的数据整理成某种形式,从而全面了解代码库的使用模式。

Edit: Further information on using this method can be found on other SO posts;

编辑:有关使用此方法的更多信息可以在其他SO帖子中找到;