A comparison of the effects of structured vs. non-structured and modularized vs. non-modularized programs on run time (abstract only)

This paper presents the basis for analytical research, examining the various effects of modifying or amending a particular program in both its basic structure and its degree of modularity on its ultimate run time. We begin with a program which produces as output a series of tables of high card and distribution counts of 1000 bridge hands. The deal of each bridge hand is accomplished by a random number generator function and the program employs a test module to ascertain valid results.The original program is written in TURBO PASCAL with a high degree of modularity. It is later modified by an “unwrapping process” to produce a less modularized program which effects the same results as the original. The comparison of source lines of code, degree of modularity, number of modules, and run time in addition to actual output are noted and analyzed. The programs were executed on an IBM PC.The original program contains 272 lines of code, six procedures (in addition to the main control module), and has an execution time of approximately 12 minutes. The first of the six procedures is the deal of the cards (which is invoked once per iteration, for a total of 1000 calls). The next three procedures are counting modules (each of which is invoked four times per iteration for a total of 12000 calls). The fifth procedure is a test module which supplies the programmer with a sample hand and counting data for validation purposes (which is invoked once per 100 deals for a total of 10 calls). Finally, the sixth procedure is one which computes frequency data (and is invoked a total of 6 times after the 1000 deal iteration has terminated).The program is highly structured with a complexity measure of 212. Due to its high degree of modularity, it can be read and debugged with little or no difficulty.The less modularized version is acquired by an unwrapping process as follows: The deal procedure is eliminated and its code is placed directly in the main module;The three counting modules are no longer invoked as procedures but are instead placed within the main module. Since each of these three modules had been called four times per iteration (once per each bridge hand) this results in four times as much code;The test and frequency modules are left intact.This version of the program contains 373 lines of code, two procedures (in addition to the main control module), and has an execution time of approximately 13 minutes. The first procedure is the test module (which as before is invoked once per 100 deals for a total of 10 calls). The second procedure is the frequency procedure (invoked six times after the 1000 deal iteration). The main module is now much larger than in the original version, having absorbed four procedures with a high degree of repetition of code.This program contains a complexity measure of 316. Due to its lack of modularity and much higher sloc and complexity measures, its readability and facility for debugging are greatly reduced. It is especially noteworthy that the unwrapped version of the program, although containing 13000 less procedure calls than the original, did not have a shorter run time than the original. A summary of the results: