Filename | /Users/ap13/perl5/lib/perl5/Graph/Attribute.pm |
Statements | Executed 70 statements in 1.08ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 92µs | 115µs | import | Graph::Attribute::
2 | 1 | 1 | 44µs | 52µs | get_attribute | Graph::Attribute::
2 | 1 | 1 | 44µs | 63µs | set_attribute | Graph::Attribute::
10 | 1 | 1 | 22µs | 22µs | CORE:match (opcode) | Graph::Attribute::
2 | 1 | 1 | 19µs | 19µs | __ANON__[:19] | Graph::Attribute::
1 | 1 | 1 | 15µs | 36µs | BEGIN@3 | Graph::Attribute::
1 | 1 | 1 | 8µs | 19µs | BEGIN@14 | Graph::Attribute::
1 | 1 | 1 | 8µs | 19µs | BEGIN@24 | Graph::Attribute::
1 | 1 | 1 | 8µs | 18µs | BEGIN@49 | Graph::Attribute::
2 | 1 | 1 | 8µs | 8µs | __ANON__[:15] | Graph::Attribute::
0 | 0 | 0 | 0s | 0s | __ANON__[:20] | Graph::Attribute::
0 | 0 | 0 | 0s | 0s | __ANON__[:21] | Graph::Attribute::
0 | 0 | 0 | 0s | 0s | __ANON__[:25] | Graph::Attribute::
0 | 0 | 0 | 0s | 0s | __ANON__[:29] | Graph::Attribute::
0 | 0 | 0 | 0s | 0s | __ANON__[:30] | Graph::Attribute::
0 | 0 | 0 | 0s | 0s | __ANON__[:31] | Graph::Attribute::
0 | 0 | 0 | 0s | 0s | delete_attribute | Graph::Attribute::
0 | 0 | 0 | 0s | 0s | delete_attributes | Graph::Attribute::
0 | 0 | 0 | 0s | 0s | get_attribute_names | Graph::Attribute::
0 | 0 | 0 | 0s | 0s | get_attribute_values | Graph::Attribute::
0 | 0 | 0 | 0s | 0s | get_attributes | Graph::Attribute::
0 | 0 | 0 | 0s | 0s | has_attribute | Graph::Attribute::
0 | 0 | 0 | 0s | 0s | has_attributes | Graph::Attribute::
0 | 0 | 0 | 0s | 0s | set_attributes | Graph::Attribute::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Graph::Attribute; | ||||
2 | |||||
3 | 2 | 80µs | 2 | 57µs | # spent 36µs (15+21) within Graph::Attribute::BEGIN@3 which was called:
# once (15µs+21µs) by Graph::BEGIN@86 at line 3 # spent 36µs making 1 call to Graph::Attribute::BEGIN@3
# spent 21µs making 1 call to strict::import |
4 | |||||
5 | sub _F () { 0 } | ||||
6 | sub _COMPAT02 () { 0x00000001 } | ||||
7 | |||||
8 | # spent 115µs (92+22) within Graph::Attribute::import which was called:
# once (92µs+22µs) by Graph::BEGIN@86 at line 86 of Graph.pm | ||||
9 | 1 | 600ns | my $package = shift; | ||
10 | 1 | 2µs | my %attr = @_; | ||
11 | 1 | 1µs | my $caller = caller(0); | ||
12 | 1 | 600ns | if (exists $attr{array}) { | ||
13 | 1 | 300ns | my $i = $attr{array}; | ||
14 | 2 | 162µs | 2 | 30µs | # spent 19µs (8+11) within Graph::Attribute::BEGIN@14 which was called:
# once (8µs+11µs) by Graph::BEGIN@86 at line 14 # spent 19µs making 1 call to Graph::Attribute::BEGIN@14
# spent 11µs making 1 call to strict::unimport |
15 | 3 | 27µs | # spent 8µs within Graph::Attribute::__ANON__[/Users/ap13/perl5/lib/perl5/Graph/Attribute.pm:15] which was called 2 times, avg 4µs/call:
# 2 times (8µs+0s) by Graph::Attribute::get_attribute at line 86, avg 4µs/call | ||
16 | *{"${caller}::_set_attributes"} = | ||||
17 | 2 | 6µs | # spent 19µs within Graph::Attribute::__ANON__[/Users/ap13/perl5/lib/perl5/Graph/Attribute.pm:19] which was called 2 times, avg 10µs/call:
# 2 times (19µs+0s) by Graph::Attribute::set_attribute at line 59, avg 10µs/call | ||
18 | 2 | 2µs | $_[0]->[ $i ] = $_[1] if @_ == 2; | ||
19 | 3 | 20µs | $_[0]->[ $i ] }; | ||
20 | 1 | 4µs | *{"${caller}::_has_attributes"} = sub { defined $_[0]->[ $i ] }; | ||
21 | 1 | 6µs | *{"${caller}::_delete_attributes"} = sub { undef $_[0]->[ $i ]; 1 }; | ||
22 | } elsif (exists $attr{hash}) { | ||||
23 | my $k = $attr{hash}; | ||||
24 | 2 | 232µs | 2 | 30µs | # spent 19µs (8+11) within Graph::Attribute::BEGIN@24 which was called:
# once (8µs+11µs) by Graph::BEGIN@86 at line 24 # spent 19µs making 1 call to Graph::Attribute::BEGIN@24
# spent 11µs making 1 call to strict::unimport |
25 | *{"${caller}::_get_attributes"} = sub { $_[0]->{ $k } }; | ||||
26 | *{"${caller}::_set_attributes"} = | ||||
27 | sub { $_[0]->{ $k } ||= { }; | ||||
28 | $_[0]->{ $k } = $_[1] if @_ == 2; | ||||
29 | $_[0]->{ $k } }; | ||||
30 | *{"${caller}::_has_attributes"} = sub { defined $_[0]->{ $k } }; | ||||
31 | *{"${caller}::_delete_attributes"} = sub { delete $_[0]->{ $k } }; | ||||
32 | } else { | ||||
33 | die "Graph::Attribute::import($package @_) caller $caller\n"; | ||||
34 | } | ||||
35 | 1 | 2µs | my @api = qw(get_attribute | ||
36 | get_attributes | ||||
37 | set_attribute | ||||
38 | set_attributes | ||||
39 | has_attribute | ||||
40 | has_attributes | ||||
41 | delete_attribute | ||||
42 | delete_attributes | ||||
43 | get_attribute_names | ||||
44 | get_attribute_values); | ||||
45 | 1 | 6µs | if (exists $attr{map}) { | ||
46 | 1 | 300ns | my $map = $attr{map}; | ||
47 | 1 | 600ns | for my $api (@api) { | ||
48 | 10 | 45µs | 10 | 22µs | my ($first, $rest) = ($api =~ /^(\w+?)_(.+)/); # spent 22µs making 10 calls to Graph::Attribute::CORE:match, avg 2µs/call |
49 | 2 | 392µs | 2 | 29µs | # spent 18µs (8+11) within Graph::Attribute::BEGIN@49 which was called:
# once (8µs+11µs) by Graph::BEGIN@86 at line 49 # spent 18µs making 1 call to Graph::Attribute::BEGIN@49
# spent 10µs making 1 call to strict::unimport |
50 | 10 | 33µs | *{"${caller}::${first}_${map}_${rest}"} = \&$api; | ||
51 | } | ||||
52 | } | ||||
53 | } | ||||
54 | |||||
55 | # spent 63µs (44+19) within Graph::Attribute::set_attribute which was called 2 times, avg 32µs/call:
# 2 times (44µs+19µs) by Graph::_check_cache at line 2657 of Graph.pm, avg 32µs/call | ||||
56 | 2 | 2µs | my $g = shift; | ||
57 | 2 | 500ns | my $v = pop; | ||
58 | 2 | 2µs | my $a = pop; | ||
59 | 2 | 10µs | 2 | 19µs | my $p = $g->_set_attributes; # spent 19µs making 2 calls to Graph::Attribute::__ANON__[Graph/Attribute.pm:19], avg 10µs/call |
60 | 2 | 4µs | $p->{ $a } = $v; | ||
61 | 2 | 7µs | return 1; | ||
62 | } | ||||
63 | |||||
64 | sub set_attributes { | ||||
65 | my $g = shift; | ||||
66 | my $a = pop; | ||||
67 | my $p = $g->_set_attributes( $a ); | ||||
68 | return 1; | ||||
69 | } | ||||
70 | |||||
71 | sub has_attribute { | ||||
72 | my $g = shift; | ||||
73 | my $a = pop; | ||||
74 | my $p = $g->_get_attributes; | ||||
75 | $p ? exists $p->{ $a } : 0; | ||||
76 | } | ||||
77 | |||||
78 | sub has_attributes { | ||||
79 | my $g = shift; | ||||
80 | $g->_get_attributes ? 1 : 0; | ||||
81 | } | ||||
82 | |||||
83 | # spent 52µs (44+8) within Graph::Attribute::get_attribute which was called 2 times, avg 26µs/call:
# 2 times (44µs+8µs) by Graph::_check_cache at line 2653 of Graph.pm, avg 26µs/call | ||||
84 | 2 | 1µs | my $g = shift; | ||
85 | 2 | 2µs | my $a = pop; | ||
86 | 2 | 15µs | 2 | 8µs | my $p = $g->_get_attributes; # spent 8µs making 2 calls to Graph::Attribute::__ANON__[Graph/Attribute.pm:15], avg 4µs/call |
87 | 2 | 13µs | $p ? $p->{ $a } : undef; | ||
88 | } | ||||
89 | |||||
90 | sub delete_attribute { | ||||
91 | my $g = shift; | ||||
92 | my $a = pop; | ||||
93 | my $p = $g->_get_attributes; | ||||
94 | if (defined $p) { | ||||
95 | delete $p->{ $a }; | ||||
96 | return 1; | ||||
97 | } else { | ||||
98 | return 0; | ||||
99 | } | ||||
100 | } | ||||
101 | |||||
102 | sub delete_attributes { | ||||
103 | my $g = shift; | ||||
104 | if ($g->_has_attributes) { | ||||
105 | $g->_delete_attributes; | ||||
106 | return 1; | ||||
107 | } else { | ||||
108 | return 0; | ||||
109 | } | ||||
110 | } | ||||
111 | |||||
112 | sub get_attribute_names { | ||||
113 | my $g = shift; | ||||
114 | my $p = $g->_get_attributes; | ||||
115 | defined $p ? keys %{ $p } : ( ); | ||||
116 | } | ||||
117 | |||||
118 | sub get_attribute_values { | ||||
119 | my $g = shift; | ||||
120 | my $p = $g->_get_attributes; | ||||
121 | defined $p ? values %{ $p } : ( ); | ||||
122 | } | ||||
123 | |||||
124 | sub get_attributes { | ||||
125 | my $g = shift; | ||||
126 | my $a = $g->_get_attributes; | ||||
127 | ($g->[ _F ] & _COMPAT02) ? (defined $a ? %{ $a } : ()) : $a; | ||||
128 | } | ||||
129 | |||||
130 | 1 | 2µs | 1; | ||
# spent 22µs within Graph::Attribute::CORE:match which was called 10 times, avg 2µs/call:
# 10 times (22µs+0s) by Graph::Attribute::import at line 48, avg 2µs/call |