Skip to content

Commit 33b4d47

Browse files
author
wangzheng
committed
Refactored the TreeNode::executeTick() function to use a scoped timer for performance monitoring. (#861)
1 parent 4f66447 commit 33b4d47

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/tree_node.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,17 @@ NodeStatus TreeNode::executeTick()
106106
if(!substituted)
107107
{
108108
using namespace std::chrono;
109+
109110
auto t1 = steady_clock::now();
111+
std::shared_ptr<void> timer(nullptr, [&](...) {
112+
auto t2 = steady_clock::now();
113+
if(monitor_tick)
114+
{
115+
monitor_tick(*this, new_status, duration_cast<microseconds>(t2 - t1));
116+
}
117+
});
118+
110119
new_status = tick();
111-
auto t2 = steady_clock::now();
112-
if(monitor_tick)
113-
{
114-
monitor_tick(*this, new_status, duration_cast<microseconds>(t2 - t1));
115-
}
116120
}
117121
}
118122

0 commit comments

Comments
 (0)