|
-
May 6th, 2019, 08:33 PM
#1
Thread Starter
^:^...ANGEL...^:^
Code Level Runtime Analytics
Hi,
Being given a task to analyse and collect info on all code paths for a very very large monolithic .NET Web app that is used across various clients.
Thinking about adding in some reflection type code that basically collects data of run-time code path taken depending on the params passed to various methods.
Once I have the data, need to start removing/deprecating code that never gets used in few months in real world. Along with refactoring and adding more test coverage on major code paths to improve quality.
I am aware of unit testing approach but this app is 13+ years old and unit testing can't be just added, can't be easily refactored without breaking something, can't be easily re-written.
Are there any tools frameworks that can be integrated into existing code that would allow me to collect such data?
Not looking for code samples but if anyone has it then awesome. Any help, general guidance, software/framework recommendation would be highly appreciated.
Something like Google Analytics but for the actual source code itself.
TA
-
May 7th, 2019, 03:26 AM
#2
Re: Code Level Runtime Analytics
One option is to write a routine to log the usage somehow (perhaps to a database table), and call that routine from every potential candidate for removal.
Thankfully Runtime.CompilerServices provides useful features so that you don't even need to pass any parameters to know the caller, eg:
Code:
Imports System.Runtime.CompilerServices
...
Private Sub LogUsage(<CallerMemberName> Optional methodName As String = Nothing,
<CallerFilePath> Optional filePath As String = Nothing,
<CallerLineNumber> Optional lineNumber As Integer? = Nothing)
Console.WriteLine("Entered '" & methodName & "' in '" & filePath & "'")
End Sub
Then in each place you want to log, simply call it without parameters:
As parts of your app are likely to get called many times, it would be a good idea to log to a database table and Update records by default (and only Insert if the Update didn't affect any records). I would recommend storing the routine info, a usage count, and datetime of last usage.
This is also likely to slow the app down a bit, so I recommend occasionally removing it from any routines that get called frequently.
-
May 7th, 2019, 11:41 PM
#3
Thread Starter
^:^...ANGEL...^:^
Re: Code Level Runtime Analytics
Thank you si. I was partially aware of those. Now to find someone who will modify all the methods for me or write some code to modify the code
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|