You use the PowerScript functions and PowerBuilder objects listed in the following table to build a nested trace tree model of an application.
|
Use this function |
With this object |
To do this |
|---|---|---|
|
SetTraceFileName |
TraceTree |
Set the name of the trace file to be analyzed. |
|
BuildModel |
TraceTree |
Build a trace tree model based on the trace file. You can pass optional parameters that let you track the progress of the build. |
|
EntryList |
TraceTree |
Get a list of the top-level entries in the trace tree model. |
|
GetChildrenList |
TraceTreeRoutine, TraceTreeObject, and TraceTreeGarbageCollect |
Get a list of the children of the routine or object—that is, all the routines called directly by the routine, or the destructor called as a result of the object's deletion. |
|
DestroyModel |
TraceTree |
Destroy the current trace tree model and all the objects associated with it. |
Each of these functions returns a value of type ErrorReturn.
Each TraceTreeNode object returned by the EntryList and GetChildrenList functions represents a single node in the trace tree model and contains information about the parent of the node and the type of activity it represents.
Inherited objects
The following objects inherit from TraceTreeNode and contain additional information, including timer values:
-
TraceTreeError
-
TraceTreeESQL
-
TraceTreeGarbageCollect
-
TraceTreeLine
-
TraceTreeObject
-
TraceTreeRoutine
-
TraceTreeUser
You use the same approach to building a trace tree model as you do to building a call graph model, except that you build a model of type TraceTree instead of type Profiling.
For example:
TraceTree ltct_treemodel ltct_treemodel = CREATE TraceTree ltct_treeModel.SetTraceFileName( is_fileName ) ltct_treeModel.BuildModel(this, 'ue_progress', 1)
For more about using BuildModel, see Using the BuildModel function to build a call graph model.
To extract information from a tree model, you can use the EntryList function to create a list of top-level entries in the model and then loop through the list, extracting information about each node. For each node, determine its activity type using the TraceActivity enumerated datatype, and then use the appropriate TraceTree object to extract information.
Example: trace tree model
The following simple example extracts information from an existing trace tree model and stores it in a structure:
TraceTreeNode ltctn_list[], ltctn_node long ll_index, ll_limit string ls_line str_node lstr_node ltct_treemodel.EntryList(ltctn_list) ll_limit = UpperBound(ltctn_list) FOR ll_index = 1 to ll_limit ltctn_node = ltctn_list[ll_index] of_dumpnode(ltctn_node, lstr_node) // insert code to handle display of // the information in the structure here … NEXT
The of_dumpnode function takes a TraceTreeNode object and a structure as arguments and populates the structure with information about each node. The following code shows part of the function:
string ls_exit, ls_label, ls_routinename
long ll_node_cnt
TraceTreeNode ltctn_list[]
errorreturn l_err
astr_node.Children = FALSE
astr_node.Label = ''
IF NOT isvalid(atctn_node) THEN RETURN
CHOOSE CASE atctn_node.ActivityType
CASE ActRoutine!
TraceTreeRoutine ltctrt_routin
ltctrt_routine = atctn_node
IF ltctrt_routine.Classname = '' THEN &
ls_routinename = ltctrt_routine.ClassName + "."
END IF
ls_routinename += ltctrt_routine.Name
ltctrt_routine.GetChildrenList(ltctn_list)
ll_node_cnt = UpperBound(ltctn_list)
ls_label = "Execute " + ls_routinename + ' :' + &
space(ii_offset) + String(l_timescale * &
(ltctrt_routine.ExitTimerValue - &
ltctrt_routine.EnterTimerValue), '0.000000')
astr_node.Children = (ll_node_cnt > 0)
astr_node.Label = ls_label
astr_node.Time = ltctrt_routine.EnterTimerValue
RETURN
CASE ActLine!
TraceTreeLine tctln_treeLine
tctln_treeLine = atctn_node
ls_label = LINEPREFIX + &
String(tctln_treeLine.LineNumber )
astr_node.time = tctln_treeLine.Timervalue
...
// CASE statements omitted
...
CASE ELSE
ls_label = "INVALID NODE"
END CHOOSE
astr_node.label = ls_label
RETURN

