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: Ray Blaak Subject: Re: Stack based allocation vs. Dynamic allocation Date: 2000/05/31 Message-ID: #1/1 X-Deja-AN: 629348645 Sender: blaak@ns49.infomatch.bc.ca References: X-Trace: news.bc.tac.net 959756948 207.34.170.113 (Wed, 31 May 2000 00:09:08 PDT) NNTP-Posting-Date: Wed, 31 May 2000 00:09:08 PDT Newsgroups: comp.lang.ada X-Complaints-To: news@bctel.net Date: 2000-05-31T00:00:00+00:00 List-Id: dale writes: > A discussion at work left me claiming that stack based allocation > was quicker than heap based allocation. > > A person wrote up a demonstration program that proved that this > wasn't the case (at least for the experiment). [...] > procedure Stack is > N : constant := 500; > Big : constant := 1024 ** 2; > type ints is array (0 .. Big) of Integer; [...] > procedure Heap is > N : constant := 500; > Big : constant := 1024 ** 2; > type ints is array (0 .. N - 1) of integer; > > Does anyone know what the factors are that would cause stack > allocation to be so slow? 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. -- Cheers, The Rhythm is around me, The Rhythm has control. Ray Blaak The Rhythm is inside me, blaak@infomatch.com The Rhythm has my soul.