Which is better in terms of performance? "if else" or "Evaluate" statement in COBOL? -


which better in terms of performance ? "if else" or "evaluate" statement in cobol, when have lesser conditons check ?

it seems have doubter op, here's example ibm enterprise cobol:

    01  pic 9.      procedure division.         accept          if equal 2              continue          else               continue          end-if          evaluate            when 2               continue            when other               continue          end-evaluate  

and here code generated. don't need know ibm mainframe assembler, have note things same:

000008  if                                                                        0002f8  d200 d0f8 8000          mvc   248(1,13),0(8)          ts2=0            0002fe  96f0 d0f8               oi    248(13),x'f0'           ts2=0            000302  95f2 d0f8               cli   248(13),x'f2'           ts2=0            000306  4770 b126               bc    7,294(0,11)             gn=4(00030e)  000009  continue                                                                  00030a  47f0 b126               bc    15,294(0,11)            gn=5(00030e)     00030e                 gn=4     equ   *                                     000011  continue                                                                  00030e                 gn=5     equ   *                                     000013  evaluate                                                               000014  when                                                                      00030e  d200 d0f8 8000          mvc   248(1,13),0(8)          ts2=0            000314  96f0 d0f8               oi    248(13),x'f0'           ts2=0            000318  95f2 d0f8               cli   248(13),x'f2'           ts2=0            00031c  4770 b13c               bc    7,316(0,11)             gn=12(000324) 000015  continue                                                                  000320  47f0 b13c               bc    15,316(0,11)            gn=11(000324)    000324                 gn=12    equ   *                                     000016  when                                                                   000017  continue                                                                  000324                 gn=11    equ   *      

continue, generates no instructions, used keep things simple both "legs" in if , evaluate.

there no reason believe code generated non-ibm compiler differ 2 examples.

if don't have energy respond questions or make comments if unclear, don't expect in future when summon energy ask question.

back original...

if have performance problem in cobol program highly unlikely down use of if or evaluate per se.

evaluate can used direct replacement nested-if.

if find old nested-if this:

if     else     if b             else         if c                     else             if d                             else                 if e                     something. 

or, this:

if     else if b     else if c     else if d     else if e     something. 

you can know old code, because of full-stop/period.

nested-ifs in new code better evaluate.

there should no real overlap between usage, not problematic performance point of view if there is.

i don't know compilers, not surprised if if/else generates identical code simple evaluate/when/when other.

if have performance problem, logic.

if thinking of "optimising" cobol program make somehow better, forget it. logic straight , understandable. make program maintainable.

if want know making programs run little faster (and emphasis may on a little) write test programs manipulations of numeric fields of different types (usage display vs packed-decimal/comp-3 vs binary/comp/various other non-floating-point comp options provided compiler).

check them out subscripting, counting, accumulating values decimal places, computations multiple sources. you'll know how define fields purpose have, , won't have consider afterwards.

if have site standards are, use them.

don't write cobol programs , sit down once working , "now optimise it". it's not do.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -