View previous topic :: View next topic |
Author |
Message |
rasprasads Beginner
Joined: 10 Dec 2002 Posts: 59 Topics: 20 Location: Chennai
|
Posted: Fri Feb 06, 2004 7:52 am Post subject: |
|
|
The performance is affected by large data processing. I changed the code to check from the end of line to first as the occurunce of this will be at the end. There was a slight improvement in performance. Any other ideas to improve the performance ? _________________ Rasprasad S |
|
Back to top |
|
 |
Mike Chantrey Intermediate
Joined: 10 Sep 2003 Posts: 234 Topics: 1 Location: Wansford
|
Posted: Fri Feb 06, 2004 9:03 am Post subject: |
|
|
The example uses subscripts. You will probably get at least some (and maybe quite a lot of) performance improvement using indexes instead. Also, you should probably be specifying OPTIMIZE, TRUNC(OPT) and NOSSR compiler options (or the equivalent for your compiler - these are COBOL II). |
|
Back to top |
|
 |
rasprasads Beginner
Joined: 10 Dec 2002 Posts: 59 Topics: 20 Location: Chennai
|
Posted: Fri Feb 06, 2004 9:24 am Post subject: |
|
|
Mike, Do you suggest to use a array. I do not get what you mean by Index. Please explain. _________________ Rasprasad S |
|
Back to top |
|
 |
Mike Chantrey Intermediate
Joined: 10 Sep 2003 Posts: 234 Topics: 1 Location: Wansford
|
Posted: Fri Feb 06, 2004 10:14 am Post subject: |
|
|
You can define your character strings as indexed arrays, i.e. PIC X OCCURS nnn INDEXED by INDEX-NAME.
I slightly misunderstood the sample code because it was using names like 'WS-SUB' so I thought it was using subscripting but in fact it's using reference modification (as per the :1 stuff). So you may not benefit much from indexing; I've never compared it with ref mod. Also you can't directly replace the :4 ref mod with an index use. So maybe it's not worth trying.
But I'd certainly give the compiler options a go. |
|
Back to top |
|
 |
Mike Chantrey Intermediate
Joined: 10 Sep 2003 Posts: 234 Topics: 1 Location: Wansford
|
Posted: Fri Feb 06, 2004 10:23 am Post subject: |
|
|
Also, I think the following code from kolusu's example could be changed from Code: |
PERFORM VARYING WS-SUB FROM 1 BY 1 UNTIL WS-SUB > 192
INITIALIZE WS-POS1 WS-POS2 WS-NUM
IF WS-ADD(WS-SUB : 1) = '-' AND WS-SUB > 5
COMPUTE WS-POS1 = WS-SUB - 5
MOVE WS-ADD(WS-POS1 : 5) TO WS-NUM
IF WS-NUM IS NUMERIC
|
to
Code: |
MOVE WS-ADD(1 : 5) TO WS-REPL-STRING(1 : 5)
PERFORM VARYING WS-SUB FROM 6 BY 1 UNTIL WS-SUB > 192
IF WS-ADD(WS-SUB : 1) = '-'
COMPUTE WS-POS1 = WS-SUB - 5
IF WS-ADD(WS-POS1 : 5) IS NUMERIC
|
without affecting the function (Kolusu might like to verify if this is true since I haven't tested it! Sorry if I have messed it up).
The INITIALIZE wasn't necessary since the variables involved are assigned to before use; WS-NUM was an intermediate variable which can be eliminated; the WS-SUB > 5 test each time round the loop can be eliminated by starting WS-SUB at 6 and moving the first 5 chars before the loop starts (this replicates the fact that in the original code, only the final ELSE clause got get executed while WS-SUB was 1,2,3,4 or 5).
This is not a criticism of Kolusu's code since the original is probably clearer and easier to change. But it should speed it up at bit. |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12384 Topics: 75 Location: San Jose
|
Posted: Fri Feb 06, 2004 10:57 am Post subject: |
|
|
Mike,
I like constructive criticism and thanks for the tip of trimming my code. As you said the code posted earlier is clear and easier to UNDERSTAND as well as to maintain. I agree that Initialize is unnecessary, but it is just me who wants every field clean before manipulating them.
Actually you can clean up some more fields. You really don't need ws-pos1 & ws-pos2 and ws-num.
The perform should always start from position 1 unless you move the first 5 bytes to the output string before the perform loop. This is a case when the first occurance is a match.
Modified code
Code: |
MOVE WS-ADD(1 : 5) TO WS-REPL-STRING
PERFORM VARYING WS-SUB FROM 6 BY 1 UNTIL WS-SUB > 192
IF WS-ADD(WS-SUB : 1) = '-'
IF WS-ADD(WS-SUB - 5 : 5) IS NUMERIC
MOVE '- ' TO WS-REPL-STRING (WS-SUB : 5)
COMPUTE WS-SUB = WS-SUB + 4
ELSE
MOVE WS-ADD(WS-SUB : 1)
TO WS-REPL-STRING(WS-SUB : 1)
END-IF
ELSE
MOVE WS-ADD(WS-SUB : 1)
TO WS-REPL-STRING(WS-SUB : 1)
END-IF
END-PERFORM
DISPLAY WS-REPL-STRING
|
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
|
|