Parameter passing benchmark test

From MidrangeWiki
Revision as of 02:44, 6 November 2007 by Larryducie (talk | contribs)
Jump to: navigation, search

Below is the code for a test program designed benchmark the passing of large character data to a subprocedure. To call this program simply call it from a with a numeric parameter. This parameter will instruct the program to perform that number of calls for each test. the results will be an average call time for each test.

The results will be displayed on the terminal.

It may be necessary to amend the code to measure the call time more accurately, or to provide an aggregate call time. this is because on extremely fast machines the values returned may be less than 1 ms per call.

    H dftactgrp(*no) bnddir('QC2LE')
    d valueconst      pr                  extpgm('VALUECONST')
    d ntimes                        15p 5 const
    d valueconst      pi
    d ntimes                        15p 5 const
    d byvalue         pr
    d bigparm                    65535a   varying value
    d byconst         pr
    d bigparm                    65535a   varying const
    d byvalueC        pr
    d bigparm                    65535a   value
    d byconstC        pr
    d bigparm                    65535a   const
    d printf          pr                  extproc('printf')
    d                                 *   value options(*string)
    d getchar         pr            10i 0 extproc('getchar')
    d startTime       s               z
    d endTime         s               z
    d t1              s             10i 0
    d t2              s             10i 0
    d msg             s             52a
    d i               s             10i 0
    d crlf            c                   const(X'0d25')
    d char100         s            100a   varying inz(*all'X')
    d char1000        s           1000a   varying inz(*all'X')
    d char65535       s          65535a   varying inz(*all'X')
    d varyingField    s          65535a   varying
    d charField       s          65535a
     /free
          printf('----------------------------------------------' + crlf);
          printf('Starting test...' + crlf);
          // For VARYING...
          startTime = %timestamp();
          for i = 1 to %int(ntimes);
            byvalue ('a');
          endfor;
          endTime = %timestamp();
          t1 = (%diff(endTime : startTime : *ms)/ntimes);
          startTime = %timestamp();
          for i = 1 to %int(ntimes);
            byconst ('a');
          endfor;
          endTime = %timestamp();
          t2 = (%diff(endTime : startTime : *ms)/ntimes);
          printf('Passing the literal _a_ for 65535a varying...' + crlf);
          printf('value: ' + %editc(t1 : 'P') + ' ms | '
          + 'const: ' + %editc(t2 : 'P') + ' ms' + crlf);
          varyingField = char100;
          startTime = %timestamp();
          for i = 1 to %int(ntimes);
            byvalue (varyingField);
          endfor;
          endTime = %timestamp();
          t1 = (%diff(endTime : startTime : *ms)/ntimes);
          startTime = %timestamp();
          for i = 1 to %int(ntimes);
            byconst (varyingField);
          endfor;
          endTime = %timestamp();
          t2 = (%diff(endTime : startTime : *ms)/ntimes);
          printf('Passing a 65535a varying with 100a filled...' + crlf);
          printf('value: ' + %editc(t1 : 'P') + ' ms | '
          + 'const: ' + %editc(t2 : 'P') + ' ms' + crlf);
          varyingField = char1000;
          startTime = %timestamp();
          for i = 1 to %int(ntimes);
            byvalue (varyingField);
          endfor;
          endTime = %timestamp();
          t1 = (%diff(endTime : startTime : *ms)/ntimes);
          startTime = %timestamp();
          for i = 1 to %int(ntimes);
            byconst (varyingField);
          endfor;
          endTime = %timestamp();
          t2 = (%diff(endTime : startTime : *ms)/ntimes);
          printf('Passing a 65535a varying with 1000a filled...' + crlf);
          printf('value: ' + %editc(t1 : 'P') + ' ms | '
          + 'const: ' + %editc(t2 : 'P') + ' ms' + crlf);
          varyingField = char65535;
          startTime = %timestamp();
          for i = 1 to %int(ntimes);
            byvalue (varyingField);
          endfor;
          endTime = %timestamp();
          t1 = (%diff(endTime : startTime : *ms)/ntimes);
          startTime = %timestamp();
          for i = 1 to %int(ntimes);
            byconst (varyingField);
          endfor;
          endTime = %timestamp();
          t2 = (%diff(endTime : startTime : *ms)/ntimes);
          printf('Passing a 65535a varying with 65535a filled...' + crlf);
          printf('value: ' + %editc(t1 : 'P') + ' ms | '
          + 'const: ' + %editc(t2 : 'P') + ' ms' + crlf);


          // For CHAR...
          startTime = %timestamp();
          for i = 1 to %int(ntimes);
            byvalueC ('a');
          endfor;
          endTime = %timestamp();
          t1 = (%diff(endTime : startTime : *ms)/ntimes);
          startTime = %timestamp();
          for i = 1 to %int(ntimes);
            byconstC ('a');
          endfor;
          endTime = %timestamp();
          t2 = (%diff(endTime : startTime : *ms)/ntimes);
          printf('Passing the literal _a_ for 65535a...' + crlf);
          printf('value: ' + %editc(t1 : 'P') + ' ms | '
          + 'const: ' + %editc(t2 : 'P') + ' ms' + crlf);
          charField = char100;
          startTime = %timestamp();
          for i = 1 to %int(ntimes);
            byvalueC (charField);
          endfor;
          endTime = %timestamp();
          t1 = (%diff(endTime : startTime : *ms)/ntimes);
          startTime = %timestamp();
          for i = 1 to %int(ntimes);
            byconstC (charField);
          endfor;
          endTime = %timestamp();
          t2 = (%diff(endTime : startTime : *ms)/ntimes);
          printf('Passing a 65535a with 100a filled...' + crlf);
          printf('value: ' + %editc(t1 : 'P') + ' ms | '
          + 'const: ' + %editc(t2 : 'P') + ' ms' + crlf);
          charField = char1000;
          startTime = %timestamp();
          for i = 1 to %int(ntimes);
            byvalueC (charField);
          endfor;
          endTime = %timestamp();
          t1 = (%diff(endTime : startTime : *ms)/ntimes);
          startTime = %timestamp();
          for i = 1 to %int(ntimes);
            byconstC (charField);
          endfor;
          endTime = %timestamp();
          t2 = (%diff(endTime : startTime : *ms)/ntimes);
          printf('Passing a 65535a with 1000a filled...' + crlf);
          printf('value: ' + %editc(t1 : 'P') + ' ms | '
          + 'const: ' + %editc(t2 : 'P') + ' ms' + crlf);
          charField = char65535;
          startTime = %timestamp();
          for i = 1 to %int(ntimes);
            byvalueC (charField);
          endfor;
          endTime = %timestamp();
          t1 = (%diff(endTime : startTime : *ms)/ntimes);
          startTime = %timestamp();
          for i = 1 to %int(ntimes);
            byconstC (charField);
          endfor;
          endTime = %timestamp();
          t2 = (%diff(endTime : startTime : *ms)/ntimes);
          printf('Passing a 65535a with 65535a filled...' + crlf);
          printf('value: ' + %editc(t1 : 'P') + ' ms | '
          + 'const: ' + %editc(t2 : 'P') + ' ms' + crlf);
          printf('Test ended - press ENTER to close window...' + crlf);
          printf('----------------------------------------------' + crlf);


          // Read 1 char from the keyboard - to force display of screen...
          i = getchar();
          *inlr = *on;
      /end-free
    P byvalue         b
    D byValue         pi
    D bigParm                    65535a   varying value
    P byValue         e
    P byConst         b
    D byConst         pi
    D bigParm                    65535a   varying const
    P byConst         e
    P byvalueC        b
    D byValueC        pi
    D bigParm                    65535a   value
    P byValueC        e
    P byConstC        b
    D byConstC        pi
    D bigParm                    65535a   const
    P byConstC        e