comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: Efficiency and overhead: Ada.Containers.Vectors.vector versus array type
Date: Sat, 21 Jan 2012 18:40:52 +0000
Date: 2012-01-21T18:40:52+00:00	[thread overview]
Message-ID: <m2ipk4dhl7.fsf@pushface.org> (raw)
In-Reply-To: a011aaef-8ce5-4256-96e3-b2813dc101db@n6g2000vbz.googlegroups.com

Ada BRL <ada.brl.2011@gmail.com> writes:

> I need some hints about Ada.Containers.Vectors.vector efficiency.
>
> I'm developing a multithreaded real time application in Ada.
>
> I need a "collection" of objects (every object has a lot of records
> like task objects, Gnat.Sockets and so on...);
> This collection is accessed several times during the execution.  In
> the meantime I don't have to insert and delete any items during the
> execution, I just need to instantiate N object when the application
> starts and then the number of objects will remain the same throughout
> the execution.
>
> Since I know how many object will be inside the collection I thought
> to use, as the collection I need, the "array standard type".  In the
> meanwhile the Ada.Containers.Vectors.vector object is far more
> practical, simple and has even more interesting and useful functions
> like iterators and so on.
>
> For this reason, since I don't have any experience in Ada, I ask you
> all what can you suggest me to use.
> If there is no such difference in efficiency/overhead between array
> types and Ada.Containers.Vectors.vector I'll definitely use the
> latter.

It's bound to take longer to, for example, iterate over a Vector than to
loop over an array. The question is, how much longer? and is that
acceptable for your proposed usage?

I'd have thought the actual operations you want to do on your objects
would be independent of the storage mechanism, so maybe you could use
the Vectors first, do some measurements, and see if that will be
adequate.

I'd  start by something like creating an Indefinite_Vector of Strings,
populating it with say 1000 strings, and seeing how long it takes to
iterate over it. I'd expect it to be sub-microsecond per element, on a
modern processor (but I could be wrong!)

One thing to be wary of: an object with an embedded task will be
limited, which means you can't hold it directly in any of the standard
Containers; you'd have to hold access-to-object (or
access-to-object'Class if you have tagged types). This means you'll need
to do storage management yourself, perhaps using Ada.Finalization.



  reply	other threads:[~2012-01-21 18:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-21 18:19 Efficiency and overhead: Ada.Containers.Vectors.vector versus array type Ada BRL
2012-01-21 18:40 ` Simon Wright [this message]
2012-01-21 19:11 ` Jeffrey Carter
2012-01-22 15:05   ` Ada BRL
replies disabled

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