Boost::multi_array performance question

前端 未结 16 2166
不思量自难忘°
不思量自难忘° 2020-12-04 11:20

I am trying to compare the performance of boost::multi_array to native dynamically allocated arrays, with the following test program:

#include 

        
16条回答
  •  广开言路
    2020-12-04 12:01

    Are you building release or debug?

    If running in debug mode, the boost array might be really slow because their template magic isn't inlined properly giving lots of overhead in function calls. I'm not sure how multi array is implemented though so this might be totally off :)

    Perhaps there is some difference in storage order as well so you might be having your image stored column by column and writing it row by row. This would give poor cache behavior and may slow down things.

    Try switching the order of the X and Y loop and see if you gain anything. There is some info on the storage ordering here: http://www.boost.org/doc/libs/1_37_0/libs/multi_array/doc/user.html

    EDIT: Since you seem to be using the two dimensional array for image processing you might be interested in checking out boosts image processing library gil.

    It might have arrays with less overhead that works perfectly for your situation.

提交回复
热议问题