grid_map icon indicating copy to clipboard operation
grid_map copied to clipboard

Performance: getPosition(Index) is super slow

Open laxnpander opened this issue 8 years ago • 2 comments

Hey hey,

I currently have an iteration of about 10 000 elements in a submap which runs in less than 0.1 seconds. However, as soon as I add "getPosition(*iterator, position)" into the loop, the performance drops to 0.5 seconds and worse. This is not really acceptable for me, especially as it should be quite an easy computation? Whats going on there?

Thanks for your help and best regards, Alex

laxnpander avatar Jan 03 '18 15:01 laxnpander

The same for getIndex(position, index). This is the Gperftools result: screenshot from 2018-08-14 17-18-01

taogashi avatar Aug 14 '18 09:08 taogashi

Hi @maximilianwulf , I have the same performance issue. Iterating over a grid with 10 000 cells and getting the position inside the iterator results in a 40 ms.

   for (grid_map::GridMapIterator iterator(grid_map); !iterator.isPastEnd();
         ++iterator) {
      const int i = iterator.getLinearIndex();
      float res = data(i);
      grid_map::Position currentCellPosition;
      grid_map.getPosition(*iterator, currentCellPosition);
}

Is there a work around to improve this performance? Cheers, Bruno

brunoeducsantos avatar Mar 15 '22 16:03 brunoeducsantos