Parameter passing benchmark test
From MidrangeWiki
Revision as of 06:05, 6 November 2007 by Larryducie (talk | contribs)
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 command line with a single numeric parameter. This parameter will instruct the program to perform that number of calls for each test. The results displayed 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.
The code
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
RESULTS
The results so far are:
Version V5R2 Model 270 Times per 1 call Passing the literal _a_ for 65535a varying... value: 1510 ms | const: 9 ms Passing a 65535a varying with 100a filled... value: 1456 ms | const: 8 ms Passing a 65535a varying with 1000a filled... value: 1502 ms | const: 8 ms Passing a 65535a varying with 65535a filled.. value: 2219 ms | const: 8 ms Passing the literal _a_ for 65535a... value: 1904 ms | const: 338 ms Passing a 65535a with 100a filled... value: 974 ms | const: 8 ms Passing a 65535a with 1000a filled... value: 973 ms | const: 8 ms Passing a 65535a with 65535a filled... value: 1265 ms | const: 8 ms Version V5R4 Model 520 Times per 1 call Passing the literal _a_ for 65535a varying... value: 133 ms | const: 6 ms Passing a 65535a varying with 100a filled... value: 150 ms | const: 1 ms Passing a 65535a varying with 1000a filled... value: 131 ms | const: 6 ms Passing a 65535a varying with 65535a filled.. value: 201 ms | const: 1 ms Passing the literal _a_ for 65535a... value: 207 ms | const: 41 ms Passing a 65535a with 100a filled... value: 127 ms | const: 1 ms Passing a 65535a with 1000a filled... value: 122 ms | const: 7 ms Passing a 65535a with 65535a filled... value: 120 ms | const: 1 ms Version V5R3 Model 890 Times per 1 call Passing the literal _a_ for 65535a varying... value: 120 ms | const: 0 ms Passing a 65535a varying with 100a filled... value: 60 ms | const: 0 ms Passing a 65535a varying with 1000a filled... value: 50 ms | const: 0 ms Passing a 65535a varying with 65535a filled... value: 90 ms | const: 0 ms Passing the literal _a_ for 65535a... value: 180 ms | const: 30 ms Passing a 65535a with 100a filled... value: 60 ms | const: 0 ms Passing a 65535a with 1000a filled... value: 60 ms | const: 0 ms Passing a 65535a with 65535a filled... value: 60 ms | const: 0 ms Version V5R2 Model 170 (2290) Times per 1 call Passing the literal _a_ for 65535a varying... value: 3339 ms | const: 24 ms Passing a 65535a varying with 100a filled... value: 3314 ms | const: 21 ms Passing a 65535a varying with 1000a filled... value: 3367 ms | const: 21 ms Passing a 65535a varying with 65535a filled... value: 4572 ms | const: 21 ms Passing the literal _a_ for 65535a... value: 4579 ms | const: 1087 ms Passing a 65535a with 100a filled... value: 2483 ms | const: 21 ms Passing a 65535a with 1000a filled... value: 2844 ms | const: 23 ms Passing a 65535a with 65535a filled... value: 2503 ms | const: 22 ms Version V5R2 Model SB1 (2313) Times per 1 call Passing the literal _a_ for 65535a varying... value: 318 ms | const: 2 ms Passing a 65535a varying with 100a filled... value: 301 ms | const: 1 ms Passing a 65535a varying with 1000a filled... value: 339 ms | const: 1 ms Passing a 65535a varying with 65535a filled... value: 439 ms | const: 1 ms Passing the literal _a_ for 65535a... value: 570 ms | const: 95 ms Passing a 65535a with 100a filled... value: 246 ms | const: 1 ms Passing a 65535a with 1000a filled... value: 276 ms | const: 1 ms Passing a 65535a with 65535a filled... value: 246 ms | const: 1 ms