	.ENABLE SUBSTITUTION
	;
	; THE KMS FUSION SYSTEM TERMINAL LOAD SIMULATOR (RSX11M V3.2 BL26)
	;		     '<DATE>'  '<TIME>'
	;
	.ENABLE QUIET
	.SETN PRISHF 105.		! DEFAULT SHUFFLER PRIORITY
	.SETN PRIIND 65.		! DEFAULT ...AT. PRIORITY
.IFNINS DSKMON INS $DSKMON
.IFACT DSKMON RUN $DSKOFF
.IFINS DSKMON RUN DSKMON
.;     This command procedure will simulate a program development load on
.; a system of from 1 to "n" terminals.   The user may either leav SHF...
.; in SYSPAR(the SYSGEN default), REMOVE it, or FIX it in a small TASK
.; partition(In our system we call this partition SHTPAR.  The name will
.; have to be changed depending on the system used.).
.;
.;     The user is also allowed to alter the ROUND ROBIN and SWAP interval
.; from run to run.  This allows tailoring performance for disk and CPU
.; speed.  To do this the task SCH is used and the KMS supplied SLP file
.; to TDSCH.MAC must have been applied.
.;
.;     This procedure depends on the ability to pass command lines to non
.; installed tasks using INS filespec/PRM="cmdline"/TASK=tsknam.  In this
.; way an "n" terminal environment is all forced to run on a single terminal.
.; Another requirement is the use of PIN, a procedure interpreter which
.; spawns single line MCR commands from a command file to MCR.  This
.; allows creating "n" independent job streams all controlled from a single
.; copy of ...AT. runing on TI:.
.;
.;     The final feature is using the program SNPSHT to take snap shots
.; of system performance parameters(# loader requests, # SHF requests,
.; # checkpoint requests, elapsed CPU time, #QIO's issued).  While all
.; system parameters are not measured, these provide a good measure for
.; the activity and the level of load imposed by this test on the sytem.
.; SNPSHT creates a command file of .SETN XYZ 123. type commands to
.; pass on the variables to ...AT. without having to modify ...AT. to
.; monitor these values directly.  Given the length of time this load
.; test will run, the overhead of opening and closing the command file
.; does not drastically affect the validity of the timings produced.
   
	.SETN TTL2 0
	.SETF REMSHF
	.SETF FIXSHF
	.SETS SHFPAR ""
	.ASKS BASLVL SYSTEM BASE LEVEL CODE
	.ASKN[1.:20.:1.] TRMCNT MAXIMUM NUMBER OF TERMINALS TO SIMULATE
	.ASKN[1.:10.:1.] PASCNT HOW MANY PASSES SHOULD BE MADE
	.DISABLE QUIET
	; CURRENT ROUND ROBIN AND SWAP TIMES ARE
	.ENABLE QUIET
	SCH /DSP
	.ASKN[5.:100.:5.] ROBIN  HOW MANY TICS FOR ROUND ROBIN INTERVAL
	.ASKN[40.:100.:40.] SWAP  HOW MANY TICS FOR SWAP INTERVAL
	.ASK CPUMON MONITOR CPU PERFORMANCE
	.SETS COMNT1 ""
	.ASKS COMNT1 SPECIAL CONDITIONS
.SHF:
	.ASK REMSHF REMOVE THE SHUFFLER FOR THIS RUN
	.IFF REMSHF.ASK FIXSHF FIX THE SHUFFLER FOR THIS RUN
	.IFT FIXSHF .ASKS SHFPAR WHAT PARTITION SHALL SHF BE FIXED IN
	.IFT FIXSHF .IF SHFPAR EQ "" .GOTO SHFERR
	.IFT FIXSHF .IF SHFPAR EQ "SYSPAR" .GOTO SHFERR
	.IFT REMSHF REM SHF...
	.IFT FIXSHF REM SHF...
	.IFT FIXSHF INS $SHF/PAR='SHFPAR'/CKP=NO
	.IF <EXSTAT> EQ 1 .GOTO FIXSHF	
.SHFERR:
	.DISABLE QUIET
	;  Some sort of error was made in trying to Install SHF in 'SHFPAR'.
	;  Perhaps the partition does not exist.  Try again!!
	.ENABLE QUIET
	REM SHF...
	INS $SHF/PAR=SYSPAR
	.GOTO SHF
.FIXSHF:.IFT FIXSHF FIX SHF...
	.IF <EXSTAT> NE 1 .GOTO SHFERR
	.IFF REMSHF .ASK SHFPRI ALTER THE SHUFFLER PRIORITY (DEFAULT=105.)
	.IFT SHFPRI .ASKN [1.:200.:105.] PRISHF WHAT IS THE SHUFFLER PRIORITY
	.ASK INDPRI ALTER ...AT. PRIORITY (DEFAULT=65.)
	.IFT INDPRI .ASKN [1.:100.:65.] PRIIND RUNNING PRIORITY FOR ...AT.
	.ASKN [1.:10.:2.] DELTA SCANNING RATE(SEC) FOR THIS COMMAND PROCEDURE
	ALT AT./RPRI='PRIIND'.
	ALT SHF.../PRI='PRISHF'.

	SCH /RBN:'ROBIN'/SWP:'SWAP'
	.SETN TERM 0
	.SETN MAXTI TRMCNT-1
.INSINS:
	.SETS FIL "0"
	.IF TERM GT 7 .SETS FIL ""
	.SETS INS "I"+FIL
	.SETN CNT'TERM' 0
	.SETS STRT'TERM' ""
	.IFNINS 'INS''TERM' INS $INS/TASK=...'INS''TERM'
	.INC TERM
	.IF TERM LE MAXTI .GOTO INSINS
	.;
	.; CREATE A FILE TO COMPILE AND TASKBUILD
	.OPEN DUMMY.FTN;1
	.DISABLE SUBSTITUTION
.ENABLE DATA
	WRITE(5,100)
100	FORMAT(' HI')
	END
.DISABLE DATA
	.CLOSE
	.ENABLE SUBSTITUTION
	.; 
	.; CREATE UP TO MAXTI COPIES OF .PRC FILES TO DRIVE THE LOAD TEST
	.SETN TERM 0
.CREATE:.SETS FIL "0"
	.IF TERM GT 7 .SETS FIL ""
	.SETS INS "I"+FIL
	.SETN T TERM
	.OPEN LOADT'TERM'.PRC;1
	.DATA $NOTRACE
.DATA 'INS''T' $PIP/TASK=PIPX'T'/PRM="DUMMY'T'.OBJ;1/DE/NM"/RUN=REM
.DATA 'INS''T' $F4P/TASK=F4PX'T'/PRM="DUMMY'T'.OBJ;1=DUMMY"/RUN=REM
.DATA 'INS''T' $TKB27/TASK=TKBX'T'/PRM="@DUMMY'T'.BLD"/RUN=REM
.DATA 'INS''T' $PIP/TASK=PIPX'T'/PRM="DUMMY'T'.OBJ;1/DE/NM"/RUN=REM
	.CLOSE
	.OPEN DUMMY'TERM'.BLD;1
	.DATA DUMMY'TERM'.TSK;1/CP/FP=DUMMY'TERM',LB:[1,1]F4POTS/LB
	.DATA /
	.DATA LIBR=FCSRES:RO
	.DATA //
	.CLOSE
	.INC TERM
	.IF TERM LE MAXTI .GOTO CREATE
	.SETN TOTAL TRMCNT*PASCNT
	.OPEN LOADTST.LOG;1
	.DATA ; 
	.DATA ; SYSTEM LOAD TEST SIMULATING TERMINAL ACTIVITY ON 'BASLVL'
	.DATA ;		'<DATE>'  '<TIME>'
	.DATA ; SIMULATING 'TRMCNT' TERMINALS RUNNING FOR 'PASCNT' PASSES
	.DATA ; 
	.DATA ;	LOAD TEST ENVIRONMENT AND PARAMETERS
	.DATA ;
	.DATA ; 	ROUND ROBIN INTERVAL(TICS) = 'ROBIN'
	.DATA ; 	EXECUTIVE SWAP TIME(TICS)  = 'SWAP'
	.IFINS SHF... .IFF FIXSHF .DATA ;	THE SHUFFLER IS IN SYSPAR
	.IFT REMSHF .DATA ;	THE SHUFFLER IS REMOVED
	.IFT FIXSHF .DATA ;	THE SHUFFLER IS FIXED IN 'SHFPAR'
		    .DATA ;	THE SHUFFLER PRIORITY = 'PRISHF'
		    .DATA ;	THE INDIRECT PRIORITY = 'PRIIND'
		    .DATA ;	INDIRECT DELAY TIME   = 'DELTA' SEC
		    .DATA ;
		    .DATA ; 'COMNT1'
	.DATA ;
	.DATA   JOB   PASCNT   START      STOP
	.SETN TERM 0
	.SETS START <TIME>

	.; TAKE A SNAPSHOT OF THE SYSTEM PERFORMANCE PARAMETERS
	.; $CKPRQ	- NUMBER OF CHECKPOINT REQUESTS
	.; $LDRQ	- NUMBER OF LOADER REQUESTS
	.; $SHFRQ	- NUMBER OF SHUFFLE REQUESTS
	.; $QIOCT	- NUMBER OF QIO'S/10
	.; $CPUTM	- NUMBER OF CPU TICS/100
	.IFF CPUMON .GOTO RUN
	.IFNINS SNPSHT INS $SNPSHT
	RUN SNPSHT
	.WAIT SNPSHT
	@SNAPSHOT.CMD/DE
	.SETN CKPCT1 $CKPRQ
	.SETN LDRCT1 $LDRQ
	.SETN SHFCT1 $SHFRQ
	.SETN QIOCT1 $QIOCT
	.SETN CPUTM1 $CPUTM

	;
	; STARTING RUN AT '<DATE>' '<TIME>'
.RUN:	
	.SETS FIL "0"
	.IF TERM GT 7 .SETS FIL ""
	.SETS INS "I"+FIL
	.SETS STRT'TERM' <TIME>
	.XQT 'INS''TERM' $PIN/TASK=PINX'TERM'/PRM="LOADT'TERM'.PRC"/RUN=REM
	.INC TERM
	.IF TERM LE MAXTI .GOTO RUN
.WATLOD:
	.IFNACT PINX0 .GOTO WATLOD
.TSTACT:
	.SETN TERM 0
	.DELAY 'DELTA'S
.LOOP:
	.IF CNT'TERM' GE PASCNT .GOTO STLACT
	.IFACT PINX'TERM' .GOTO STLACT
	.SETS STRTIM STRT'TERM'
	.INC CNT'TERM'
	.INC TTL2
	.SETN CNT CNT'TERM'
	.DATA  PINX'TERM'    'CNT'    'STRTIM'   '<TIME>'
	.SETS STRT'TERM' <TIME>
.IF CNT LT PASCNT .XQT INS $PIN/TASK=PINT'TERM'/PRM="LOADT'TERM'.PRC"/RUN=REM
.STLACT:
	.IF TTL2 GE TOTAL .GOTO ENDUP
.NEXT:
	.INC TERM
	.IF TERM GT MAXTI .GOTO TSTACT
	.GOTO LOOP
	.DISABLE QUIET
.ENDUP:
	.SETS LAST <TIME>
	.SETS HR START[1:2]
	.SETS MIN START[4:5]
	.SETS SEC START[7:8.]
	.SETN HOUR 'HR'.
	.SETN MINIT 'MIN'.
	.SETN SECND 'SEC'.
	.SETN STRTHR HOUR
.;	.SETN TOT 3600.*HOUR
	.SETN TOT1 60.*MINIT
;	.SETN TIME1 TOT+TOT1+SECND
	.SETN TIME1 TOT1+SECND
	.SETS HR LAST[1:2]
	.SETS MIN LAST[4:5]
	.SETS SEC LAST[7:8.]
	.SETN HOUR 'HR'.
	.SETN HOUR HOUR-STRTHR
	.SETN MINIT 'MIN'.
	.SETN SECND 'SEC'.
	.SETN TOT 3600.*HOUR
	.SETN TOT1 60.*MINIT
	.SETN TIME2 TOT+TOT1+SECND
	.SETN ELAPD TIME2-TIME1
	.SETN NLOADS PASCNT*TRMCNT
	.SETN TIMPER ELAPD/NLOADS
	.DATA ;
	.DATA ; TOTAL ELAPSED TIME(SEC) = 'ELAPD'
	.DATA ; TIME/TERMINAL LOAD(SEC) = 'TIMPER'
	.IFF CPUMON .GOTO CLS

	.; GET THE CLOSING PERFORMANCE STATISTICS
	RUN SNPSHT
	.WAIT SNPSHT
	REM SNPSHT
	@SNAPSHOT.CMD/DE
	.SETN CKPCT $CKPRQ-CKPCT1
	.SETN LDRQ  $LDRQ-LDRCT1
	.SETN SHFRQ $SHFRQ-SHFCT1
	.SETN QIOCT $QIOCT-QIOCT1
	.SETN CPUTM $CPUTM-CPUTM1
	.SETN PERCNT 100*CPUTM
	.SETN PERCNT PERCNT/ELAPD
	.DATA ;
	.DATA ; CHECKPOINT REQUESTS = 'CKPCT'      LOADER REQUESTS = 'LDRQ'
	.DATA ;   SHUFFLER REQUESTS = 'SHFRQ'         QIO COUNT/10 = 'QIOCT'
	.DATA ; CPU TIME = 'CPUTM'               % CPU UTILIZATION = 'PERCNT'

.CLS:	.CLOSE
	.SETN TERM 0
.CLEAN:	PIP LOADT'TERM'.PRC;*/DE/NM,DUMMY'TERM'.BLD;*,DUMMY'TERM'.TSK;*
	PIP DUMMY'TERM'.OBJ;*/DE/NM,DUMMY.FTN;*
	PIP LOADTST.LOG/TR
	.INC TERM
	.IF TERM LE MAXTI .GOTO CLEAN
	.SETN TERM 0
.REMINS:
	.SETS FIL "0"
	.IF TERM GT 7 .SETS FIL ""
	.SETS INS "I"+FIL
	.IFINS 'INS''TERM' REM 'INS''TERM'
	.INC TERM
	.IF TERM LE MAXTI .GOTO REMINS
	.IFT FIXSHF REM SHF...
	.IFNINS SHF... INS $SHF


	.DISABLE QUIET
	; 
	; THE LOAD SIMULATOR HAS COMPLETED 'PASCNT' PASSES 
	; SIMULATING 'MAXTI' TERMINALS
	.ENABLE QUIET
	PIP TI:=LOADTST.LOG
	PRINT LOADTST.LOG
	.IFACT DSKMON .IFNINS DSKOFF INS $DSKOFF
	.IFACT DSKMON RUN DSKOFF
	REM DSKOFF
	REM DSKMON


