Listing 2. Benchmark code listing
identification division.
program-id. bench.
environment division.
input-output section.
file-control.
select sdf-file-in assign to sdf-file-in
organization is line sequential.
select isam-file assign to isam-file
organization is indexed
record key field-1
alternate record key field-3 with duplicates
file status is isam-file-status.
data division.
file section.
fd sdf-file-in
value of file-id is "../dbman/test.sdf".
01 dbase-rec-in.
03 field-1-in pic 9(7).
03 field-2-in pic x(81).
03 field-3-in pic 9(8).
fd isam-file
value of file-id is "isam".
01 isam-rec.
03 field-1 pic 9(8) comp-4.
03 field-2 pic x(81).
03 field-3 pic 9(8).
working-storage section.
77 any-key pic x.
88 eof value '1'.
77 time-x pic 9(8).
77 x_s pic x(81).
77 x_y pic x(81).
77 x_a pic s9(8) comp-5.
77 isam-file-status pic xx.
procedure division.
opening-para.
accept time-x from time.
display time-x.
open input sdf-file-in
output isam-file.
move zero to any-key.
perform until eof
read sdf-file-in at end move '1' to any-key
not end
move field-1-in to field-1
move field-2-in to field-2
move field-3-in to field-3
write isam-rec
invalid key display field-1-in field-1 isam-file-status
accept omitted
end-write
end-read
end-perform.
close sdf-file-in isam-file.
accept time-x from time.
display time-x.
open i-o isam-file.
move "seed" to x_s.
move zero to x_a, field-1.
start isam-file key >= field-1
invalid key display "something seriously wrong".
move zero to any-key.
perform until eof
read isam-file next at end move '1' to any-key
not end
move field-2 to x_y
move x_s to field-2
rewrite isam-rec
invalid key display "something seriously wrong"
end_rewrite
move x_y to x_s
compute x_a = x_a + field-1 / 1000
end-read
end-perform.
accept time-x from time.
display time-x.
move zero to field-1.
start isam-file key >= field-1
invalid key display "something seriously wrong".
move zero to any-key.
perform until eof
read isam-file next at end move '1' to any-key
not end
delete isam-file
end-read
end-perform.
accept time-x from time.
display time-x.
accept omitted.
close isam-file.
stop run.
Copyright © 1994 - 2018 Linux Journal. All rights reserved.