comp.lang.ada
 help / color / mirror / Atom feed
From: "Per Lindquist" <commander@death-star.com>
Subject: Re: This can't be done in Ada...or?
Date: 15 Feb 2005 08:30:23 -0800
Date: 2005-02-15T08:30:23-08:00	[thread overview]
Message-ID: <1108485023.838467.131230@o13g2000cwo.googlegroups.com> (raw)
In-Reply-To: wccpsz2djp5.fsf@shell01.TheWorld.com

Robert A Duff wrote:
> No, instantiation is a compile-time concept.  I'm not sure what
> it would mean to delay it until run time.
>
> The issue here is the cost of running the elaboration code of the
> instance.  Theoretically, the compiler could optimize it away in this
> case, but I don't think any Ada compilers are that smart.  The only
> way to know for sure is to try it.
>
> This Reflection package has a bunch of string manipulation code,
> and if you instantiate it in a procedure, it will happen
> every time that procedure is called (unless the compiler
> is smarter than I think it is).  This could indeed be very
> costly.

I can now confirm that the Reflection package, in our case, indeed
causes considerable overhead compared to hardcoded constants.

The test consisted of 1_000_000 calls to procedure Q in either package
P1 or P2:

package body P1 is
  procedure Q is
    package Reflect is new PragmARC.Reflection;
  begin
    Dummy := Dummy + 1;
  end;
end P1;

package body P2 is
  procedure Q is
    Subprogram_Name : constant String := "Q";
  begin
    Dummy := Dummy + 1;
  end;
end P2;

(I'm aware that Reflect.Unit_Name is longer ("P1.Q") than
Subprogram_NAme ("Q") but this test is relevant in our case.)

I tested on a Sun (Solaris) machine using the GNAT compiler and on a
PowerPC (Integrity) using GreenHill's Ada compiler.

There was really no need for an accurate time measurement since the
difference was large on both platforms. The constant test finished
immediately and the Reflection test took several seconds.

Optimization flags (GNAT only) didn't do much difference.

So although PragmARC.Reflection offers very nice features we cannot use
it in our particular system.

Thanks for your help!

/PerL




  reply	other threads:[~2005-02-15 16:30 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 [this message]
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
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