beautypg.com

Sample tal program, Example 5-1, Tal application containing user-defined counters – HP NonStop G-Series User Manual

Page 99

background image

Defining Custom Counters

Measure User’s Guide 520560-003

5 -3

Sample TAL Program

When specifying

bumptype

:

If you specify ADD, specify the value to add to the counter as the third parameter.

If you specify SETBUSY, you must have a matching RESETBUSY call.

If you specify INCQUEUE, you must have a matching DECQUEUE call.

If you are using an array of counters, specify the index value of the counter as the
fourth parameter. By default, the index value is zero to indicate the only (or first) value
associated with the counter name.

If the counter specified is not part of a currently active measurement,
MEASCOUNTERBUMP returns the literal value ERR^UDCNOTPRESENT in

error

.

Always check for this error.

For time-critical applications, to avoid unnecessary calls to the MEASCOUNTERBUMP
procedure, set a flag in your application to indicate that a counter is not active. Testing
the flag before you call MEASCOUNTERBUMP costs fewer CPU cycles than calling
MEASCOUNTERBUMP and finding that the counter is not active.

Sample TAL Program

The TAL program in

Example 5-1

bumps three counters:

TRANSACTIONS, an accumulating counter array containing two elements

TIMEPER, a busy counter

WAITING, a queue counter

This sample program assumes that the measurement is already running.

Caution.

Not balancing the busy and queue calls causes unpredictable counter values.

Example 5-1. TAL Application Containing User-Defined Counters (page 1 of 3)

?PAGE "GLOBAL DECLARATIONS"
?SYMBOLS, INSPECT
?NOMAP, NOLMAP, NOCODE

! error variable
int error := 0;
int .array[0:2];
string .sarray := @array '<<' 1;

! terminal name and number
int term[0:11];
int term^number;

! message variable
int .msg[0:40*[" "]];
string .smsg := @msg '<<' 1;

?NOLIST
?SOURCE $SYSTEM.SYS20.MEASDECS ! check your subvolume name