← Index
NYTProf Performance Profile   « line view »
For scripts/bench.pl
  Run on Mon Oct 22 16:48:56 2018
Reported on Mon Oct 22 16:49:10 2018

Filename/home/tmurray/proj/Game-Collisions/lib/Game/Collisions/AABB.pm
StatementsExecuted 2748344 statements in 2.37s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
2643631566ms659msGame::Collisions::AABB::::_calculate_bounding_box_for_nodesGame::Collisions::AABB::_calculate_bounding_box_for_nodes
23996011354ms354msGame::Collisions::AABB::::does_collideGame::Collisions::AABB::does_collide
19428011105ms105msGame::Collisions::AABB::::is_branch_nodeGame::Collisions::AABB::is_branch_node
1832001159.4ms59.4msGame::Collisions::AABB::::right_nodeGame::Collisions::AABB::right_node
1841982158.7ms58.7msGame::Collisions::AABB::::left_nodeGame::Collisions::AABB::left_node
9991149.9ms315msGame::Collisions::AABB::::resize_all_parentsGame::Collisions::AABB::resize_all_parents
9991143.8ms469msGame::Collisions::AABB::::find_best_sibling_nodeGame::Collisions::AABB::find_best_sibling_node
94781127.1ms260msGame::Collisions::AABB::::_resize_to_fit_childrenGame::Collisions::AABB::_resize_to_fit_children
1077423226.6ms26.6msGame::Collisions::AABB::::xGame::Collisions::AABB::x
1077423224.8ms24.8msGame::Collisions::AABB::::yGame::Collisions::AABB::y
528721112.1ms12.1msGame::Collisions::AABB::::lengthGame::Collisions::AABB::length
528721111.6ms11.6msGame::Collisions::AABB::::heightGame::Collisions::AABB::height
2996219.76ms12.9msGame::Collisions::AABB::::_set_nodeGame::Collisions::AABB::_set_node
18956225.35ms5.35msGame::Collisions::AABB::::parentGame::Collisions::AABB::parent
1541213.76ms11.6msGame::Collisions::AABB::::set_left_nodeGame::Collisions::AABB::set_left_node
1455213.72ms8.76msGame::Collisions::AABB::::set_right_nodeGame::Collisions::AABB::set_right_node
1999213.32ms3.32msGame::Collisions::AABB::::newGame::Collisions::AABB::new
2996112.07ms2.07msGame::Collisions::AABB::::set_parentGame::Collisions::AABB::set_parent
1111.57ms1.84msGame::Collisions::AABB::::BEGIN@32Game::Collisions::AABB::BEGIN@32
111494µs533µsGame::Collisions::AABB::::BEGIN@30Game::Collisions::AABB::BEGIN@30
111250µs253µsGame::Collisions::AABB::::BEGIN@26Game::Collisions::AABB::BEGIN@26
11110µs10µsGame::Collisions::AABB::::BEGIN@27Game::Collisions::AABB::BEGIN@27
1118µs14µsGame::Collisions::AABB::::BEGIN@28Game::Collisions::AABB::BEGIN@28
1118µs35µsGame::Collisions::AABB::::BEGIN@33Game::Collisions::AABB::BEGIN@33
1115µs38µsGame::Collisions::AABB::::BEGIN@34Game::Collisions::AABB::BEGIN@34
1115µs27µsGame::Collisions::AABB::::BEGIN@35Game::Collisions::AABB::BEGIN@35
1115µs26µsGame::Collisions::AABB::::BEGIN@39Game::Collisions::AABB::BEGIN@39
1115µs28µsGame::Collisions::AABB::::BEGIN@36Game::Collisions::AABB::BEGIN@36
1115µs24µsGame::Collisions::AABB::::BEGIN@40Game::Collisions::AABB::BEGIN@40
1114µs25µsGame::Collisions::AABB::::BEGIN@38Game::Collisions::AABB::BEGIN@38
1114µs24µsGame::Collisions::AABB::::BEGIN@37Game::Collisions::AABB::BEGIN@37
1113µs3µsGame::Collisions::AABB::::BEGIN@29Game::Collisions::AABB::BEGIN@29
0000s0sGame::Collisions::AABB::::dump_treeGame::Collisions::AABB::dump_tree
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# Copyright (c) 2018 Timm Murray
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are met:
6#
7# * Redistributions of source code must retain the above copyright notice,
8# this list of conditions and the following disclaimer.
9# * Redistributions in binary form must reproduce the above copyright
10# notice, this list of conditions and the following disclaimer in the
11# documentation and/or other materials provided with the distribution.
12#
13# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
17# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
23# POSSIBILITY OF SUCH DAMAGE.
24package Game::Collisions::AABB;
25
262253µs2256µs
# spent 253µs (250+3) within Game::Collisions::AABB::BEGIN@26 which was called: # once (250µs+3µs) by Game::Collisions::BEGIN@30 at line 26
use utf8;
# spent 253µs making 1 call to Game::Collisions::AABB::BEGIN@26 # spent 3µs making 1 call to utf8::import
27245µs110µs
# spent 10µs within Game::Collisions::AABB::BEGIN@27 which was called: # once (10µs+0s) by Game::Collisions::BEGIN@30 at line 27
use v5.14;
# spent 10µs making 1 call to Game::Collisions::AABB::BEGIN@27
28223µs221µs
# spent 14µs (8+6) within Game::Collisions::AABB::BEGIN@28 which was called: # once (8µs+6µs) by Game::Collisions::BEGIN@30 at line 28
use warnings;
# spent 14µs making 1 call to Game::Collisions::AABB::BEGIN@28 # spent 6µs making 1 call to warnings::import
29220µs13µs
# spent 3µs within Game::Collisions::AABB::BEGIN@29 which was called: # once (3µs+0s) by Game::Collisions::BEGIN@30 at line 29
use List::Util ();
# spent 3µs making 1 call to Game::Collisions::AABB::BEGIN@29
302122µs1533µs
# spent 533µs (494+38) within Game::Collisions::AABB::BEGIN@30 which was called: # once (494µs+38µs) by Game::Collisions::BEGIN@30 at line 30
use Scalar::Util ();
# spent 533µs making 1 call to Game::Collisions::AABB::BEGIN@30
31
322129µs21.89ms
# spent 1.84ms (1.57+275µs) within Game::Collisions::AABB::BEGIN@32 which was called: # once (1.57ms+275µs) by Game::Collisions::BEGIN@30 at line 32
use constant _X => 0;
# spent 1.84ms making 1 call to Game::Collisions::AABB::BEGIN@32 # spent 42µs making 1 call to constant::import
33226µs263µs
# spent 35µs (8+27) within Game::Collisions::AABB::BEGIN@33 which was called: # once (8µs+27µs) by Game::Collisions::BEGIN@30 at line 33
use constant _Y => 1;
# spent 35µs making 1 call to Game::Collisions::AABB::BEGIN@33 # spent 27µs making 1 call to constant::import
34225µs270µs
# spent 38µs (5+32) within Game::Collisions::AABB::BEGIN@34 which was called: # once (5µs+32µs) by Game::Collisions::BEGIN@30 at line 34
use constant _LENGTH => 2;
# spent 38µs making 1 call to Game::Collisions::AABB::BEGIN@34 # spent 32µs making 1 call to constant::import
35221µs248µs
# spent 27µs (5+22) within Game::Collisions::AABB::BEGIN@35 which was called: # once (5µs+22µs) by Game::Collisions::BEGIN@30 at line 35
use constant _HEIGHT => 3;
# spent 27µs making 1 call to Game::Collisions::AABB::BEGIN@35 # spent 22µs making 1 call to constant::import
36221µs252µs
# spent 28µs (5+24) within Game::Collisions::AABB::BEGIN@36 which was called: # once (5µs+24µs) by Game::Collisions::BEGIN@30 at line 36
use constant _MAX_X => 4;
# spent 28µs making 1 call to Game::Collisions::AABB::BEGIN@36 # spent 24µs making 1 call to constant::import
37220µs244µs
# spent 24µs (4+20) within Game::Collisions::AABB::BEGIN@37 which was called: # once (4µs+20µs) by Game::Collisions::BEGIN@30 at line 37
use constant _MAX_Y => 5;
# spent 24µs making 1 call to Game::Collisions::AABB::BEGIN@37 # spent 20µs making 1 call to constant::import
38221µs246µs
# spent 25µs (4+21) within Game::Collisions::AABB::BEGIN@38 which was called: # once (4µs+21µs) by Game::Collisions::BEGIN@30 at line 38
use constant _PARENT_NODE => 6;
# spent 25µs making 1 call to Game::Collisions::AABB::BEGIN@38 # spent 21µs making 1 call to constant::import
39222µs246µs
# spent 26µs (5+20) within Game::Collisions::AABB::BEGIN@39 which was called: # once (5µs+20µs) by Game::Collisions::BEGIN@30 at line 39
use constant _LEFT_NODE => 7;
# spent 26µs making 1 call to Game::Collisions::AABB::BEGIN@39 # spent 20µs making 1 call to constant::import
402902µs242µs
# spent 24µs (5+19) within Game::Collisions::AABB::BEGIN@40 which was called: # once (5µs+19µs) by Game::Collisions::BEGIN@30 at line 40
use constant _RIGHT_NODE => 8;
# spent 24µs making 1 call to Game::Collisions::AABB::BEGIN@40 # spent 19µs making 1 call to constant::import
41
42
43sub new
44
# spent 3.32ms within Game::Collisions::AABB::new which was called 1999 times, avg 2µs/call: # 1000 times (1.61ms+0s) by Game::Collisions::make_aabb at line 52 of /home/tmurray/proj/Game-Collisions/lib/Game/Collisions.pm, avg 2µs/call # 999 times (1.71ms+0s) by Game::Collisions::_new_meta_aabb at line 147 of /home/tmurray/proj/Game-Collisions/lib/Game/Collisions.pm, avg 2µs/call
{
451999376µs my ($class, $args) = @_;
46 my $self = [
47 $args->{x},
48 $args->{y},
49 $args->{length},
50 $args->{height},
51 $args->{x} + $args->{length},
52 $args->{y} + $args->{height},
53 undef, # parent node
54 undef, # left node
55 undef, # right node
5619991.94ms ];
57
5819991.93ms bless $self => $class;
59}
60
61
62107742129ms
# spent 26.6ms within Game::Collisions::AABB::x which was called 107742 times, avg 247ns/call: # 52872 times (13.9ms+0s) by Game::Collisions::AABB::_calculate_bounding_box_for_nodes at line 210, avg 263ns/call # 52872 times (12.1ms+0s) by Game::Collisions::AABB::_calculate_bounding_box_for_nodes at line 212, avg 229ns/call # 1998 times (561µs+0s) by Game::Collisions::_add_aabb at line 113 of /home/tmurray/proj/Game-Collisions/lib/Game/Collisions.pm, avg 281ns/call
sub x { $_[0]->[_X] }
63107742136ms
# spent 24.8ms within Game::Collisions::AABB::y which was called 107742 times, avg 231ns/call: # 52872 times (12.3ms+0s) by Game::Collisions::AABB::_calculate_bounding_box_for_nodes at line 211, avg 233ns/call # 52872 times (12.0ms+0s) by Game::Collisions::AABB::_calculate_bounding_box_for_nodes at line 216, avg 228ns/call # 1998 times (499µs+0s) by Game::Collisions::_add_aabb at line 114 of /home/tmurray/proj/Game-Collisions/lib/Game/Collisions.pm, avg 250ns/call
sub y { $_[0]->[_Y] }
645287253.2ms
# spent 12.1ms within Game::Collisions::AABB::length which was called 52872 times, avg 229ns/call: # 52872 times (12.1ms+0s) by Game::Collisions::AABB::_calculate_bounding_box_for_nodes at line 212, avg 229ns/call
sub length { $_[0]->[_LENGTH] }
655287260.5ms
# spent 11.6ms within Game::Collisions::AABB::height which was called 52872 times, avg 220ns/call: # 52872 times (11.6ms+0s) by Game::Collisions::AABB::_calculate_bounding_box_for_nodes at line 216, avg 220ns/call
sub height { $_[0]->[_HEIGHT] }
66184198264ms
# spent 58.7ms within Game::Collisions::AABB::left_node which was called 184198 times, avg 319ns/call: # 183200 times (58.4ms+0s) by Game::Collisions::get_collisions_for_aabb at line 81 of /home/tmurray/proj/Game-Collisions/lib/Game/Collisions.pm, avg 319ns/call # 998 times (336µs+0s) by Game::Collisions::_add_aabb at line 133 of /home/tmurray/proj/Game-Collisions/lib/Game/Collisions.pm, avg 337ns/call
sub left_node { $_[0]->[_LEFT_NODE] }
67183200279ms
# spent 59.4ms within Game::Collisions::AABB::right_node which was called 183200 times, avg 324ns/call: # 183200 times (59.4ms+0s) by Game::Collisions::get_collisions_for_aabb at line 82 of /home/tmurray/proj/Game-Collisions/lib/Game/Collisions.pm, avg 324ns/call
sub right_node { $_[0]->[_RIGHT_NODE] }
681895620.4ms
# spent 5.35ms within Game::Collisions::AABB::parent which was called 18956 times, avg 282ns/call: # 17957 times (5.00ms+0s) by Game::Collisions::AABB::resize_all_parents at line 98, avg 278ns/call # 999 times (351µs+0s) by Game::Collisions::_add_aabb at line 123 of /home/tmurray/proj/Game-Collisions/lib/Game/Collisions.pm, avg 352ns/call
sub parent { $_[0]->[_PARENT_NODE] }
69
70
71sub set_left_node
72
# spent 11.6ms (3.76+7.89) within Game::Collisions::AABB::set_left_node which was called 1541 times, avg 8µs/call: # 999 times (3.13ms+5.60ms) by Game::Collisions::_add_aabb at line 124 of /home/tmurray/proj/Game-Collisions/lib/Game/Collisions.pm, avg 9µs/call # 542 times (629µs+2.29ms) by Game::Collisions::_add_aabb at line 136 of /home/tmurray/proj/Game-Collisions/lib/Game/Collisions.pm, avg 5µs/call
{
731541192µs my ($self, $node) = @_;
7415413.53ms15417.89ms return $self->_set_node( $node, _LEFT_NODE );
# spent 7.89ms making 1541 calls to Game::Collisions::AABB::_set_node, avg 5µs/call
75}
76
77sub set_right_node
78
# spent 8.76ms (3.72+5.04) within Game::Collisions::AABB::set_right_node which was called 1455 times, avg 6µs/call: # 999 times (3.19ms+3.17ms) by Game::Collisions::_add_aabb at line 125 of /home/tmurray/proj/Game-Collisions/lib/Game/Collisions.pm, avg 6µs/call # 456 times (538µs+1.87ms) by Game::Collisions::_add_aabb at line 136 of /home/tmurray/proj/Game-Collisions/lib/Game/Collisions.pm, avg 5µs/call
{
791455211µs my ($self, $node) = @_;
8014551.47ms14555.04ms return $self->_set_node( $node, _RIGHT_NODE );
# spent 5.04ms making 1455 calls to Game::Collisions::AABB::_set_node, avg 3µs/call
81}
82
83sub set_parent
84
# spent 2.07ms within Game::Collisions::AABB::set_parent which was called 2996 times, avg 692ns/call: # 2996 times (2.07ms+0s) by Game::Collisions::AABB::_set_node at line 185, avg 692ns/call
{
852996382µs my ($self, $parent) = @_;
862996425µs my $current_parent = $self->[_PARENT_NODE];
872996399µs $self->[_PARENT_NODE] = $parent;
8829962.10ms return $current_parent;
89}
90
91sub resize_all_parents
92
# spent 315ms (49.9+265) within Game::Collisions::AABB::resize_all_parents which was called 999 times, avg 316µs/call: # 999 times (49.9ms+265ms) by Game::Collisions::_add_aabb at line 139 of /home/tmurray/proj/Game-Collisions/lib/Game/Collisions.pm, avg 316µs/call
{
93999142µs my ($self) = @_;
94
95999223µs my @nodes_to_resize = ($self);
96999227µs while( @nodes_to_resize ) {
9794781.08ms my $next_node = shift @nodes_to_resize;
9894789.98ms179575.00ms push @nodes_to_resize, $next_node->parent
# spent 5.00ms making 17957 calls to Game::Collisions::AABB::parent, avg 278ns/call
99 if defined $next_node->parent;
10094785.64ms9478260ms $next_node->_resize_to_fit_children;
# spent 260ms making 9478 calls to Game::Collisions::AABB::_resize_to_fit_children, avg 27µs/call
101 }
102
103999726µs return;
104}
105
106sub does_collide
107
# spent 354ms within Game::Collisions::AABB::does_collide which was called 239960 times, avg 1µs/call: # 239960 times (354ms+0s) by Game::Collisions::get_collisions_for_aabb at line 84 of /home/tmurray/proj/Game-Collisions/lib/Game/Collisions.pm, avg 1µs/call
{
10823996030.2ms my ($self, $other_object) = @_;
10923996046.1ms return 0 if $self == $other_object; # Does not collide with itself
11023926094.7ms my ($minx1, $miny1, $length1, $height1, $maxx1, $maxy1) = @$self;
11123926070.0ms my ($minx2, $miny2, $length2, $height2, $maxx2, $maxy2) = @$other_object;
112
113239260403ms return $maxx1 >= $minx2
114 && $minx1 <= $maxx2
115 && $maxy1 >= $miny1
116 && $miny1 <= $maxy2;
117}
118
119sub find_best_sibling_node
120
# spent 469ms (43.8+425) within Game::Collisions::AABB::find_best_sibling_node which was called 999 times, avg 470µs/call: # 999 times (43.8ms+425ms) by Game::Collisions::_add_aabb at line 111 of /home/tmurray/proj/Game-Collisions/lib/Game/Collisions.pm, avg 470µs/call
{
121999151µs my ($self, $new_node) = @_;
122
123999267µs my @nodes_to_check = ($self);
124999157µs while( @nodes_to_check ) {
12594781.12ms my $check_node = shift @nodes_to_check;
12694781.45ms my $left_node = $check_node->[_LEFT_NODE];
12794781.24ms my $right_node = $check_node->[_RIGHT_NODE];
12894782.08ms return $check_node
129 if (! defined $left_node) || (! defined $right_node);
130
13184794.95ms8479207ms my (undef, undef, $left_length, $left_height)
# spent 207ms making 8479 calls to Game::Collisions::AABB::_calculate_bounding_box_for_nodes, avg 24µs/call
132 = $self->_calculate_bounding_box_for_nodes( $left_node, $new_node );
13384794.65ms8479218ms my (undef, undef, $right_length, $right_height)
# spent 218ms making 8479 calls to Game::Collisions::AABB::_calculate_bounding_box_for_nodes, avg 26µs/call
134 = $self->_calculate_bounding_box_for_nodes( $right_node, $new_node);
135
1368479980µs my $left_surface = $left_length * $left_height;
1378479750µs my $right_surface = $right_length * $right_height;
13884794.14ms push @nodes_to_check,
139 ($left_surface > $right_surface) ? $right_node : $left_node;
140 }
141
142 # How did we get here? It should have descended the tree until it
143 # came to the leaf and returned that. Just in case, return ourselves.
144 return $self;
145}
146
147sub is_branch_node
148
# spent 105ms within Game::Collisions::AABB::is_branch_node which was called 194280 times, avg 539ns/call: # 194280 times (105ms+0s) by Game::Collisions::get_collisions_for_aabb at line 80 of /home/tmurray/proj/Game-Collisions/lib/Game/Collisions.pm, avg 539ns/call
{
14919428021.3ms my ($self) = @_;
150194280337ms return (defined $self->[_LEFT_NODE]) || (defined $self->[_RIGHT_NODE]);
151}
152
153sub dump_tree
154{
155 my ($self, $spacing) = @_;
156 $spacing //= '';
157
158 my $draw_chars = $self->is_branch_node
159 ? '├┐'
160 : '│├';
161 my $str = "$spacing├┤ " . join( ', ',
162 "$self",
163 $self->x,
164 $self->y,
165 $self->length,
166 $self->height,
167 );
168 $str .= "\n";
169 $str .= $self->left_node->dump_tree( $spacing . '┼' )
170 if defined $self->left_node;
171 $str .= $self->right_node->dump_tree( $spacing . '┼' )
172 if defined $self->right_node;
173
174 return $str;
175}
176
177
178sub _set_node
179
# spent 12.9ms (9.76+3.17) within Game::Collisions::AABB::_set_node which was called 2996 times, avg 4µs/call: # 1541 times (6.14ms+1.74ms) by Game::Collisions::AABB::set_left_node at line 74, avg 5µs/call # 1455 times (3.62ms+1.42ms) by Game::Collisions::AABB::set_right_node at line 80, avg 3µs/call
{
1802996445µs my ($self, $node, $index) = @_;
18129961.45ms998246µs Scalar::Util::unweaken( $self->[$index] )
# spent 246µs making 998 calls to Scalar::Util::unweaken, avg 246ns/call
182 if defined $self->[$index];
1832996380µs $self->[$index] = $node;
18429964.91ms2996847µs Scalar::Util::weaken( $self->[$index] );
# spent 847µs making 2996 calls to Scalar::Util::weaken, avg 283ns/call
18529961.35ms29962.07ms my $former_parent = $node->set_parent( $self );
# spent 2.07ms making 2996 calls to Game::Collisions::AABB::set_parent, avg 692ns/call
18629966.10ms return $former_parent;
187}
188
189sub _resize_to_fit_children
190
# spent 260ms (27.1+233) within Game::Collisions::AABB::_resize_to_fit_children which was called 9478 times, avg 27µs/call: # 9478 times (27.1ms+233ms) by Game::Collisions::AABB::resize_all_parents at line 100, avg 27µs/call
{
19194781.09ms my ($self) = @_;
19294785.96ms9478233ms my ($x, $y, $length, $height) = $self->_calculate_bounding_box_for_nodes(
# spent 233ms making 9478 calls to Game::Collisions::AABB::_calculate_bounding_box_for_nodes, avg 25µs/call
193 $self->[_LEFT_NODE],
194 $self->[_RIGHT_NODE],
195 );
196
19794781.17ms $self->[_X] = $x;
1989478971µs $self->[_Y] = $y;
1999478933µs $self->[_LENGTH] = $length;
2009478883µs $self->[_HEIGHT] = $height;
20194781.16ms $self->[_MAX_X] = $x + $length;
2029478946µs $self->[_MAX_Y] = $y + $height;
203
204947820.1ms return;
205}
206
207sub _calculate_bounding_box_for_nodes
208
# spent 659ms (566+92.1) within Game::Collisions::AABB::_calculate_bounding_box_for_nodes which was called 26436 times, avg 25µs/call: # 9478 times (201ms+32.6ms) by Game::Collisions::AABB::_resize_to_fit_children at line 192, avg 25µs/call # 8479 times (188ms+29.4ms) by Game::Collisions::AABB::find_best_sibling_node at line 133, avg 26µs/call # 8479 times (177ms+30.1ms) by Game::Collisions::AABB::find_best_sibling_node at line 131, avg 24µs/call
{
209264363.28ms my ($self, $node1, $node2) = @_;
2102643661.6ms7930818.1ms my $min_x = List::Util::min( $node1->x, $node2->x );
# spent 13.9ms making 52872 calls to Game::Collisions::AABB::x, avg 263ns/call # spent 4.21ms making 26436 calls to List::Util::min, avg 159ns/call
2112643658.2ms7930815.2ms my $min_y = List::Util::min( $node1->y, $node2->y );
# spent 12.3ms making 52872 calls to Game::Collisions::AABB::y, avg 233ns/call # spent 2.94ms making 26436 calls to List::Util::min, avg 111ns/call
2122643672.9ms13218029.7ms my $max_x = List::Util::max(
# spent 12.1ms making 52872 calls to Game::Collisions::AABB::x, avg 229ns/call # spent 12.1ms making 52872 calls to Game::Collisions::AABB::length, avg 229ns/call # spent 5.48ms making 26436 calls to List::Util::max, avg 207ns/call
213 $node1->length + $node1->x,
214 $node2->length + $node2->x,
215 );
2162643666.0ms13218029.0ms my $max_y = List::Util::max(
# spent 12.0ms making 52872 calls to Game::Collisions::AABB::y, avg 228ns/call # spent 11.6ms making 52872 calls to Game::Collisions::AABB::height, avg 220ns/call # spent 5.38ms making 26436 calls to List::Util::max, avg 203ns/call
217 $node1->height + $node1->y,
218 $node2->height + $node2->y,
219 );
220
221264362.66ms my $length = $max_x - $min_x;
222264362.35ms my $height = $max_y - $min_y;
2232643651.5ms return ($min_x, $min_y, $length, $height);
224}
225
226
22713µs1;
228__END__