Page 1 of 1

Cobol program performance Improvement

PostPosted: Mon Mar 24, 2008 1:27 pm
by anoopm7
Hi all,

I want to reduce the CPU usuage by my cobol program. The program mainly utilises the CPU time to EVALUATE using a WHEN statment which repeats for 140times thus causing the program to run for a longer time.
Please tell me how i can replace the WHEN statment and put a more effective wayb of doing it.

eg:

WHEN 127
ADD +1 TO WS-127-CT
WHEN 128
ADD +1 TO WS-128-CT
WHEN 129
ADD +1 TO WS-129-CT
WHEN 130
ADD +1 TO WS-130-CT

It goes on checking from 0-140.

Re: Cobol program performance Improvment.

PostPosted: Mon Mar 24, 2008 10:12 pm
by dick scherrer
Hello,

Set up an array and use the "when" value as a subscript rather than using the evaluate.

Re: Cobol program performance Improvment.

PostPosted: Fri Mar 28, 2008 4:33 pm
by anoopm7
Appreciate your timely response.

Could any one suggest me few CPU usage optimiaztion techniques. This would be highly helpful as iam now doing a performance check for my programs.


Thanks
Anoop ;)

Re: Cobol program performance Improvment.

PostPosted: Fri Mar 28, 2008 10:04 pm
by dick scherrer
Hello,

The way this sort of thing is typically done is to work with the performance measurement people for your system and identify which parts of the code use the most resources (if there is an interest in this level of performance measurement, they will have tools to use to measure). Once the "heavy" user sections of code are identified, they can be reviewed to see how they process and how they might possibly be improved.

Most performance improvements are made by changing the way i/o is done or the way database activity is done.

Keep in mind that it is more important that the code always executes correctly and that the code is maintainable.

Re: Cobol program performance Improvment.

PostPosted: Sun Jul 20, 2008 6:31 am
by pi17388
Excessive/Unnecessary CPU time in cobol is consumed by compiler generated statements involved in packing/unpacking numeric fields. If you compile your programs with options that produce the assembler code for the program (options vary by compiler) you can rather quickly see which cobol statements are generating assembler statements that could be eliminated by simply changing the definition of the target/source data items.

There are a number of cpu saving techniques depending on the type of program but I would wholehartedly agree with the comment about I/O -- there's an old adage, "the fastest I/O is the one you never do", so if your program is I/O intensive and you want to reduce elapsed time (and svc/system cpu time) -- find ways to do less I/Os.

Re: Cobol program performance Improvment.

PostPosted: Mon Jul 21, 2008 5:08 pm
by jayind
Few other reasons I came across... (unnecessary I/Os as explained by Dick)

1. Bad SQL statements - having wildcard where clauses, improper optimizing path,
2. Unnecessary file reads - unnecessary loops, unnecessary reads,
3. sharing of files - improper scheduling of jobs causing contention

etc..

Hope these make sense...

regards,
jayind