-
-
Notifications
You must be signed in to change notification settings - Fork 119
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
Implement performance metrics BehaveTree Node #103
Implement performance metrics BehaveTree Node #103
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good start! Apart from a few smaller comments this looks generally good.
Could we also add additional metrics like described on #89?
Metric Name | Description |
---|---|
beehave/node_count |
The number of total beehave nodes in the scene |
beehave/active_count |
Number of active behaviour trees in the scene |
Also reminder, that there is no need to check for debug mode, as Godot will only query the monitors inside the editor anyways and ensures not to call these in production mode.
addons/beehave/nodes/beehave_tree.gd
Outdated
@@ -22,6 +22,8 @@ enum { | |||
|
|||
var actor : Node | |||
|
|||
var _tree_metric_name : String |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we may want to give this a better name: as it is tracking the process_time
of this tree, perhaps something like this:
var _tree_metric_name : String | |
var _process_time_metric_name : String |
(we are inside the tree already so using "tree" is redundant)
addons/beehave/nodes/beehave_tree.gd
Outdated
func _enter_tree() -> void: | ||
# Get the name of the parent node name for metric | ||
var parent_name = get_parent().name | ||
_tree_metric_name = "beehave/process_time/%s(%s)" % [parent_name, get_instance_id()] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From a structural perspective, we may want to have multiple metrics as part of the same tree. Therefore, I'd group them differently:
_tree_metric_name = "beehave/process_time/%s(%s)" % [parent_name, get_instance_id()] | |
_tree_metric_name = "beehave/%s-%s/process_time" % [parent_name, get_instance_id()] |
addons/beehave/nodes/beehave_tree.gd
Outdated
|
||
func _enter_tree() -> void: | ||
# Get the name of the parent node name for metric | ||
var parent_name = get_parent().name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using get_parent()
here is wrong, as there are different ways to associate a node to a tree (see actor_node_path
export property)
var parent_name = get_parent().name | |
var parent_name = actor.name |
addons/beehave/nodes/beehave_tree.gd
Outdated
|
||
|
||
# Called by the engine to profile this tree | ||
func _get_tree_metric() -> float: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, this method also should be renamed to something like this:
func _get_tree_metric() -> float: | |
func _get_process_time_metric_value() -> float: |
The metric is now registered in the ready() function instead of the _enter_tree(). |
- Refactored variable names to tell what the metric is. - Parent name is now obtained by actor property
70b502d
to
c3c179a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution!
Description
I've implemented the performance per tree in the Godot engine profiler.
Time is being showed in nanosecconds and tree will be automatically added and removed to the profiler.
It might be better to disable all the metric code when running in release mode, example: use
if OS.is_debug_build()
Any ideas are welcome.
Addressed issues
#89
Screenshots