comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeff C," <nolongersafeto@userealemailsniff.com>
Subject: Re: Problems converting Float to Integer efficiently
Date: Fri, 10 Oct 2003 02:05:33 GMT
Date: 2003-10-10T02:05:33+00:00	[thread overview]
Message-ID: <Ntohb.253936$mp.172042@rwcrnsc51.ops.asp.att.net> (raw)
In-Reply-To: Oplhb.9211$RU4.88029@newsfep4-glfd.server.ntli.net


"Dr. Adrian Wrigley" <amtw@linuxchip.demon.co.uk.uk.uk> wrote in message
news:Oplhb.9211$RU4.88029@newsfep4-glfd.server.ntli.net...
> Jeff C, wrote:
> >
> This whole situation illustrates one of the things which frustrates me
about coding in Ada/GNAT:
> performance and reliability of Ada code is often very good, but you need
to be eternally
> vigilant that you are getting out the code that you think you should be
getting.  The speed
> of the compiled code is sometimes critically dependent on apparently
inocuous choices.
> Things like enumerated types, use of generics under certain circumstances
etc. can cause
> apparently good source code to crawl.  Is this a necessary price for
ditching low-level HLLs
> like 'C'?  Perhaps someone should create a web site highlighting the
problem areas and
> explaining the solutions? Volunteers anybody?
>
> Thanks guys for the help on this!


No problem... The problem is not really unique to Ada.  Even with C if you
are writing performance
critical code you often run into areas where you have to do "something" to
make the code run better.
This can be an assembly language insertion or just a restructing of the code
to help the compiler figure
out what you wanted better. I have ended up having to create my own
memcpy/bcopy serveral times
because the "optimized" one from the compiler ended up doing something
really bad for a specific (but
potentially common) situation.

The problem with any website or list I have ever seen that tries to tell you
things to "look out for" is that
they all tend to be full of misleading information that is either based on
someone not understanding the tool
or language or based on some specific compiler, version, bug, os, etc.

My best advice is to run a profiler and see what you can see. Of course this
is one of those things
that people always say but there are plenty of ways for profilers to get
somewhat confused too so even
using a profiler can be somewhat of an art form.

I have personally used generics to actually make some code faster in the
past (and had
no problems with performance critical code with enumeration types as long as
you stay away from 'image 'value in performace critical code and avoid
rep-specing them when you don't need to).

Now even my last statement is full of half-truths and misleading info. I can
just see someone going ah-ha I won't use a 'image I'll build a lookup table
of pointers to strings and return that...and of course the code would be
just as slow..(probably).....





  reply	other threads:[~2003-10-10  2:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-09  0:06 Problems converting Float to Integer efficiently Dr. Adrian Wrigley
2003-10-09  1:08 ` Jeffrey Carter
2003-10-09  2:36 ` Jeff C,
2003-10-09  3:21   ` Dr. Adrian Wrigley
2003-10-09  3:36     ` Jeff C,
2003-10-17 20:57     ` Randy Brukardt
2003-10-09 22:36   ` Dr. Adrian Wrigley
2003-10-10  2:05     ` Jeff C, [this message]
2003-10-10 17:15     ` Robert I. Eachus
2003-10-11  1:47     ` Waldek Hebisch
2003-10-09  7:10 ` Robert I. Eachus
replies disabled

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