BuildModel PowerScript function
Description
Builds either a performance analysis or trace tree model based
on the trace file you have specified with the SetTraceFileName function.
Optional arguments let you monitor the progress of the build or
interrupt it.
You must specify the trace file to be modeled using the SetTraceFileName function
before calling BuildModel.
Controls
Profiling and TraceTree objects
Syntax
|
1 |
<span>instancename</span>.<span>BuildModel</span> ( { <span>progressobject, eventname, triggerpercent</span> } ) |
|
Argument |
Description |
|---|---|
|
instancename |
Instance name of the Profiling or TraceTree |
|
progressobject (optional) |
A PowerObject that represents the number |
|
eventname (optional) |
A string specifying the name of an event |
|
triggerpercent (optional) |
A long identifying the number of activities |
Return Values
ErrorReturn. Returns one of the following values:
-
Success! – The function
succeeded -
FileNotSetError! – TraceFileName has not
been set -
ModelExistsError! – A model has already
been built -
EnterpriseOnlyFeature! – This function
is supported only in the Enterprise edition of PowerBuilder -
EventNotFoundError! – The event cannot
be found on the passed progressobject, so the
model cannot be built -
EventWrongPrototypeError! – The event was
found but does not have the proper prototype, so the model cannot
be built -
SourcePBLError! – The
source libraries cannot be found, so the model cannot be built
Usage
The BuildModel function extracts raw data
from a trace file and maps it to objects that can be acted upon
by PowerScript functions. If you want to build a model of your trace
file without recording the progress of the build, call BuildModel without
any of its optional arguments. If you want to receive progress information
while the model is being created or if you want to be able to interrupt
a BuildModel that is taking too long to complete,
call BuildModel with its optional arguments.
The event eventname on the passed progressobject is
triggered when the number of activities indicated by the triggerpercent argument
are processed. If the value of triggerpercent is
0, eventname is triggered for every activity.
If the value of triggerpercent is greater than
100, eventname is never triggered. You define
this event using this syntax:
|
1 |
<span>eventname </span>(<span> currentactivity, totalnumberofactivities</span> ) |
|
Argument |
Description |
|---|---|
|
eventname |
Name of the event |
|
currentactivity |
A long identifying the number of the |
|
totalnumberofactivities |
A long identifying the total number of |
Eventname returns a boolean value. If
it returns false, the processing initiated by
the BuildModel function is canceled and any temporary
storage is cleaned up. If you need to stop BuildModel processing
that is taking too long, you can return a false value
from eventname. The script you write for eventname determines how
progress is monitored. For example, you might display progress or
simply check whether the processing must be canceled.
Examples
This example creates a performance analysis model
of a trace file:
|
1 |
Profiling lpro_model |
|
1 |
String ls_filename |
|
1 |
|
1 |
lpro_model = CREATE Profiling |
|
1 |
lpro_model.SetTraceFileName(ls_filename) |
|
1 |
lpro_model.<span>BuildModel</span>() |
This example creates a trace tree model of a trace
file:
|
1 |
TraceTree ltct_model |
|
1 |
String ls_filename |
|
1 |
|
1 |
ltct_model = CREATE TraceTree |
|
1 |
ltct_model.SetTraceFileName(ls_filename) |
|
1 |
ltct_model.<span>BuildModel</span>() |
This example creates a performance analysis model
that provides progress information as the model is built. The eventname argument
to BuildModel is called ue_progress and
is triggered each time five percent of the activities have been
processed. The progress of the build is shown in a window called w_progress that
includes a Cancel button:
|
1 |
Profiling lpro_model |
|
1 |
String ls_filename |
|
1 |
Boolean lb_cancel |
|
1 |
|
1 |
lpro_model = CREATE Profiling |
|
1 |
lb_cancel = false |
|
1 |
lpro_model.SetTraceFileName(ls_filename) |
|
1 |
|
1 |
Open(w_progress) |
|
1 |
// Call the of_init window function to initialize |
|
1 |
// the w_progress window |
|
1 |
w_progress.of_init(lpro_model.NumberOfActivities, & |
|
1 |
'Building Model', This, 'ue_cancel') |
|
1 |
|
1 |
lpro_model.<span>BuildModel</span>(This, 'ue_progress', 5) |
|
1 |
|
1 |
// Clicking the cancel button in w_progress |
|
1 |
// sets lb_cancel to true and returns |
|
1 |
// false to ue_progress |
|
1 |
IF lb_cancel THEN & |
|
1 |
Close(w_progress) |
|
1 |
RETURN -1 |
|
1 |
END IF |