Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #5502
| From | Edek <edek.pieITAKNIECZYTAM@gmail.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: Boost.bind and performance penalties? |
| Date | 2011-05-25 16:45 +0200 |
| Organization | ATMAN - ATM S.A. |
| Message-ID | <irj4cg$mv8$1@node2.news.atman.pl> (permalink) |
| References | <4198e173-5f6c-447d-a848-07767e446048@w36g2000vbi.googlegroups.com> |
On 05/25/2011 01:56 PM, Rune Allnor wrote:
> Hi all.
[snip]
> The point is that I can't afford much run-time overhead, or
> it will signifigantly impact the application.
>
> Now, there are several variants of computations that I can
> do on the data x. I'd like to use function objects or pointers
> to specify how to do the computations, and am thinking of
> using boost.bind to declare these function pointers when
> calling this library.
>
> What run-time overheads, if any, would be expected when
> using function pointers, as opposed to 'hard-wiring' the
> computations inside the library?
I guess it depends on how complicated the functions are, in two ways.
One: if they take long time, the call overhead is _relatively_ small.
Two: how complicated they are, impacting optimizing possibilities. E.g.
simple multiplication can be SSE'd ('vectorized') if inline'd or
deducted by compiler in some other way. Such optimisations cannot be
done - in most cases - when the call is indirect enough that the
compiler cannot be sure it knows the called function body. This can be
significant.
In general bind() is not light, and even function pointers, or even
worse pointers to members, should not be called in a tight loop, if only
for the call itself, let alone missed optimisations.
These are mostly rules of thumb. If you have a lot of time to spend on
programming, use expression templates, or inline at least. If you
cannot, use boost::bind and just don't worry.
HTH
Edek
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Boost.bind and performance penalties? Rune Allnor <allnor@tele.ntnu.no> - 2011-05-25 04:56 -0700
Re: Boost.bind and performance penalties? Edek <edek.pieITAKNIECZYTAM@gmail.com> - 2011-05-25 16:45 +0200
Re: Boost.bind and performance penalties? Rune Allnor <allnor@tele.ntnu.no> - 2011-05-25 21:35 -0700
Re: Boost.bind and performance penalties? Edek <edek.pieITAKNIECZYTAM@gmail.com> - 2011-05-26 11:34 +0200
Re: Boost.bind and performance penalties? Rune Allnor <allnor@tele.ntnu.no> - 2011-05-26 02:40 -0700
Re: Boost.bind and performance penalties? Edek <edek.pieITAKNIECZYTAM@gmail.com> - 2011-05-26 12:53 +0200
Re: Boost.bind and performance penalties? Rune Allnor <allnor@tele.ntnu.no> - 2011-05-26 04:19 -0700
Re: Boost.bind and performance penalties? Jeff Flinn <TriumphSprint2000@hotmail.com> - 2011-05-26 16:11 -0400
csiph-web