class %Monitor.System.LineByLine extends %Library.RegisteredObjectLine-by-line Monitor.
A facility to allow monitoring of Cache Object Script routines on a line-by-line basis. The user may select which routines to monitor and any of the standard performance metrics supported by the PERFMON utility, as well as "Time" (clock time spent in line) and "TotalTime" (total clock time including in-line calls to other subroutines). See the GetMetrics() method for a list of metric names.
WARNING ! Starting the line-by-line monitor will enable the collection of statistics for *every* line of code executed by the selected routines and processes. This can have a major impact on the performance of a system, and it is recommended that you do this only on a 'test' system.
Normally, a list of routines can be specified simply as a parameter of the Start() method. But if the user requires a list of routines which exceeds the maximum string length, then this method may be called repeatedly with routine lists, prior to calling Start().
The first time it is called, the user should make sure they specify the "Clear" parameter to initialize the list and ensure that any previous entries are cleared. Then when Start() is invoked, the "Routine" parameter should be null (Routine = ""). Routines may use the asterisk wildcard as in Start().
The "Select" parameter is used to select either a list of metrics which are currently being monitored (default of Select=1) or a list of all available metric names (Select=2).
If Select=3, this method will print a list of all available metrics and a short description to the current device.
Routines may be "wildcarded" by using an asterisk as the final character of any routine name.
A null list of Metrics will use the default of "RtnLine, Time, TotalTime".
A null list of Process IDs will enable all processes.
The following example shows how to retrieve the current results for a routine named "Test":
s metrics=##class(%Monitor.System.LineByLine).GetMetrics(),cnt=$l(metrics,",") s rset=##class(%ResultSet).%New("%Monitor.System.LineByLine:Result") d rset.Execute("Test") w "LineByLine" f i=1:1:cnt w ?(12*i),$p(metrics,",",i) f l=1:1 s more=rset.Next() q:'more d . s x=rset.GetData(1) . w !,l,"." f i=1:1:cnt w ?(12*i),$li(x,i) k rset q