Path: utzoo!attcan!uunet!zaphod.mps.ohio-state.edu!ncar!csn!ccncsu!lamar!mglacy From: mglacy@lamar.ColoState.EDU Newsgroups: comp.lang.pascal Subject: proc calls Message-ID: <12583@ccncsu.ColoState.EDU> Date: 6 Feb 91 14:35:23 GMT Sender: news@ccncsu.ColoState.EDU Reply-To: mglacy@lamar.ColoState.EDU () Distribution: na Organization: Colorado State University, Fort Collins, CO 80523 Lines: 43 I have a fair sized numerical analysis program I'm working on. In the middle of it is the workhorse procedure that eats up about 90% of run time. 'workhorse' looks something like this: PROCEDURE workhorse; procedure A begin if some condition call A {recursively} else do a bunch of calculations I'll call C end;{A} begin {main part of workhorse} initlz; Do procedure A process results of A end; {workhorse} Here's the thing: In the interests of style, I decided to make the bunch of calculations C into a procedure. This necessitates passing a number of parameters, including a big array {ca 50k elements}. To avoid excess memory use, particularly given the recursive calls of A, I made the big array a VAR parameter. (In the original version above, I just left the big array as global to procedure workhorse). The program works either way but: 1. both versions run equally fast under turbo pascal 4.0 2. but using a vax running VMS and IBM AIX system, the second version, with the procedure for the set of calculations C, runs about 30% slower. Question: Can anybody explain this to me---I have a hard time imagining that some parameter passing and proc calls would eat up about 30% as much time as the whole workhorse procedure. I've tried the optimizing compiler option on the IBM AIX system, with function/procedures results put into special registers, etc. Still, the TP compiler seems to be the only one that will me to improve the style of the program without a major sacrifice in execution time. Enlightment would be appreciated.