Skip to content

Commit

Permalink
Do not waste time constructing error string if nobody is interested i…
Browse files Browse the repository at this point in the history
…n it in canTransform(). (#469)
  • Loading branch information
peci1 authored Aug 24, 2020
1 parent ad04943 commit 34a4154
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tf2/src/buffer_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ int BufferCore::walkToTopParent(F& f, ros::Time time, CompactFrameID target_id,
break;
}

CompactFrameID parent = f.gather(cache, time, &extrapolation_error_string);
CompactFrameID parent = f.gather(cache, time, error_string ? &extrapolation_error_string : NULL);
if (parent == 0)
{
// Just break out here... there may still be a path from source -> target
Expand Down
27 changes: 27 additions & 0 deletions tf2/test/speed_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,31 @@ int main(int argc, char** argv)
CONSOLE_BRIDGE_logInform("canTransform at Time(2) took %f for an average of %.9f", dur.toSec(), dur.toSec() / (double)count);
}
#endif

#if 01
{
ros::WallTime start = ros::WallTime::now();
for (uint32_t i = 0; i < count; ++i)
{
bc.canTransform(v_frame1, v_frame0, ros::Time(3));
}
ros::WallTime end = ros::WallTime::now();
ros::WallDuration dur = end - start;
CONSOLE_BRIDGE_logInform("canTransform at Time(3) without error string took %f for an average of %.9f", dur.toSec(), dur.toSec() / (double)count);
}
#endif

#if 01
{
ros::WallTime start = ros::WallTime::now();
std::string str;
for (uint32_t i = 0; i < count; ++i)
{
bc.canTransform(v_frame1, v_frame0, ros::Time(3), &str);
}
ros::WallTime end = ros::WallTime::now();
ros::WallDuration dur = end - start;
CONSOLE_BRIDGE_logInform("canTransform at Time(3) with error string took %f for an average of %.9f", dur.toSec(), dur.toSec() / (double)count);
}
#endif
}

0 comments on commit 34a4154

Please sign in to comment.