From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,123c40d62c632159 X-Google-Attributes: gid103376,public From: Dale Stanbrough Subject: Re: Stack based allocation vs. Dynamic allocation Date: 2000/05/31 Message-ID: #1/1 X-Deja-AN: 629429366 References: X-Trace: 31 May 2000 22:22:35 +1000, r1021c-02.ppp.cs.rmit.edu.au Organization: RMIT User-Agent: MT-NewsWatcher/3.0 (PPC) Newsgroups: comp.lang.ada Date: 2000-05-31T00:00:00+00:00 List-Id: Ray Blaak wrote: > Well the code you posted has the heap version working with much smaller > arrays > (500 vs 1 million), so of course it will be faster. > > Fix the Heap version to have the same array type as in the Stack version > and try again. I am interested in the answer. Well Ray was very correct, and i was very wrong! I must apologise for submitting such obviously bad code. I've fixed the code, and added in a few extras. I have compared various variations of the code (in C and in Ada), the results follow... Ada Stack -- allocating fixed size array real 17.5 user 16.5 sys 0.0 C Stack -- allocating fixed size array real 17.0 user 16.2 sys 0.0 Ada Heap -- allocating fixed size array real 20.3 user 18.8 sys 0.0 C Heap -- allocating fixed size array real 30.6 user 28.1 sys 0.0 Ada Heap Unconstrained -- allocating fixed sized unconstrained array real 35.4 user 34.1 sys 0.0 Ada Heap Unconstrained Changing -- alternating b/w allocating 1E6/3, 1E6 *3 size arrays real 56.0 user 52.3 sys 0.1 Ada Stack Unconstrained Changing -- alternating b/w allocating 1E6/3, 1E6 *3 size arrays real 28.2 user 26.3 sys 0.1 All compiled with gnat 3.12/gcc, on Solaris Not quite sure why the unconstrained version should be so much more expensive. Interesting to note of course that the Ada heap version is -so- much cheaper than the C version. Presumably they are calling different allocators. Dale