Skip to content

Refactored the TreeNode::executeTick() function to use a scoped timer… #863

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/tree_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,19 @@ NodeStatus TreeNode::executeTick()
if(!substituted)
{
using namespace std::chrono;

auto t1 = steady_clock::now();
// trick to prevent the compile from reordering the order of execution. See #861
// This makes sure that the code is executed at the end of this scope
std::shared_ptr<void> execute_later(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
Loading