1 /* Take a measure of REXX clauses
-per
-second (CIPS
) */
2 /* Mike
Cowlishaw (MFC at VENTA
) */
3 /* 1.0 17 Jan
89 Original version
*/
4 /* 2.0 3 Jun
89 Remove attempt to simulate commands
*/
5 /* 2.1 7 Oct
89 Remove use of not symbols
, and correct commentary
*/
6 rexxcps
=2.1 /* REXXCPS version
*/
8 /* This measure of REXX execution speed is based on an analysis of
*/
9 /* the dynamic mix of clauses found
in a (subjectively chosen
) */
10 /* collection of REXX
programs (including commands
, macros
, and
*/
11 /* personal programs
). Approximately
2,500,000 lines of trace
*/
12 /* output were analysed
, and the program below recreates the
*/
13 /* dynamic mix of constructs found
in that analysis
. */
14 /* In view of the dramatic differences between systems
in their
*/
15 /* efficiency of issuing commands
, the timed loop does not issue
*/
16 /* commands (an
'RC=expression; PARSE' sequence is used instead
). */
17 /* This program therefore measures the performance of a REXX
*/
18 /* implementation
, exclusive of command execution overhead
. */
19 /* Elapsed (user
-perceived
) time is used
, rather than any form of
*/
22 count
=10 /* Repetition count
*/
23 averaging
=10 /* Averaging
-over count
*/
24 tracevar
='Off' /* Trace
setting (for development use
) */
26 parse source source
1 system
.
30 say
'----- REXXCPS' rexxcps
'-- Measuring REXX clauses/second -----'
31 say
' REXX version is:' version
32 say
' System is:' system
33 say
' Averaging:' averaging
'measures of' count
'iterations'
35 /* ----- Calibrate
for the empty do
-loop (average of
5) ----- */
44 noterm
=(system
='CMS'); if pos('O',tracevar
)=1 then noterm
=0
46 say
'Calibration (empty DO):' empty
'secs (average of' averaging
')'
47 say
'Spooling trace NOTERM'
48 'CP SPOOL CON * START NOTERM'; 'CP CLOSE CON PUR'
51 /* Now the true timer loop
.. average timing again
*/
57 /* ----- This is first of the
1000 clauses
----- */
60 /* This is the
"block" comment
in loop
*/
62 acompound
.key1
.loop
=substr(1234"5678",6,2)
63 if flag
=acompound
.key1
.loop then say
'Failed1'
64 do j
=1.1 to
2.2 by
1.1 /* executed
28 times
*/
65 if j
>acompound
.key1
.loop then say
'Failed2'
66 if 17<length(j
)-1 then say
'Failed3'
67 if j
='foobar' then say
'Failed4'
68 if substr(1234,1,1)=9 then say
'Failed5'
69 if word(key1
,1)='?' then say
'Failed6'
70 if j
<5 then do
/* This path taken
*/
71 acompound
.key1
.loop
=acompound
.key1
.loop
+1
78 when flag
='string' then say
'FailedS1'
79 when avar
.flag
.2=0 then say
'FailedS2'
80 when flag
=5+99.7 then say
'FailedS3'
81 when flag then avar
.1.2=avar
.1.2*1.1
82 when flag
==0 then flag
=0
86 when flag
=='ring' then say
'FailedT1'
87 when avar
.flag
.3=0 then say
'FailedT2'
88 when flag then avar
.1.2=avar
.1.2*1.1
89 when flag
==0 then flag
=1
91 parse value
'Foo Bar' with v1
+5 v2
.
92 trace value
trace(); address value
address()
93 call subroutine
'with' 2 'args', '(This is the second)'1''1
94 rc
='This is an awfully boring program'; parse var rc
p1 (p0
) p5
95 rc
='is an awfully boring program This'; parse var rc
p2 (p0
) p6
96 rc
='an awfully boring program This is'; parse var rc
p3 (p0
) p7
97 rc
='awfully boring program This is an'; parse var rc
p4 (p0
) p8
99 /* ----- This is last of the
1000 clauses
----- */
106 'CP CLOSE CON'; 'CP SPOOL CON * START TERM'
107 say
'Spooling now back on TERM'
110 /* Now display the statistics
*/
111 looptime
=(full
-empty
)/count
112 /* Developer
's statistics: */
113 if left(tracevar,1)='O
' then nop; else do
115 say 'Total (full DO
):' full-empty 'secs (average of
' averaging ,
116 'measures of
' count 'iterations
)'
117 say 'Time
for one
iteration (1000 clauses
) was
:' looptime 'seconds
'
119 /* And finally, the Result... */
121 say' Performance
:' format(1000/looptime,,0) 'REXX clauses per second
'
127 /* Target routine for the timed CALL - called 14 times */
129 parse upper arg a1 a2 a3 ., a4
130 parse var a3 b1 b2 b3 .
131 do 1; rc=a1 a2 a3; parse var rc c1 c2 c3; end
134 novalue: if noterm then 'CP SP CON STOP TERM
'
135 say "No value from line" sigl":" sourceline(sigl)