For Programmers: Free Programming Magazines  


Home > Archive > Cobol > July 2005 > Re: Is it always possible to write a COBOL program using only 1 sentence per paragrap









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Is it always possible to write a COBOL program using only 1 sentence per paragrap
Rick Smith

2005-07-24, 10:01 pm


"Pete Dashwood" <dashwood@enternet.co.nz> wrote in message
news:3k86utFl4gssU1@individual.net...
>
> "Clark Morris" <cfmtech@istar.ca> wrote in message
> news:e1atd11fi2cshuqsgg11l78qp1n840102p@
4ax.com...
> <snip>>>
>
> Yes, necessarily. :-) Three factors affect online performance; two of

them
> are load time and capture time. The smaller and tighter a module is, the
> quicker it loads and it will be likely to require less capture time.
>
> Capture time for a process will be improved if there is less code for the
> process to execute (as long as it provides the same functionality, of
> course.)
>
> Adding code cannot possibly make it execute any faster than it is required
> to. And if everything else is equal, the faster load time of a smaller
> module makes overall execution quicker. If a small module is being paged

in
> and out continually, as opposed to a large resident piece of code, then

the
> overall execution of the small module functionality may be longer, but

that
> implies that the large piece of code is doing more (otherwise, why is it

so
> large?), so the comparison is between apples and oranges
>
> Given identical functionality and identical residence, the smaller the

code
> is, the quicker it will execute. Invariably.


Perhaps, Mr Dashwood, you had some additional restrictions
in mind; but there are cases where larger code, with 'identical
functionality', will execute faster.

The following program has two procedures to determine the
length of text (a string). The procedures have 'identical functionality',
in that they each accept a 32 character item and return its length
(the position of the last non-space character). They also function
identically by examining the 32 character item, in reverse, one
character at a time. Yet the larger procedure outperforms the smaller.

Test program
--------
program-id. unroll.
data division.
working-storage section.
1 str pic x(32) value space.
1 strlen-1 comp-5 pic 9(4) value 0.
1 strlen-2 comp-5 pic 9(4) value 0.
1 time-1.
2 time-1-hour pic 99.
2 time-1-minute pic 99.
2 time-1-second pic 99v99.
1 time-2.
2 time-2-hour pic 99.
2 time-2-minute pic 99.
2 time-2-second pic 99v99.
1 time-3.
2 time-3-hour pic 99.
2 time-3-minute pic 99.
2 time-3-second pic 99v99.
1 elapsed-time pic 9(7)v99.
1 elapsed-time-display pic z(6)9.99.
procedure division.
mainline section.
move spaces to str
perform time-test
move 'a' to str (16:1)
perform time-test
move 'a' to str (32:1)
perform time-test
stop run
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com