[comp.os.vms] program to determine the speed of another program

warnock@prism.clemson.EDU.UUCP (04/13/87)

In response to the recent request for a program to determine the speed of
another program, I submit the following to the net.  It consists of:

SPEED.FOR - the program itself
SPEED.CLD - the command definition
SPEED.DOC - the documentation

(simple enough, right ?)

It's NOT in make format - it's just appended to this message.
I'll be happy to answer any questions I can !

Todd Warnock
Clemson University
ARPA:	Warnock@PRISM.Clemson.EDU
CSnet:	Warnock@Clemson.CSNET
BITnet: Warnock@Clemson

---------------------- SPEED.FOR -------------------------------------------
c********************************************************
c                                                       *
c  Written by:  Todd Warnock				*
c		VAX Systems				*
c               Clemson University Computer Center	*
c               Clemson, South Carolina 29634-2803	*
c               					*
c               (803) 656-3703				*
c                                                       *
c BITnet:	Warnock@Clemson				*
c CSnet:	Warnock@Clemson.CSnet			*
c ARPA:		Warnock@PRISM.Clemson.EDU		*
c                                                       *
c Copyright (C) 1986,1987 Todd Warnock - permission is	*
c hereby granted for the reproduction of this software,	*
c on condition that this copyright notice is included	*
c in the reproduction, and that such reproduction is	*
c not for purposes of profit or material gain. 		*
c                                                       *
c********************************************************
	program		speed
	implicit	integer*4(a-z)
	character	terminal*20 
	character	term_symbol*20 
	character	speed_string*5
	integer*2	channel
	
	structure	/iostat_block/
	integer*2 iostat
	byte	transmit,
     +		receive,
     +		crfill,
     +		lffill,
     +		parity,
     +		zero
	end structure
	record /iostat_block/ iosb

	structure /characteristics/
	byte	class,
     +		type
	integer*2	width
	union
	map
	integer*4 basic
	end map
	map
	byte length(4)
	end map
	end union
	integer*4 extended
	end structure
	record /characteristics/ charbuf

	include		'($ttdef)'
	include		'($iodef)'

c  Get the symbol name from the CLI
c
	call cli$get_value('TERMINAL',terminal)
 	call cli$get_value('SYMBOL',term_symbol)

	speed_50 = tt$c_baud_50
	speed_75 = tt$c_baud_75
	speed_100 = tt$c_baud_100
	speed_134 = tt$c_baud_134
	speed_150 = tt$c_baud_150
	speed_300 = tt$c_baud_300
	speed_600 = tt$c_baud_600
	speed_1200 = tt$c_baud_1200
	speed_1800 = tt$c_baud_1800
	speed_2000 = tt$c_baud_2000
	speed_2400 = tt$c_baud_2400
	speed_3600 = tt$c_baud_3600
	speed_4800 = tt$c_baud_4800
	speed_7200 = tt$c_baud_7200
	speed_9600 = tt$c_baud_9600
	speed_19200 = tt$c_baud_19200

	status = sys$assign(terminal,channel,,)
	if (.not. status) then
         type*,'SPEED-F-DEVNOTFND, device not a terminal device'
         goto 100 
	endif

	status = sys$qio(,%val(channel),
     +    %val(io$_sensemode),iosb,,,charbuf,%val(12),,,,)
	if (.not. status) call lib$stop(%val(status))

	if (iosb.transmit .eq. speed_50) term_speed = 50
	if (iosb.transmit .eq. speed_75) term_speed = 75
	if (iosb.transmit .eq. speed_100) term_speed = 100
	if (iosb.transmit .eq. speed_134) term_speed = 134
	if (iosb.transmit .eq. speed_150) term_speed = 150
	if (iosb.transmit .eq. speed_300) term_speed = 300
	if (iosb.transmit .eq. speed_600) term_speed = 600
	if (iosb.transmit .eq. speed_1200) term_speed = 1200
	if (iosb.transmit .eq. speed_1800) term_speed = 1800
	if (iosb.transmit .eq. speed_2000) term_speed = 2000
	if (iosb.transmit .eq. speed_2400) term_speed = 2400
	if (iosb.transmit .eq. speed_3600) term_speed = 3600
	if (iosb.transmit .eq. speed_4800) term_speed = 4800
	if (iosb.transmit .eq. speed_7200) term_speed = 7200
	if (iosb.transmit .eq. speed_9600) term_speed = 9600
	if (iosb.transmit .eq. speed_19200) term_speed = 19200

	  status=ots$cvt_l_ti(term_speed,speed_string,,,)
   	  if (.not. status) call lib$stop(%val(status))
	  status = str$trim(speed_string,speed_string,len)
          status=lib$set_symbol(term_symbol,speed_string(1:len),)
   	  if (.not. status) call lib$stop(%val(status))

 100	end
------------------------ SPEED.CLD ------------------------------------------
DEFINE VERB SPEED
	IMAGE SPEED
	PARAMETER P1,LABEL=TERMINAL,PROMPT="terminal",VALUE(REQUIRED)
	PARAMETER P2,LABEL=SYMBOL,PROMPT="symbol",VALUE(REQUIRED)
------------------------- SPEED.DOC ------------------------------------------
SPEED - Accepts, as input, a terminal and a symbol, and returns
		the terminal speed to the symbol specified.

The following steps are used to install SPEED in the SYS$COMMON:[SYSEXE]
directory (to make it accessible from all cluster nodes.)
No special privileges are needed to run SPEED.

	$backup/log speed.exe;0 sys$common:[sysexe]speed.exe;0
	$set prot=(w:e) sys$common:[sysexe]speed.exe
$!
$!  Optional, depending on whether you want SPEED shared or not.
$!
	$install
	replace/open/head/share speed   ! the default is sys$common:[sysexe]
	exit

The image must be INSTALLed each time the system boots, so it should be
placed in the system startup file. Also, the command must be added to the DCL
tables (if you so desire).

	$ set def sys$library
	$ set command speed /tables=dcltables/output=dcltables

Note:  If the image SPEED is put anywhere OTHER than SYS$SYSTEM, the
file SPEED.CLD will have to be modified to reflect the location of the
image.  (DEFINE IMAGE where$it$lives:SPEED)
------