← Index
NYTProf Performance Profile   « block view • line view • sub view »
For bin/pan_genome_post_analysis
  Run on Fri Mar 27 11:43:32 2015
Reported on Fri Mar 27 11:46:15 2015

Filename/Users/ap13/perl5/lib/perl5/Graph/AdjacencyMap/Light.pm
StatementsExecuted 887776 statements in 573ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
3491121226ms236msGraph::AdjacencyMap::Light::::set_pathGraph::AdjacencyMap::Light::set_path
4975221140ms140msGraph::AdjacencyMap::Light::::_get_path_idGraph::AdjacencyMap::Light::_get_path_id
5023822137ms137msGraph::AdjacencyMap::Light::::_get_id_pathGraph::AdjacencyMap::Light::_get_id_path
2102116.9ms16.9msGraph::AdjacencyMap::Light::::pathsGraph::AdjacencyMap::Light::paths
351952115.8ms15.8msGraph::AdjacencyMap::Light::::_is_MULTIGraph::AdjacencyMap::Light::_is_MULTI (xsub)
9977119.81ms9.81msGraph::AdjacencyMap::Light::::CORE:sortGraph::AdjacencyMap::Light::CORE:sort (opcode)
224212.34ms2.72msGraph::AdjacencyMap::Light::::_newGraph::AdjacencyMap::Light::_new
67112.11ms13.9msGraph::AdjacencyMap::Light::::__attrGraph::AdjacencyMap::Light::__attr
1111.08ms1.43msGraph::AdjacencyMap::Light::::BEGIN@15Graph::AdjacencyMap::Light::BEGIN@15
1792196µs96µsGraph::AdjacencyMap::Light::::_is_COUNTGraph::AdjacencyMap::Light::_is_COUNT (xsub)
761195µs95µsGraph::AdjacencyMap::Light::::_is_HYPERGraph::AdjacencyMap::Light::_is_HYPER (xsub)
11113µs26µsGraph::AdjacencyMap::Light::::BEGIN@7Graph::AdjacencyMap::Light::BEGIN@7
11110µs34µsGraph::AdjacencyMap::Light::::BEGIN@12Graph::AdjacencyMap::Light::BEGIN@12
1119µs67µsGraph::AdjacencyMap::Light::::BEGIN@10Graph::AdjacencyMap::Light::BEGIN@10
1118µs252µsGraph::AdjacencyMap::Light::::BEGIN@9Graph::AdjacencyMap::Light::BEGIN@9
1118µs19µsGraph::AdjacencyMap::Light::::BEGIN@14Graph::AdjacencyMap::Light::BEGIN@14
0000s0sGraph::AdjacencyMap::Light::::__predecessorsGraph::AdjacencyMap::Light::__predecessors
0000s0sGraph::AdjacencyMap::Light::::__successorsGraph::AdjacencyMap::Light::__successors
0000s0sGraph::AdjacencyMap::Light::::_get_path_countGraph::AdjacencyMap::Light::_get_path_count
0000s0sGraph::AdjacencyMap::Light::::_predecessorsGraph::AdjacencyMap::Light::_predecessors
0000s0sGraph::AdjacencyMap::Light::::_successorsGraph::AdjacencyMap::Light::_successors
0000s0sGraph::AdjacencyMap::Light::::del_pathGraph::AdjacencyMap::Light::del_path
0000s0sGraph::AdjacencyMap::Light::::has_pathGraph::AdjacencyMap::Light::has_path
0000s0sGraph::AdjacencyMap::Light::::has_pathsGraph::AdjacencyMap::Light::has_paths
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Graph::AdjacencyMap::Light;
2
3# THIS IS INTERNAL IMPLEMENTATION ONLY, NOT TO BE USED DIRECTLY.
4# THE INTERFACE IS HARD TO USE AND GOING TO STAY THAT WAY AND
5# ALMOST GUARANTEED TO CHANGE OR GO AWAY IN FUTURE RELEASES.
6
7231µs239µs
# spent 26µs (13+13) within Graph::AdjacencyMap::Light::BEGIN@7 which was called: # once (13µs+13µs) by Graph::BEGIN@29 at line 7
use strict;
# spent 26µs making 1 call to Graph::AdjacencyMap::Light::BEGIN@7 # spent 13µs making 1 call to strict::import
8
9228µs2496µs
# spent 252µs (8+244) within Graph::AdjacencyMap::Light::BEGIN@9 which was called: # once (8µs+244µs) by Graph::BEGIN@29 at line 9
use Graph::AdjacencyMap qw(:flags :fields);
# spent 252µs making 1 call to Graph::AdjacencyMap::Light::BEGIN@9 # spent 244µs making 1 call to Exporter::import
10226µs2126µs
# spent 67µs (9+59) within Graph::AdjacencyMap::Light::BEGIN@10 which was called: # once (9µs+59µs) by Graph::BEGIN@29 at line 10
use base 'Graph::AdjacencyMap';
# spent 67µs making 1 call to Graph::AdjacencyMap::Light::BEGIN@10 # spent 59µs making 1 call to base::import
11
12225µs258µs
# spent 34µs (10+24) within Graph::AdjacencyMap::Light::BEGIN@12 which was called: # once (10µs+24µs) by Graph::BEGIN@29 at line 12
use Scalar::Util qw(weaken);
# spent 34µs making 1 call to Graph::AdjacencyMap::Light::BEGIN@12 # spent 24µs making 1 call to Exporter::import
13
14221µs231µs
# spent 19µs (8+11) within Graph::AdjacencyMap::Light::BEGIN@14 which was called: # once (8µs+11µs) by Graph::BEGIN@29 at line 14
use Graph::AdjacencyMap::Heavy;
# spent 19µs making 1 call to Graph::AdjacencyMap::Light::BEGIN@14 # spent 12µs making 1 call to Exporter::import
1521.22ms21.45ms
# spent 1.43ms (1.08+352µs) within Graph::AdjacencyMap::Light::BEGIN@15 which was called: # once (1.08ms+352µs) by Graph::BEGIN@29 at line 15
use Graph::AdjacencyMap::Vertex;
# spent 1.43ms making 1 call to Graph::AdjacencyMap::Light::BEGIN@15 # spent 17µs making 1 call to Exporter::import
16
17sub _V () { 2 } # Graph::_V
18sub _E () { 3 } # Graph::_E
19sub _F () { 0 } # Graph::_F
20
21
# spent 2.72ms (2.34+374µs) within Graph::AdjacencyMap::Light::_new which was called 224 times, avg 12µs/call: # 112 times (1.44ms+271µs) by Graph::new at line 300 of Graph.pm, avg 15µs/call # 112 times (902µs+103µs) by Graph::new at line 305 of Graph.pm, avg 9µs/call
sub _new {
22224231µs my ($class, $graph, $flags, $arity) = @_;
23224271µs my $m = bless [ ], $class;
24224125µs $m->[ _n ] = 0;
2522493µs $m->[ _f ] = $flags | _LIGHT;
2622444µs $m->[ _a ] = $arity;
2722484µs $m->[ _i ] = { };
28224145µs $m->[ _s ] = { };
2922473µs $m->[ _p ] = { };
30224144µs $m->[ _g ] = $graph;
31224940µs224374µs weaken $m->[ _g ]; # So that DESTROY finds us earlier.
# spent 374µs making 224 calls to Scalar::Util::weaken, avg 2µs/call
32224538µs return $m;
33}
34
35
# spent 236ms (226+9.81) within Graph::AdjacencyMap::Light::set_path which was called 34911 times, avg 7µs/call: # 24934 times (132ms+0s) by Graph::add_vertex at line 396 of Graph.pm, avg 5µs/call # 9977 times (94.8ms+9.81ms) by Graph::add_edge at line 504 of Graph.pm, avg 10µs/call
sub set_path {
36349116.35ms my $m = shift;
373491117.6ms my ($n, $f, $a, $i, $s, $p) = @$m;
383491130.9ms99779.81ms if ($a == 2) {
# spent 9.81ms making 9977 calls to Graph::AdjacencyMap::Light::CORE:sort, avg 984ns/call
39 @_ = sort @_ if ($f & _UNORD);
40 }
41349117.47ms my $e0 = shift;
423491168.6ms if ($a == 2) {
4399771.13ms my $e1 = shift;
4499774.96ms unless (exists $s->{ $e0 } && exists $s->{ $e0 }->{ $e1 }) {
4599772.40ms $n = $m->[ _n ]++;
46997714.7ms $i->{ $n } = [ $e0, $e1 ];
47997710.7ms $s->{ $e0 }->{ $e1 } = $n;
48997711.6ms $p->{ $e1 }->{ $e0 } = $n;
49 }
50 } else {
51249348.15ms unless (exists $s->{ $e0 }) {
52249346.82ms $n = $m->[ _n ]++;
532493414.1ms $s->{ $e0 } = $n;
542493424.4ms $i->{ $n } = $e0;
55 }
56 }
57}
58
59sub has_path {
60 my $m = shift;
61 my ($n, $f, $a, $i, $s) = @$m;
62 return 0 unless $a == @_;
63 my $e;
64 if ($a == 2) {
65 @_ = sort @_ if ($f & _UNORD);
66 $e = shift;
67 return 0 unless exists $s->{ $e };
68 $s = $s->{ $e };
69 }
70 $e = shift;
71 exists $s->{ $e };
72}
73
74
# spent 140ms within Graph::AdjacencyMap::Light::_get_path_id which was called 49752 times, avg 3µs/call: # 24876 times (75.4ms+0s) by Graph::_edges at line 812 of Graph.pm, avg 3µs/call # 24876 times (64.5ms+0s) by Graph::_edges at line 817 of Graph.pm, avg 3µs/call
sub _get_path_id {
75497528.89ms my $m = shift;
764975220.0ms my ($n, $f, $a, $i, $s) = @$m;
77497526.79ms return undef unless $a == @_;
78497521.09ms my $e;
79497524.70ms if ($a == 2) {
80 @_ = sort @_ if ($f & _UNORD);
81 $e = shift;
82 return undef unless exists $s->{ $e };
83 $s = $s->{ $e };
84 }
85497527.20ms $e = shift;
8649752106ms $s->{ $e };
87}
88
89sub _get_path_count {
90 my $m = shift;
91 my ($n, $f, $a, $i, $s) = @$m;
92 my $e;
93 if (@_ == 2) {
94 @_ = sort @_ if ($f & _UNORD);
95 $e = shift;
96 return undef unless exists $s->{ $e };
97 $s = $s->{ $e };
98 }
99 $e = shift;
100 return exists $s->{ $e } ? 1 : 0;
101}
102
103sub has_paths {
104 my $m = shift;
105 my ($n, $f, $a, $i, $s) = @$m;
106 keys %$s;
107}
108
109
# spent 16.9ms within Graph::AdjacencyMap::Light::paths which was called 210 times, avg 80µs/call: # 134 times (709µs+0s) by Graph::edges05 at line 557 of Graph.pm, avg 5µs/call # 76 times (16.2ms+0s) by Graph::vertices05 at line 411 of Graph.pm, avg 213µs/call
sub paths {
11021056µs my $m = shift;
111210152µs my ($n, $f, $a, $i) = @$m;
11221066µs if (defined $i) {
113210377µs my ($k, $v) = each %$i;
114210259µs if (ref $v) {
115 return values %{ $i };
116 } else {
11714316.2ms return map { [ $_ ] } values %{ $i };
118 }
119 } else {
120 return ( );
121 }
122}
123
124
# spent 137ms within Graph::AdjacencyMap::Light::_get_id_path which was called 50238 times, avg 3µs/call: # 50037 times (136ms+0s) by Graph::AdjacencyMap::_successors at line 396 of Graph/AdjacencyMap.pm, avg 3µs/call # 201 times (607µs+0s) by Graph::edges05 at line 559 of Graph.pm, avg 3µs/call
sub _get_id_path {
125502388.61ms my $m = shift;
1265023816.6ms my ($n, $f, $a, $i) = @$m;
1275023833.5ms my $p = $i->{ $_[ 0 ] };
12850238107ms defined $p ? ( ref $p eq 'ARRAY' ? @$p : $p ) : ( );
129}
130
131sub del_path {
132 my $m = shift;
133 my ($n, $f, $a, $i, $s, $p) = @$m;
134 if (@_ == 2) {
135 @_ = sort @_ if ($f & _UNORD);
136 my $e0 = shift;
137 return 0 unless exists $s->{ $e0 };
138 my $e1 = shift;
139 if (defined($n = $s->{ $e0 }->{ $e1 })) {
140 delete $i->{ $n };
141 delete $s->{ $e0 }->{ $e1 };
142 delete $p->{ $e1 }->{ $e0 };
143 delete $s->{ $e0 } unless keys %{ $s->{ $e0 } };
144 delete $p->{ $e1 } unless keys %{ $p->{ $e1 } };
145 return 1;
146 }
147 } else {
148 my $e = shift;
149 if (defined($n = $s->{ $e })) {
150 delete $i->{ $n };
151 delete $s->{ $e };
152 return 1;
153 }
154 }
155 return 0;
156}
157
158sub __successors {
159 my $E = shift;
160 return wantarray ? () : 0 unless defined $E->[ _s ];
161 my $g = shift;
162 my $V = $g->[ _V ];
163 return wantarray ? () : 0 unless defined $V && defined $V->[ _s ];
164 # my $i = $V->_get_path_id( $_[0] );
165 my $i =
166 ($V->[ _f ] & _LIGHT) ?
167 $V->[ _s ]->{ $_[0] } :
168 $V->_get_path_id( $_[0] );
169 return wantarray ? () : 0 unless defined $i && defined $E->[ _s ]->{ $i };
170 return keys %{ $E->[ _s ]->{ $i } };
171}
172
173sub _successors {
174 my $E = shift;
175 my $g = shift;
176 my @s = $E->__successors($g, @_);
177 if (($E->[ _f ] & _UNORD)) {
178 push @s, $E->__predecessors($g, @_);
179 my %s; @s{ @s } = ();
180 @s = keys %s;
181 }
182 my $V = $g->[ _V ];
183 return wantarray ? map { $V->[ _i ]->{ $_ } } @s : @s;
184}
185
186sub __predecessors {
187 my $E = shift;
188 return wantarray ? () : 0 unless defined $E->[ _p ];
189 my $g = shift;
190 my $V = $g->[ _V ];
191 return wantarray ? () : 0 unless defined $V && defined $V->[ _s ];
192 # my $i = $V->_get_path_id( $_[0] );
193 my $i =
194 ($V->[ _f ] & _LIGHT) ?
195 $V->[ _s ]->{ $_[0] } :
196 $V->_get_path_id( $_[0] );
197 return wantarray ? () : 0 unless defined $i && defined $E->[ _p ]->{ $i };
198 return keys %{ $E->[ _p ]->{ $i } };
199}
200
201sub _predecessors {
202 my $E = shift;
203 my $g = shift;
204 my @p = $E->__predecessors($g, @_);
205 if ($E->[ _f ] & _UNORD) {
206 push @p, $E->__successors($g, @_);
207 my %p; @p{ @p } = ();
208 @p = keys %p;
209 }
210 my $V = $g->[ _V ];
211 return wantarray ? map { $V->[ _i ]->{ $_ } } @p : @p;
212}
213
214
# spent 13.9ms (2.11+11.8) within Graph::AdjacencyMap::Light::__attr which was called 67 times, avg 208µs/call: # 67 times (2.11ms+11.8ms) by Graph::AdjacencyMap::_set_path_attr at line 207 of Graph/AdjacencyMap.pm, avg 208µs/call
sub __attr {
215 # Major magic takes place here: we rebless the appropriate 'light'
216 # map into a more complex map and then redispatch the method.
2176738µs my $m = $_[0];
2186771µs my ($n, $f, $a, $i, $s, $p, $g) = @$m;
21967133µs my ($k, $v) = each %$i;
22067108µs my @V = @{ $g->[ _V ] };
22167205µs673.30ms my @E = $g->edges; # TODO: Both these (ZZZ) lines are mysteriously needed!
# spent 3.30ms making 67 calls to Graph::edges, avg 49µs/call
222 # ZZZ: an example of failing tests is t/52_edge_attributes.t.
2236763µs if (ref $v eq 'ARRAY') { # Edges, then.
224 # print "Reedging.\n";
22567174µs672.67ms @E = $g->edges; # TODO: Both these (ZZZ) lines are mysteriously needed!
# spent 2.67ms making 67 calls to Graph::edges, avg 40µs/call
22667382µs67303µs $g->[ _E ] = $m = Graph::AdjacencyMap::Heavy->_new($f, 2);
# spent 303µs making 67 calls to Graph::AdjacencyMap::_new, avg 5µs/call
22767196µs675.56ms $g->add_edges( @E );
# spent 5.56ms making 67 calls to Graph::add_edges, avg 83µs/call
228 } else {
229 # print "Revertexing.\n";
230 $m = Graph::AdjacencyMap::Vertex->_new(($f & ~_LIGHT), 1);
231 $m->[ _n ] = $V[ _n ];
232 $m->[ _i ] = $V[ _i ];
233 $m->[ _s ] = $V[ _s ];
234 $m->[ _p ] = $V[ _p ];
235 $g->[ _V ] = $m;
236 }
2376730µs $_[0] = $m;
23867592µs67641µs goto &{ ref($m) . "::__attr" }; # Redispatch.
# spent 641µs making 67 calls to Graph::AdjacencyMap::Heavy::__attr, avg 10µs/call
239}
240
241sub _is_COUNT () { 0 }
242sub _is_MULTI () { 0 }
243sub _is_HYPER () { 0 }
244sub _is_UNIQ () { 0 }
245sub _is_REF () { 0 }
246
24712µs1;
 
# spent 9.81ms within Graph::AdjacencyMap::Light::CORE:sort which was called 9977 times, avg 984ns/call: # 9977 times (9.81ms+0s) by Graph::AdjacencyMap::Light::set_path at line 38, avg 984ns/call
sub Graph::AdjacencyMap::Light::CORE:sort; # opcode
# spent 96µs within Graph::AdjacencyMap::Light::_is_COUNT which was called 179 times, avg 536ns/call: # 141 times (77µs+0s) by Graph::countedged at line 337 of Graph.pm, avg 544ns/call # 38 times (19µs+0s) by Graph::countvertexed at line 328 of Graph.pm, avg 508ns/call
sub Graph::AdjacencyMap::Light::_is_COUNT; # xsub
# spent 95µs within Graph::AdjacencyMap::Light::_is_HYPER which was called 76 times, avg 1µs/call: # 76 times (95µs+0s) by Graph::vertices05 at line 412 of Graph.pm, avg 1µs/call
sub Graph::AdjacencyMap::Light::_is_HYPER; # xsub
# spent 15.8ms within Graph::AdjacencyMap::Light::_is_MULTI which was called 35195 times, avg 449ns/call: # 24972 times (11.2ms+0s) by Graph::multivertexed at line 329 of Graph.pm, avg 447ns/call # 10223 times (4.67ms+0s) by Graph::multiedged at line 338 of Graph.pm, avg 457ns/call
sub Graph::AdjacencyMap::Light::_is_MULTI; # xsub