Re: Optimization by hand.
From: Mike Wahler (mkwahler_at_mkwahler.net)
Date: 10/09/04
- Next message: Steven T. Hatton: "Fun with error messages"
- Previous message: Victor Bazarov: "Re: accessing variables from more than one .cpp file"
- In reply to: Steven T. Hatton: "Re: Optimization by hand."
- Next in thread: Victor Bazarov: "Re: Optimization by hand."
- Reply: Victor Bazarov: "Re: Optimization by hand."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 08 Oct 2004 22:38:53 GMT
"Steven T. Hatton" <susudata@setidava.kushan.aa> wrote in message
news:vtmdnaMybrPKZfvcRVn-rA@speakeasy.net...
> Mike Wahler wrote:
>
> >
> > "Steven T. Hatton" <susudata@setidava.kushan.aa> wrote in message
> > news:Q_6dnT3uBccfbPvcRVn-pw@speakeasy.net...
> >> In the following code I have attempted to perform all calculations that
> > are
> >> repeated in the mathematical expression for the rotation being
evaluated.
> >> IOW, I calculate cos(_angle) only once, and put it in a variable.
> >> Perhaps
> >> a compiler is smart enough to do this for me. I don't know. When I get
a
> >> chance I plan on trying to look at the compiler output to determine
what
> > is
> >> happening with gcc.
> >>
> >> I'm wondering what others think about this kind of hand optimization.
> >
> > I think one should give the compiler first crack at it,
> > then only 'hand optimize' if necessary. But even before
> > doing that, I'd first try a different compiler(s).
> >
> > -Mike
> The real question is whether I have removed operations from the object
code,
> and/or replaced them with more efficient operations.
That depends entirely upon the implementation (and upon the
platform where the program is executed). The question cannot
be answered from a language perspective.
> Sure, I can and will
> experiment with this. I know from experience that when I start performing
> multiple nested operations on nodes in a tree the cost can get very high
in
> a hurry. O(log(n)) IIRC.
Yes it can, at the algorithmic level. How various compiler implement
the algorithm can vary widely, resulting in widely differing performance.
> I'm not trying to solve one problem. I'm trying to address an entire
class
> of problems. If there are formal discussions of these issues available in
> articels or books, I am interested to know where.
For discussion of algorithmic solutions, try an algorithms group.
And there are also always the famous Knuth books.
For discussion of the efficiency of implementation of particular
compilers, ask in groups about those compilers.
I can't at the moment think of any particular books or articles
about these issues, but google's always a good place to start. :-)
-Mike
- Next message: Steven T. Hatton: "Fun with error messages"
- Previous message: Victor Bazarov: "Re: accessing variables from more than one .cpp file"
- In reply to: Steven T. Hatton: "Re: Optimization by hand."
- Next in thread: Victor Bazarov: "Re: Optimization by hand."
- Reply: Victor Bazarov: "Re: Optimization by hand."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|