ros / geometry2

A set of ROS packages for keeping track of coordinate transforms.
189 stars 275 forks source link

Do not waste time constructing error string if nobody is interested in it in canTransform(). #469

Closed peci1 closed 3 years ago

peci1 commented 4 years ago

Solves #468.

Also added two more tests to speed_test to verify that this patch helps.

peci1 commented 4 years ago

Speed test before patch:

Info:    9 to 4
Info:    Doing 1000000 10-level 1.000000-interval tests
Info:    canTransform at Time(3) without error string took 2.520531 for an average of 0.000002521
Info:    canTransform at Time(3) with error string took 4.727922 for an average of 0.000004728

Speed test after patch:

Info:    9 to 4
Info:    Doing 1000000 10-level 1.000000-interval tests
Info:    canTransform at Time(3) without error string took 0.221355 for an average of 0.000000221
Info:    canTransform at Time(3) with error string took 4.029124 for an average of 0.000004029

That's tenfold speedup!

Other cases (when the transform exists) are without change.

peci1 commented 3 years ago

Thanks for merging. Will you pick this up to backport into Melodic, please?