View previous topic :: View next topic
|
Author |
Message |
vicky10001 Warnings : 1 Active User
Joined: 13 Jul 2005 Posts: 136
|
|
|
|
I am reading input file and moving record to INFILEREC and counting word in inspect statement as below. The infile length has 32k.
INSPECT INFILEREC TALLYING WS-COUNT
FOR ALL X'F34567057C70045"
This statement was consuming more cpu time. I need to reduce the cpu time. can we do this statment in perform statment or we can change any compiler parameter please let me know thanks in advance |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
vicky10001 wrote: |
I am reading input file and moving record to INFILEREC and counting word in inspect statement as below. The infile length has 32k.
INSPECT INFILEREC TALLYING WS-COUNT
FOR ALL X'F34567057C70045"
This statement was consuming more cpu time. I need to reduce the cpu time. can we do this statment in perform statment or we can change any compiler parameter please let me know thanks in advance |
Please use cut and paste for your code samples, your literal starts with a single quote and ends with a double quote and contains 7 and a half bytes. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
disregarding the fact that X'F34567057C70045" will not compile.....
(vicky10001, you can avoid these errors if you would cut/paste or at least proof your typing)
you are essentially making 32k - 7(or 8) compares on each record.
Quote: |
This statement was consuming more cpu time. |
the above statement, not only grammatically incorrect,
is meaningless.
unless you are using a COBOL version older than COBOL II,
the INSPECT statement is going to be hard to outperform.
how would you code a perform statement? - yes it can be done.
do you really need a count, or just an affirmation that the search key
actually exists in the record.
if you only need to know that it is present in the record,
suggest you use the SS operator of a DFSORT INCLUDE or OMIT statement. and even with a SORT product, you have a length problem.
also, since you have a 32k length record, you are talking about 8 pages for each record.
are you sure that you don't have a lot of page swapping going on.
you are essentially stuck with the performance provided by processing so many bytes.
but, are you sure that the big performance problem is really the INSPECT? |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
Run SORT with:
Code: |
INCLUDE COND=(1,32752,SS,EQ,X'F34567057C70045')
SORT FIELDS=COPY |
Compare the SORT time with your COBOL program time.
Show us your results.
NB. 32752 is the maximum value (in SYNCSORT). |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
vicky10001 wrote: |
I am reading input file and moving record to INFILEREC and counting word in inspect statement as below. The infile length has 32k.
INSPECT INFILEREC TALLYING WS-COUNT
FOR ALL X'F34567057C70045"
This statement was consuming more cpu time. I need to reduce the cpu time. can we do this statment in perform statment or we can change any compiler parameter please let me know thanks in advance |
How many records are you processing? If performance is important to you, why MOVE the input record anywhere? That's a 32K move which is not needed.
What is the purpose of counting this collection of values? Why can't whatever stuck it in there tell you that it has done that and, if necessary, how many times. The best way to search for something is not to lose it in the first place. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
I don't have access to a COBOL compiler, so could you try something.
Code: |
03 WS-INFILE-REC PIC X(32767).
03 WS-INSPECT-REC PIC X(768).
03 WS-COUNT PIC 9(08) BINARY.
MOVE WS-INFILE-REC TO WS-INSPECT-REC.
MOVE ZERO TO WS-COUNT.
INSPECT WS-INSPEC-REC TALLYING WS-COUNT FOR ALL 'X'F34567057C70045.
|
Compile the program using LIST,NOOFFSET and then see if the generated Assembler code keeps the INSPECT (which will probably be three Assembler TR instructions, each for 256-bytes), in-line, without calling a COBOL Run-Time routine.
The COBOL compiler guys seem to have 768 as a limit before calling a Run-Time routine associated with an INSPECT.
Thanks,
Mr. Bill |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
I think it is going to be hard to beat the INSPECT time for this with Cobol code.
You can show us your compile options, explain why you are counting the values, how many records, and we can see if there are suggestions.
I still say if the program that puts the data in records that it has done it, you'll use very little time searching for the data. |
|
Back to top |
|
|
vicky10001 Warnings : 1 Active User
Joined: 13 Jul 2005 Posts: 136
|
|
|
|
Input file size is 32k and file format is VBA. We are reading input file and checking this value X'D3089204C7020C' in file and replacing spaces. We are doing 8 times in process becuase we are checking 8 different values in same file.
Code:
05 WS-KEy-VALUE1 PIC X(07) VALUE X'D3089204C7020C'.
05 WS-KEy-VALUE2 PIC X(07) VALUE X'D3089204C7020C'.
.....
05 WS-KEy-VALUE8 PIC X(07) VALUE X'D3089204C7020C'.
INSPECT WS-INREC TALLYING WS-COUNT
FOR ALL WS-KEy-VALUE1.
IF WS-COUNT > 0
MOVE 9 TO WS-OFFSET
PERFORM WS-COUNT TIMES
INSPECT WS-INREC(WS-START:)
TALLYING WS-CHAR-CNT
FOR CHARACTERS BEFORE INITIAL WS-KEYLINE-POS1
COMPUTE ADDCOUNT = WS-CHAR-CNT + WS-OFFSET
COMPUTE WS-KEYCOUNT = ADDCOUNT + 2
IF WS-INREC(WS-KEYCOUNT:1) = '-'
PERFORM UNTIL WS-INREC(ADDCOUNT:1) = X'03'
MOVE SPACES TO WS-INREC(ADDCOUNT:1)
ADD 1 TO ADDCOUNT
END-PERFORM
MOVE ADDCOUNT TO WS-START
MOVE 12 TO WS-OFFSET
END-IF
END-PERFORM
ENDIF
-------
-------
Stobe is pointing 30% in inspect location. Could you please let me know if we can modify perform instead of inspect. or any idea. Thanks in advance |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
It is really still not clear what you are doing.
Are you replacing your weird seven-byte value by spaces everywhere it occurs in the input record? What is wrong with REPLACING, why do you need to know how many?
For each input record your INSPECT is doing 32760 (approx) comparisons to count the occurences of the value you are looking for (as dbz pointed out yesterday).
If you are doing that eight times for each record (though the values you show are the same, so I don't know if it is just poor description) that is close to 1/4 million comparisons.
That is going to take some time.
You then have another inspect firing up for some reason.
Is there much else going on in the program? Is it read, change, write?
How many records, asked again.
Compile options, asked again.
I do not think you will get faster than your INSPECT TALLYING to provide a count. I've tried, and I can get 4-17 times slower. Even if what I have is subject to "tuning", it is not going to approach the INSPECT. I have one more idea, but if I do it, it'll be just to do it, not in the hope of beating the INSPECT.
It is calling a sub-routine. It calls it once. It appears to be pretty slick, given what it is doing.
If all you are doing in the program is the above, I think I'd want to look at a SORT solution, with FINDREP, for instance. |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
Your code is confusing (and confused). Too bad you didn't use BBCode.
What is WS-KEYLINE-POS1 ?
If you find the string X'D3089204C7020C' then you move spaces somewhere else ? |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Code: |
INSPECT WS-INREC TALLYING WS-COUNT
FOR ALL WS-KEy-VALUE1.
IF WS-COUNT > 0
MOVE 9 TO WS-OFFSET
PERFORM WS-COUNT TIMES
INSPECT WS-INREC(WS-START:)
TALLYING WS-CHAR-CNT
FOR CHARACTERS BEFORE INITIAL WS-KEYLINE-POS1
COMPUTE ADDCOUNT = WS-CHAR-CNT + WS-OFFSET
COMPUTE WS-KEYCOUNT = ADDCOUNT + 2
IF WS-INREC(WS-KEYCOUNT:1) = '-'
PERFORM UNTIL WS-INREC(ADDCOUNT:1) = X'03'
MOVE SPACES TO WS-INREC(ADDCOUNT:1)
ADD 1 TO ADDCOUNT
END-PERFORM
MOVE ADDCOUNT TO WS-START
MOVE 12 TO WS-OFFSET
END-IF
END-PERFORM
ENDIF |
This is what the "code tags" do for your spacing.
I'd guess a lot could be done with the above, with full knowledge of the requirement. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Method 5 doesn't do it either.
Re-do your data analysis to find a way to limit the records you have to search in their entirety.
A "quick and dirty" would be to use Sort to include all the records which have one of your values. Then, by key (unlikely you have one?) or by record number, do a two-file-match in your program and then only do the INSPECT on those records you know contain at least one value.
You are not going to beat that INSPECT with Cobol code. If you come up with a different INSPECT, it may be a different answer, but you are not going to beat that one.
Reference-modification turned out to be the second slowest method. You might want to change to using an INDEX. I don't know why you chose reference-modification - easier to code? |
|
Back to top |
|
|
|