Code Comments
Programming Forum and web based access to our favorite programming groups."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
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.