| Robert Wagner 2004-05-25, 1:30 pm |
| * compile: cob -xg testcall.cbl testcal1.cbl
* cob -zg testcal2.cbl
* cob -zg timer.cbl
$set mfoo
$set sourceformat(free)
* The only case speeded up by these was Entry.
$SET NOBOUND OPT(2) NOTRUNC IBMCOMP
$SET NOCHECK NOPARAMCOUNTCHECK FASTCALL NOREENTRANT
$SET NOSERIAL NOFIXOPT FASTLINK
identification division
. program-id. testcall
* author. Robert Wagner
* Testing speed of a call.
* Results: time per call in nanoseconds, minus loop overhead
* 0. Loop overhead 16
* 1. Perform 8
* 2. Nested program 44
* 3. Static link 214
* 4. ENTRY 313
* 5. Dynamic link 4684
* 6. OO dynamic 5484
* 6. OO static 535
. class-control
. timer is class 'timer'
. data division
. working-storage section
. 01 repeat-factor value 100000000 comp pic s9(15)
. 01 testcal2 value 'testcal2' pic x(08)
. 01 parameter value 'abc' pic x(03)
. 01 loop-overhead value zero pic 9999
. 01 timer-variables
. 05 a-timer object reference
. 05 elapsed-time comp pic s9(09)
. 05 elapsed-time-edited pic zzzz
. linkage section
. 01 input-parameter pic x(03)
. procedure division.
invoke timer 'new' returning a-timer
display '0. Loop overhead ' with no advancing
perform timer-on
perform repeat-factor times
* continue *> runs the same with or without this
end-perform
perform timer-off
move elapsed-time-edited to loop-overhead
display '1. Perform ' with no advancing
perform timer-on
perform repeat-factor times
set address of input-parameter to address of parameter
perform a-paragraph
end-perform
perform timer-off
display '2. Nested program' with no advancing
perform timer-on
perform repeat-factor times
call 'test-call-3' using parameter
end-perform
perform timer-off
display '3. Static link ' with no advancing
divide 10 into repeat-factor
perform timer-on
perform repeat-factor times
call 'testcal1' using parameter
end-perform
perform timer-off
display '4. ENTRY ' with no advancing
perform timer-on
perform repeat-factor times
call 'entry-procedure' using parameter
end-perform
perform timer-off
display '5. Dynamic link ' with no advancing
divide 10 into repeat-factor
perform timer-on
perform repeat-factor times
call testcal2 using parameter
end-perform
perform timer-off
display '6. OO ' with no advancing
perform timer-on
perform repeat-factor times
invoke a-timer 'test-call-4' using parameter
end-perform
perform timer-off
goback
. a-paragraph.
continue
. end-paragraph
. entry 'entry-procedure' using input-parameter
goback
. timer-on.
invoke a-timer 'start'
. timer-off.
invoke a-timer 'stop' returning elapsed-time
compute elapsed-time-edited rounded =
(elapsed-time * (1000000000 / repeat-factor) / 100)
- loop-overhead
display elapsed-time-edited
. identification division
. program-id. test-call-3
. data division
. linkage section
. 01 input-parameter pic x(03)
. procedure division using input-parameter
. goback
. end program test-call-3
. end program testcall
|