|
Boost Users : |
Subject: Re: [Boost-users] [GIL] Performance warning...
From: Lubomir Bourdev (lbourdev_at_[hidden])
Date: 2009-11-27 19:00:48
While some channel types are classes, a built-in type such as âunsigned charâ is a valid channel. We have to be careful so we donât slow down operations on common 8-bit images. I think it is safe to replace âChannelâ with âconst Channelâ but âconst Channel&â has a size of a pointer and this is far bigger than unsigned char.
Perhaps to do this right one needs to create a metafunction that returns the type by value or by const reference, whichever is faster.
Lubomir
From: Eloi Du Bois [mailto:eloi.du.bois_at_[hidden]]
Sent: Friday, November 27, 2009 3:37 PM
To: boost-users_at_[hidden]
Cc: Lubomir Bourdev
Subject: Re: [Boost-users] [GIL] Performance warning...
I am not an expert but I think on primitive types, there is no need to put a reference (and it may slows down the process).
But the line I mentioned before concern a channel object, and I think this object stores many datas (maybe a byte array ?).
2009/11/28 Christian Henning <chhenning_at_[hidden]<mailto:chhenning_at_[hidden]>>
Lubomir, looking at the default_channel_converter the channels already
arrive as a const reference. All I did was to make sure they are still
const references in the channel_converter functions. In all cases the
source channels should at least be const. Which allows for more
compiler optimizations.
I did run the performance test in gil_test suite and the changes were
marginal. Some tests were faster some were slower after the change.
Christian
On Fri, Nov 27, 2009 at 6:13 PM, Lubomir Bourdev <lbourdev_at_[hidden]<mailto:lbourdev_at_[hidden]>> wrote:
> This was done on purpose. I don't know if it still holds, but it used to be
> that a const reference to a simple type like an int or char is slower than
> passing the type by value. This is the same reason most STL algorithms take
> iterators by value. If you want to make this change it is important to
> verify that performance of simple built-in channel types is not adversely
> affected.
>
> Lubomir
>
> On 11/27/09 12:17 PM, "Christian Henning" <chhenning_at_[hidden]<mailto:chhenning_at_[hidden]>> wrote:
>
>> Hi Eloi, you're correct and I'll fix that. I can even make it const
>> reference. Running the test shows no real difference but that might be
>> only because no expensive channels are being used.
>>
>> I'll commit the changes asap.
>>
>> Lubomir, please review the changes if your time allows. Affected files
>> are channel_algorithm.hpp and gil_concept.hpp.
>>
>> Thanks,
>> Christian
>>
>
>
_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]<mailto:Boost-users_at_[hidden]>
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net