[Insight-users] Using c++ stl containers in the transform?

motes motes mort.motes at gmail.com
Thu Dec 10 12:09:34 EST 2009


On Thu, Dec 10, 2009 at 3:23 PM, Luis Ibanez <luis.ibanez at kitware.com> wrote:
> Hi Motes,
>
> Before we dive into the details of your code....
>
> Are you compiling you application for "Release"  ?


Yes

> In order to do profiling comparisons, you must
> start first by making sure that you are using the
> compiler's optimization.
>
>
> Using STL containers is as efficient as using
> pointers, as long as you access the elements
> of the container via STL iterators.

I have not found any documentation that says that doing:

std::vector<std::string> container;
// Add 100000 strings to container

std::vector<std::string>::iterator it = container.begin()
while (it != container.end()) {
  std::string str = *it;
  // do something with str
  it++;
}

is faster than:

int size =  container.size();
for (int i=0; i< size; i++) {
  std::string str = container[i];
  // do something with str
}


I have tried both implementation in my transform and I do not
experince any difference in performance.


> Do the operations of mapping points involve
> inserting new elements or removing exising
> elements from the STL containers in your
> Transform  ?
>

I only lookup existing elements and read the contents of those. I do
not add or delete any elements.





>
>    Please let us know,
>
>
>        Thanks
>
>
>             Luis
>
>
> --------------------------------------------------
> On Thu, Dec 10, 2009 at 7:09 AM, motes motes <mort.motes at gmail.com> wrote:
>> I have created a transform (TransformPoint) that iterates a
>> std::vector base on a lookup in a std::map. I can't get the same
>> performance compared to running the  BSplineDeformableTransform and I
>> suspect that its beause I use the stl containers. Typically I only
>> iterate 10-40 elements in the vector based on a single lookup in the
>> map (lg n time).
>>
>> Does anyone have experiences with the pros and cons of using the stl
>> containers in per pixel/voxel functions like the TransformPoint in the
>> BSplineDeformableTransform?
>> _____________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Kitware offers ITK Training Courses, for more information visit:
>> http://www.kitware.com/products/protraining.html
>>
>> Please keep messages on-topic and check the ITK FAQ at:
>> http://www.itk.org/Wiki/ITK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.itk.org/mailman/listinfo/insight-users
>>
>


More information about the Insight-users mailing list