comp.lang.ada
 help / color / mirror / Atom feed
From: Dale Stanbrough <dale@cs.rmit.edu.au>
Subject: Re: Stack based allocation vs. Dynamic allocation
Date: 2000/05/31
Date: 2000-05-31T00:00:00+00:00	[thread overview]
Message-ID: <dale-B8D55E.22230631052000@news.rmit.edu.au> (raw)
In-Reply-To: m33dmz9otb.fsf@ns49.infomatch.bc.ca

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




  reply	other threads:[~2000-05-31  0:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-05-31  0:00 Stack based allocation vs. Dynamic allocation dale
2000-05-31  0:00 ` Aaro Koskinen
2000-05-31  0:00 ` Ray Blaak
2000-05-31  0:00   ` Dale Stanbrough [this message]
2000-05-31  0:00     ` Laurent Guerby
2000-06-01  0:00       ` Matthew Woodcraft
2000-06-01  0:00         ` Laurent Guerby
2000-06-05  0:00     ` Robert Dewar
2000-05-31  0:00   ` Gisle S�lensminde
2000-05-31  0:00     ` Aaro Koskinen
2000-05-31  0:00     ` Lutz Donnerhacke
2000-05-31  0:00       ` Gisle S�lensminde
2000-05-31  0:00 ` Jean-Pierre Rosen
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox