Parameter passing benchmark test
The Test
This test program is designed to benchmark the passing of large character data to a subprocedure. To call this program simply call it from a command line. The program will perform each check and print out the average call times per 100 calls for each check. There are 2 optional parameters. The first parameter will instruct the program to perform that number of calls for each test. The second parameter will instruct the program to print the call time as the average time taken to perform that number of calls. The default for the two parameters is 10,000 and 100. That is, the program will call each subprocedure 10,000 times and give the average time taken to call each subprocedure 100 times.
The results will be displayed on the terminal.
The code
H dftactgrp(*no) bnddir('QC2LE') option(*srcstmt)
d valueconst pr extpgm('VALUECONST')
d p_ntimes 15p 5 const
d p_percall 15p 5 const
d valueconst pi
d p_ntimes 15p 5 const
d p_percall 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 ntimes s 10i 0 inz(10000)
d percall s 10i 0 inz(100)
d group s 10i 0 inz(0)
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
// Override number of calls to make to each function...
if %parms >= 1;
ntimes = p_ntimes;
endif;
// Override number of calls to group over...
if %parms >= 2;
percall = p_percall;
endif;
group = ntimes/percall;
printf('----------------------------------------------' + crlf);
printf('Starting test...' + crlf);
printf('' + crlf);
printf('Testing with total ' + %char(ntimes) + ' calls' + crlf);
printf('Times given per ' + %char(percall) + ' calls' + crlf);
printf('' + crlf);
// For VARYING...
startTime = %timestamp();
for i = 1 to ntimes;
byvalue ('a');
endfor;
endTime = %timestamp();
t1 = (%diff(endTime : startTime : *ms)/group);
startTime = %timestamp();
for i = 1 to ntimes;
byconst ('a');
endfor;
endTime = %timestamp();
t2 = (%diff(endTime : startTime : *ms)/group);
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 ntimes;
byvalue (varyingField);
endfor;
endTime = %timestamp();
t1 = (%diff(endTime : startTime : *ms)/group);
startTime = %timestamp();
for i = 1 to ntimes;
byconst (varyingField);
endfor;
endTime = %timestamp();
t2 = (%diff(endTime : startTime : *ms)/group);
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 ntimes;
byvalue (varyingField);
endfor;
endTime = %timestamp();
t1 = (%diff(endTime : startTime : *ms)/group);
startTime = %timestamp();
for i = 1 to ntimes;
byconst (varyingField);
endfor;
endTime = %timestamp();
t2 = (%diff(endTime : startTime : *ms)/group);
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 ntimes;
byvalue (varyingField);
endfor;
endTime = %timestamp();
t1 = (%diff(endTime : startTime : *ms)/group);
startTime = %timestamp();
for i = 1 to ntimes;
byconst (varyingField);
endfor;
endTime = %timestamp();
t2 = (%diff(endTime : startTime : *ms)/group);
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 ntimes;
byvalueC ('a');
endfor;
endTime = %timestamp();
t1 = (%diff(endTime : startTime : *ms)/group);
startTime = %timestamp();
for i = 1 to ntimes;
byconstC ('a');
endfor;
endTime = %timestamp();
t2 = (%diff(endTime : startTime : *ms)/group);
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 ntimes;
byvalueC (charField);
endfor;
endTime = %timestamp();
t1 = (%diff(endTime : startTime : *ms)/group);
startTime = %timestamp();
for i = 1 to ntimes;
byconstC (charField);
endfor;
endTime = %timestamp();
t2 = (%diff(endTime : startTime : *ms)/group);
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 ntimes;
byvalueC (charField);
endfor;
endTime = %timestamp();
t1 = (%diff(endTime : startTime : *ms)/group);
startTime = %timestamp();
for i = 1 to ntimes;
byconstC (charField);
endfor;
endTime = %timestamp();
t2 = (%diff(endTime : startTime : *ms)/group);
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 ntimes;
byvalueC (charField);
endfor;
endTime = %timestamp();
t1 = (%diff(endTime : startTime : *ms)/group);
startTime = %timestamp();
for i = 1 to ntimes;
byconstC (charField);
endfor;
endTime = %timestamp();
t2 = (%diff(endTime : startTime : *ms)/group);
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:
(If you wish to include the timings for your machine it is recommended that you call the program with no parameters. This will ensure all benchmark tests will be easily compared (10,000 calls per subprocedure, and time per 100 calls printed)
Version V5R2 Model 270 Times per 100 calls Passing the literal _a_ for 65535a varying... value: 152460 ms | const: 470 ms Passing a 65535a varying with 100a filled... value: 145350 ms | const: 440 ms Passing a 65535a varying with 1000a filled... value: 149180 ms | const: 340 ms Passing a 65535a varying with 65535a filled.. value: 224750 ms | const: 330 ms Passing the literal _a_ for 65535a... value: 188500 ms | const: 33620 ms Passing a 65535a with 100a filled... value: 96280 ms | const: 310 ms Passing a 65535a with 1000a filled... value: 96270 ms | const: 310 ms Passing a 65535a with 65535a filled... value: 96370 ms | const: 310 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