Skip to content

Commit

Permalink
Refactored the TreeNode::executeTick() function to use a scoped timer…
Browse files Browse the repository at this point in the history
… for performance monitoring. (BehaviorTree#861)
  • Loading branch information
wangzheng committed Sep 6, 2024
1 parent 4f66447 commit 33b4d47
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/tree_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,17 @@ NodeStatus TreeNode::executeTick()
if(!substituted)
{
using namespace std::chrono;

auto t1 = steady_clock::now();
std::shared_ptr<void> timer(nullptr, [&](...) {
auto t2 = steady_clock::now();
if(monitor_tick)
{
monitor_tick(*this, new_status, duration_cast<microseconds>(t2 - t1));
}
});

new_status = tick();
auto t2 = steady_clock::now();
if(monitor_tick)
{
monitor_tick(*this, new_status, duration_cast<microseconds>(t2 - t1));
}
}
}

Expand Down

0 comments on commit 33b4d47

Please sign in to comment.