comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <spam@spam.com>
Subject: Re: This can't be done in Ada...or?
Date: Wed, 16 Feb 2005 00:09:33 GMT
Date: 2005-02-16T00:09:33+00:00	[thread overview]
Message-ID: <1bwQd.1171$kU3.57@newsread1.news.pas.earthlink.net> (raw)
In-Reply-To: <1108456053.837461.20340@f14g2000cwb.googlegroups.com>

Per Lindquist wrote:
> Jeffrey Carter wrote:
> 
>>   procedure Q is
>>      package That is new PragmARC.Reflection;
> 
> 
> Hm, I was so excited about your solution I didn't notice the potential
> problem with overhead, but a collegue of mine did:
> 
> One of our target environments is a time-critical real-time system. We
> are worried about the execution overhead implied by a package
> instantiation (or any 'new' statement) in every subprogram in the
> system.
> 
> Will your solution cause overhead for each subprogram call?

It will definitely cause overhead, as I see you've discovered. There's a 
call to Expanded_Name, 2 to Index, and another to Mixed_Case. This 
component is certainly not suitable for systems with critical timing 
requirements.

There may also be overhead in terms of the amount of storage used. The 
package declares a number of constant Strings, and I doubt if we can 
rely on a compiler to discard them (although inside a subprogram, they 
should go away when the subprogram returns).

You can eliminate the call to Mixed_Case, if you don't mind what the 
result looks like, and one of the calls to Index (it will always return 
'Last - 1), and possibly the call to Expanded_Name, if your compilers 
have 'External_Tag returning the same thing and you're willing to have 
that compiler dependency in your code (though 'External_Tag probably has 
similar overhead to Expanded_Name in that case). That still leaves a 
call to Index. You could eliminate that if you always name your 
instantiations the same thing and don't mind that extra name on the end.

This is really only a problem in subprograms, where the package is 
elaborated every time the subprogram is called. In packages and other 
things where the elaboration will only occur once, it may be acceptable 
overhead.

It's too late now, but this might have been a good thing to suggest for 
Ada 0X. Compilers already have to have this information available, or 
PragmARC.Reflection wouldn't work. We should be able to get at it 
without all this overhead.

Finally, if you only need the name in exceptional circumstances (error 
logging or the like), I could make Unit_Name a function. Then you'd only 
have the overhead when you actually use the name.

-- 
Jeff Carter
"C++ is like jamming a helicopter inside a Miata
and expecting some sort of improvement."
Drew Olbrich
51



  parent reply	other threads:[~2005-02-16  0:09 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-11 16:33 This can't be done in Ada...or? Per Lindquist
2005-02-11 16:51 ` Duncan Sands
2005-02-12 19:55   ` Florian Weimer
2005-02-14  8:34     ` Per Lindquist
2005-02-14  8:17   ` Per Lindquist
2005-02-11 17:02 ` Jeff C
2005-02-11 18:27   ` Robert A Duff
2005-02-11 23:51     ` Ludovic Brenta
2005-02-11 23:52       ` Robert A Duff
2005-02-12 13:55     ` Duncan Sands
2005-02-12 14:58       ` Martin Krischik
2005-02-12 15:56         ` Martin Dowie
2005-02-12 19:02       ` Robert A Duff
2005-02-14  8:49     ` Per Lindquist
2005-02-11 17:08 ` Jerome Hugues
2005-02-14  9:05   ` Per Lindquist
2005-02-14 13:07     ` Georg Bauhaus
2005-02-12  1:10 ` Jeffrey Carter
2005-02-12 14:01   ` Duncan Sands
2005-02-13  0:27     ` Jeffrey Carter
2005-02-14  9:10       ` Per Lindquist
2005-02-15  0:40         ` Jeffrey Carter
2005-02-15  7:40           ` Per Lindquist
2005-02-15  8:39             ` OT: Google reply (Was: Re: This can't be done in Ada...or?) Adrien Plisson
2005-02-15  9:42               ` Per Lindquist
2005-02-15  8:27           ` This can't be done in Ada...or? Per Lindquist
2005-02-14 22:10             ` Manuel G. R.
2005-02-15  8:47             ` Mark Lorenzen
2005-02-15  9:09               ` Jacob Sparre Andersen
2005-02-15  9:31                 ` Mark Lorenzen
2005-02-15  9:48                   ` Jacob Sparre Andersen
2005-02-15 10:07                     ` Mark Lorenzen
2005-02-15 10:15                   ` Martin Dowie
2005-02-17 22:09                     ` Randy Brukardt
2005-02-18  6:53                       ` Martin Dowie
2005-02-15 13:46                   ` Robert A Duff
2005-02-15 13:41                 ` Robert A Duff
2005-02-15 16:30                   ` Per Lindquist
2005-02-15 19:38                     ` Martin Dowie
2005-02-15 20:20                     ` Robert A Duff
2005-02-17 21:52                   ` Simon Wright
2005-02-17 22:06               ` Randy Brukardt
2005-02-17 22:40                 ` Mark Lorenzen
2005-02-16  0:04             ` Jeffrey Carter
2005-02-16  0:09             ` Jeffrey Carter [this message]
2005-02-17  9:47               ` Per Lindquist
2005-02-17 22:36               ` Randy Brukardt
2005-02-14 15:21 ` Peter Amey
replies disabled

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