home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rximc175.zip / rexxcps.rexx < prev    next >
OS/2 REXX Batch file  |  1993-06-25  |  5KB  |  140 lines

  1. /* ReXX */
  2.   /* Take a measure of REXX clauses-per-second (CPS)                 */
  3.   /* Mike Cowlishaw (mfc@ibm.com).  Multi-platform.                  */
  4.   /* 1.0 17 Jan 89 Original version                                  */
  5.   /* 2.0  3 Jun 89 Remove attempt to simulate commands               */
  6.   /* 2.1  7 Oct 89 Remove use of not symbols, and correct commentary */
  7.   rexxcps=2.1    /* REXXCPS version; quotable only if code unchanged */
  8.  
  9.   /* This measure of REXX execution speed is based on an analysis of */
  10.   /* the dynamic mix of clauses found in a (subjectively chosen)     */
  11.   /* collection of REXX programs (including commands, macros, and    */
  12.   /* personal programs).  Approximately 2,500,000 lines of trace     */
  13.   /* output were analysed, and the program below recreates the       */
  14.   /* dynamic mix of constructs found in that analysis.               */
  15.   /* In view of the dramatic differences between systems in their    */
  16.   /* efficiency of issuing commands, the timed loop does not issue   */
  17.   /* commands (an 'RC=expression; PARSE' sequence is used instead).  */
  18.   /* This program therefore measures the performance of a REXX       */
  19.   /* implementation, exclusive of command execution overhead.        */
  20.   /* Elapsed (user-perceived) time is used, rather than any form of  */
  21.   /* virtual time.                                                   */
  22.  
  23.   count=5        /* Repetition count */
  24.   averaging=10   /* Averaging-over count */
  25.   tracevar='Off' /* Trace setting (for development use) */
  26.   signal on novalue
  27.   parse source  source  1 system .
  28.   parse version version
  29.  
  30.  
  31.   say '----- REXXCPS' rexxcps '-- Measuring REXX clauses/second -----'
  32.   say ' REXX version is:' version
  33.   say '       System is:' system
  34.   say '       Averaging:' averaging 'measures of' count 'iterations'
  35.  
  36.   /* ----- Calibrate for the empty do-loop (average of 5) ----- */
  37.   empty=0
  38.   do i=1 to averaging
  39.     call time 'R'
  40.     do count; end
  41.     empty=time('R')+empty
  42.     end
  43.   empty=empty/averaging
  44.  
  45.   noterm=(system='CMS'); if pos('O',tracevar)=1 then noterm=0
  46.   if noterm then do
  47.      say 'Calibration (empty DO):' empty 'secs (average of' averaging')'
  48.      say 'Spooling trace NOTERM'
  49.      'CP SPOOL CON * START NOTERM'; 'CP CLOSE CON PUR'
  50.      end 
  51.  
  52.   /* Now the true timer loop .. average timing again */
  53.   full=0 
  54.   do i=1 to averaging
  55.     trace value tracevar
  56.     call time 'R'
  57.     do count;
  58.       /* -----  This is first of the 1000 clauses ----- */
  59.       flag=0; p0='b'
  60.       do loop=1 to 14
  61.         /* This is the "block" comment in loop */
  62.         key1='Key Bee'
  63.         acompound.key1.loop=substr(1234"5678",6,2)
  64.         if flag=acompound.key1.loop then say 'Failed1'
  65.         do j=1.1 to 2.2 by 1.1   /* executed 28 times */
  66.           if j>acompound.key1.loop then say 'Failed2'
  67.           if 17<length(j)-1        then say 'Failed3'
  68.           if j='foobar'            then say 'Failed4'
  69.           if substr(1234,1,1)=9    then say 'Failed5'
  70.           if word(key1,1)='?'      then say 'Failed6'
  71.           if j<5 then do   /* This path taken */
  72.             acompound.key1.loop=acompound.key1.loop+1
  73.             if j=2 then leave
  74.             end
  75.           iterate
  76.           end /* j */
  77.         avar.=1.0''loop
  78.         select
  79.           when flag='string' then say 'FailedS1'
  80.           when avar.flag.2=0 then say 'FailedS2'
  81.           when flag=5+99.7   then say 'FailedS3'
  82.           when flag          then avar.1.2=avar.1.2*1.1
  83.           when flag==0       then flag=0
  84.           end
  85.         if 1 then flag=1
  86.         select
  87.           when flag=='ring'  then say 'FailedT1'
  88.           when avar.flag.3=0 then say 'FailedT2'
  89.           when flag          then avar.1.2=avar.1.2*1.1
  90.           when flag==0       then flag=1
  91.           end
  92.         parse value 'Foo Bar' with v1 +5 v2 .
  93.         trace value trace(); address value address()
  94.         call subroutine 'with' 2 'args', '(This is the second)'1''1
  95.         rc='This is an awfully boring program'; parse var rc p1 (p0) p5
  96.         rc='is an awfully boring program This'; parse var rc p2 (p0) p6
  97.         rc='an awfully boring program This is'; parse var rc p3 (p0) p7
  98.         rc='awfully boring program This is an'; parse var rc p4 (p0) p8
  99.         end loop
  100.       /* -----  This is last of the 1000 clauses ----- */
  101.       end
  102.     full=time('R')+full
  103.     trace off
  104.     end
  105.   full=full/averaging
  106.   if noterm then do
  107.      'CP CLOSE CON'; 'CP SPOOL CON * START TERM'
  108.      say 'Spooling now back on TERM'
  109.      end 
  110.  
  111.   /* Now display the statistics */
  112.   looptime=(full-empty)/count
  113.   /* Developer's statistics: */
  114.   if left(tracevar,1)='O' then nop; else do
  115.     say
  116.     say 'Total (full DO):' full-empty 'secs (average of' averaging ,
  117.       'measures of' count 'iterations)'
  118.     say 'Time for one iteration (1000 clauses) was:' looptime 'seconds'
  119.     end
  120.   /* And finally, the Result... */
  121.   say
  122.   say'     Performance:' format(1000/looptime,,0) 'REXX clauses per second'
  123.   say
  124.  
  125.   exit
  126.  
  127.  
  128.   /* Target routine for the timed CALL - called 14 times */
  129.   subroutine:
  130.     parse upper arg a1 a2 a3 ., a4
  131.     parse var a3 b1 b2 b3 .
  132.     do 1; rc=a1 a2 a3; parse var rc c1 c2 c3; end
  133.     return
  134.  
  135.   novalue: if noterm then 'CP SP CON STOP TERM'
  136.   say "Novalue error!"
  137.   /* -- end of program -- */
  138.  
  139.  
  140.