* Variant vs. Tagged Type
@ 2003-11-05 12:30 Frank Piron
2003-11-05 12:49 ` Marin David Condic
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Frank Piron @ 2003-11-05 12:30 UTC (permalink / raw)
Hi,
is it possible to make some general statements
concerning the alternative variant vs. tagged
type with respect to runtime performance?
For example:
if we have an array A 1) of type access to a variant
2) of type access <TYPE>'Class
what can be said about the runtime performance
of the expression
A(I).<component>?
Thanks in Advance,
Frank
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Variant vs. Tagged Type
2003-11-05 12:30 Variant vs. Tagged Type Frank Piron
@ 2003-11-05 12:49 ` Marin David Condic
2003-11-05 14:50 ` Steve
2003-11-05 17:40 ` Jeffrey Carter
2 siblings, 0 replies; 5+ messages in thread
From: Marin David Condic @ 2003-11-05 12:49 UTC (permalink / raw)
Well, in most respects, a tagged type is just a special case of a
variant record. (Conceptually) The "variant" is the tag. In that sense,
most access should be just as fast either way - depending on compilers
and optimizations, etc. (The only way to know for sure is to measure
with *your* compiler in *your* environment with code that is typical of
what you want to do. Maybe Ada should develop a performance benchmark
suite to test some of these things?)
However, you do have to be careful with tagged types in that some things
cannot be done statically at compile-time. Things like dispatching to
operations on the tagged type. In general, the static things should be
no worse than any other sort of operation on a variant record, but if
you use features that are dynamic, you'll incur some additional
overhead. (How much? You can only know by checking into your compiler.)
OTOH, you also need to ask just how critical the time concerns are. In
many apps, the slight additional overhead connected to tagged types is
not enough to cause any sort of problem. In other apps, you might be so
tight on the time budget that even the variant record approach might be
too much to bear. (The code has to look up the variant at run time to
know how to interpret the record, right? That's not free.) Lots of
designers get their panties in a bunch over performance concerns when a
step back and a deep breath reveals its all "the small stuff." Like life
in general, we often worry about things that never happen.
MDC
Frank Piron wrote:
> Hi,
> is it possible to make some general statements
> concerning the alternative variant vs. tagged
> type with respect to runtime performance?
> For example:
> if we have an array A 1) of type access to a variant
> 2) of type access <TYPE>'Class
> what can be said about the runtime performance
> of the expression
> A(I).<component>?
> Thanks in Advance,
> Frank
>
--
======================================================================
Marin David Condic
I work for: http://www.belcan.com/
My project is: http://www.jsf.mil/NSFrames.htm
Send Replies To: m o d c @ a m o g
c n i c . r
"So if I understand 'The Matrix Reloaded' correctly, the Matrix is
basically a Microsoft operating system - it runs for a while and
then crashes and reboots. By design, no less. Neo is just a
memory leak that's too hard to fix, so they left him in... The
users don't complain because they're packed in slush and kept
sedated"
-- Marin D. Condic
======================================================================
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Variant vs. Tagged Type
2003-11-05 12:30 Variant vs. Tagged Type Frank Piron
2003-11-05 12:49 ` Marin David Condic
@ 2003-11-05 14:50 ` Steve
2003-11-05 17:40 ` Jeffrey Carter
2 siblings, 0 replies; 5+ messages in thread
From: Steve @ 2003-11-05 14:50 UTC (permalink / raw)
"Frank Piron" <nospam@konad.net> wrote in message
news:oprx5zpwdbz12uz9@news.onlinehome.de...
> Hi,
> is it possible to make some general statements
> concerning the alternative variant vs. tagged
> type with respect to runtime performance?
Only for a specific Ada compiler.
Actual implementation of any feature within different compilers may differ
radically. The only way to compare performance is through testing with a
specific compiler. In certain cases you may find order-of-magnitude
differences in performance between implementations.
Steve
(The Duck)
> For example:
> if we have an array A 1) of type access to a variant
> 2) of type access <TYPE>'Class
> what can be said about the runtime performance
> of the expression
> A(I).<component>?
> Thanks in Advance,
> Frank
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Variant vs. Tagged Type
2003-11-05 12:30 Variant vs. Tagged Type Frank Piron
2003-11-05 12:49 ` Marin David Condic
2003-11-05 14:50 ` Steve
@ 2003-11-05 17:40 ` Jeffrey Carter
2003-11-06 7:22 ` Frank Piron
2 siblings, 1 reply; 5+ messages in thread
From: Jeffrey Carter @ 2003-11-05 17:40 UTC (permalink / raw)
Frank Piron wrote:
> is it possible to make some general statements
> concerning the alternative variant vs. tagged
> type with respect to runtime performance?
> For example:
> if we have an array A 1) of type access to a variant
> 2) of type access <TYPE>'Class
> what can be said about the runtime performance
> of the expression
> A(I).<component>?
It sounds as if you're engaging in premature optimization (the root of
all evil). Do it whichever way is best suited to the problem, and see if
the result is fast enough. 99.99% of the time, the microsecond
differences you're worrying about don't make a difference.
--
Jeff Carter
"Many times we're given rhymes that are quite unsingable."
Monty Python and the Holy Grail
57
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Variant vs. Tagged Type
2003-11-05 17:40 ` Jeffrey Carter
@ 2003-11-06 7:22 ` Frank Piron
0 siblings, 0 replies; 5+ messages in thread
From: Frank Piron @ 2003-11-06 7:22 UTC (permalink / raw)
Am Wed, 05 Nov 2003 17:40:45 GMT hat Jeffrey Carter <spam@spam.com>
geschrieben:
> Frank Piron wrote:
>
>> is it possible to make some general statements
>> concerning the alternative variant vs. tagged
>> type with respect to runtime performance?
>> For example:
>> if we have an array A 1) of type access to a variant
>> 2) of type access <TYPE>'Class
>> what can be said about the runtime performance
>> of the expression
>> A(I).<component>?
>
> It sounds as if you're engaging in premature optimization (the root of
> all evil). Do it whichever way is best suited to the problem, and see if
> the result is fast enough. 99.99% of the time, the microsecond
> differences you're worrying about don't make a difference.
>
Currently i'm working on an ORACLE access library on top of
oci. Yesterday i've done some benchmark tests. I experienced
differences in runtime performance up to a factor of 4 while
fetching and extracting 10_000 rows in using a variant instead
of an array of class wide pointers for the db_row_type. The
compiler is gnat 3.15p on windows.
Fortunately ada gives alternatives ;-)
Frank
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2003-11-06 7:22 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-05 12:30 Variant vs. Tagged Type Frank Piron
2003-11-05 12:49 ` Marin David Condic
2003-11-05 14:50 ` Steve
2003-11-05 17:40 ` Jeffrey Carter
2003-11-06 7:22 ` Frank Piron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox