Appendices
Performance Matters
SORT
's of very large files often leave heavy footprints on the overall performance of an application. So much so, that this is often the first area examined, when addressing the imperative of improving performance.
CitSORT is fast, typically exceeding expectations in the area of performance. Below, we’ve constructed a test where we see a simple SORT of a 1 million-record sequential file being reduced from 46 seconds to 5 seconds using CitSORT.
Test:
Create a sequential file with 1,000,000 records, and use CitSORT to reverse the order of the records.
- Create the file to be sorted with the following code:
*
identification division.
program-id. labfile2.
environment division.
input-output section.
file-control.
select lab2fil assign to "lab2recs.txt"
organization is sequential
access is
sequential file
status is file-stat.
data division.
file section.
fd lab2fil.
01 lab2fil-record.
05 sequence-no pic 9(7).
05 name pic X(25).
05 addr pic X(25).
05 zip pic 9(10).
05 salary pic 9(7)V99.
*
working-storage section.
77 ws-dummy pic x.
77 file-stat pic xx.
procedure division.
main.
initialize sequence-no.
move all "A" to name.
move all "B" to addr.
move 1234567890 to zip.
move 9876543.21 to salary.
*
open output lab2fil.
perform load-file 1000000 times.
close lab2fil.
stop run.
*
load-file.
add 1 to sequence-no.
write lab2fil-record.
* display sequence-no line 10 col 10.
- Sort the file, reversing the order of the records, and record the time it takes with the following batch file:
Lab2a.bat
@echo off
now > begin2a.txt
citsort use lab2recs.txt record f 76 sort fields=(1,7,nu,d)
give lab2citsort.txt now >> begin2a.txt
type begin2a.txt
- Compare this with the performance achieved using the SORT verb in a COBOL program to perform the same function:
Use the following COBOL program for purposes of comparison:
IDENTIFICATION DIVISION.
PROGRAM-ID. lab2.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
*SORT input file
SELECT lab2fil assign to "lab2recs.txt"
ORGANIZATION IS SEQUENTIAL
ACCESS IS SEQUENTIAL
FILE STATUS is infile-stat.
*SORT output file
SELECT sortout assign to "testout.txt"
organization is SEQUENTIAL
ACCESS IS SEQUENTIAL
FILE STATUS IS outfile-stat.
*sort file (SD)
SELECT member-sort ASSIGN TO "sort-work".
DATA DIVISION.
FILE SECTION.
FD lab2fil.
01 lab2fil-record.
05 sequence-no pic 9(7).
05 name pic X(25).
05 addr pic X(25).
05 zip pic 9(10).
05 salary pic 9(7)V99.
FD sortout.
01 sortout-record.
05 out-sequence-no pic 9(7).
05 out-name pic X(25).
05 out-addr pic X(25).
05 out-zip pic 9(10).
05 out-salary pic 9(7)V99.
SD member-sort.
01 SORT-DATA.
05 sort-sequence-no PIC 9(7).
05 sort-filler PIC X(69).
*
WORKING-STORAGE SECTION.
77 infile-stat pic xx.
77 outfile-stat pic xx.
PROCEDURE DIVISION.
PRODUCT-LIST-SORT.
SORT member-sort
ON DESCENDING KEY sort-sequence-no
USING lab2fil
GIVING sortout.
- Compare the results:
Lab2b.bat
@echo off
now > begin2b.txt cobcrun lab2
now >> begin2b.txt type begin2b.txt