Some performance questions

Daniel Keep daniel.keep.lists at gmail.com
Mon Feb 2 07:06:50 PST 2009



Lars Kyllingstad wrote:
> [snip]
> From a performance
> perspective, however, it carries with it the overhead of an extra
> function call, which I'm not sure I want.
> 
> -Lars

You're worried about a second function call which could potentially be
inlined, yet you're seemingly not worried about the overhead of virtual
calls or heap allocations...

Allow me to quote Donald Knuth:

> We should forget about small efficiencies, say about 97% of the time:
> premature optimization is the root of all evil.

Unless you're doing something where you *know* you're going to need
every last cycle, just go with whichever design works best.  Your
response to Jarrett implies that you've already got a design in mind,
and are just fishing for a magic "make it go faster button."

Believe me, if Walter had invented such a thing, he wouldn't be wasting
his time putting up with us; he'd be too busy smoking $100 bills from
the comfort of his SPACE FORTRESS.  :D

In any case, I'm willing to bet that if there *are* inefficiencies
you're not going to know exactly where until you've written the code,
anyway.  :P

If classes work, and make for an elegant design, go for it.

  -- Daniel


More information about the Digitalmars-d-learn mailing list