| 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 | Graph::Attribute::import |
| 2 | 1 | 1 | 44µs | 52µs | Graph::Attribute::get_attribute |
| 2 | 1 | 1 | 44µs | 63µs | Graph::Attribute::set_attribute |
| 10 | 1 | 1 | 22µs | 22µs | Graph::Attribute::CORE:match (opcode) |
| 2 | 1 | 1 | 19µs | 19µs | Graph::Attribute::__ANON__[:19] |
| 1 | 1 | 1 | 15µs | 36µs | Graph::Attribute::BEGIN@3 |
| 1 | 1 | 1 | 8µs | 19µs | Graph::Attribute::BEGIN@14 |
| 1 | 1 | 1 | 8µs | 19µs | Graph::Attribute::BEGIN@24 |
| 1 | 1 | 1 | 8µs | 18µs | Graph::Attribute::BEGIN@49 |
| 2 | 1 | 1 | 8µs | 8µs | Graph::Attribute::__ANON__[:15] |
| 0 | 0 | 0 | 0s | 0s | Graph::Attribute::__ANON__[:20] |
| 0 | 0 | 0 | 0s | 0s | Graph::Attribute::__ANON__[:21] |
| 0 | 0 | 0 | 0s | 0s | Graph::Attribute::__ANON__[:25] |
| 0 | 0 | 0 | 0s | 0s | Graph::Attribute::__ANON__[:29] |
| 0 | 0 | 0 | 0s | 0s | Graph::Attribute::__ANON__[:30] |
| 0 | 0 | 0 | 0s | 0s | Graph::Attribute::__ANON__[:31] |
| 0 | 0 | 0 | 0s | 0s | Graph::Attribute::delete_attribute |
| 0 | 0 | 0 | 0s | 0s | Graph::Attribute::delete_attributes |
| 0 | 0 | 0 | 0s | 0s | Graph::Attribute::get_attribute_names |
| 0 | 0 | 0 | 0s | 0s | Graph::Attribute::get_attribute_values |
| 0 | 0 | 0 | 0s | 0s | Graph::Attribute::get_attributes |
| 0 | 0 | 0 | 0s | 0s | Graph::Attribute::has_attribute |
| 0 | 0 | 0 | 0s | 0s | Graph::Attribute::has_attributes |
| 0 | 0 | 0 | 0s | 0s | Graph::Attribute::set_attributes |
| 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 | 33 | 112µs | my $package = shift; | ||
| 10 | my %attr = @_; | ||||
| 11 | my $caller = caller(0); | ||||
| 12 | if (exists $attr{array}) { | ||||
| 13 | 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 | 2 | 20µ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 | 6 | 24µ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 | $_[0]->[ $i ] = $_[1] if @_ == 2; | ||||
| 19 | $_[0]->[ $i ] }; | ||||
| 20 | *{"${caller}::_has_attributes"} = sub { defined $_[0]->[ $i ] }; | ||||
| 21 | *{"${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 | 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 | if (exists $attr{map}) { | ||||
| 46 | my $map = $attr{map}; | ||||
| 47 | for my $api (@api) { | ||||
| 48 | 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 | *{"${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 | 12 | 26µs | my $g = shift; | ||
| 57 | my $v = pop; | ||||
| 58 | my $a = pop; | ||||
| 59 | 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 | $p->{ $a } = $v; | ||||
| 61 | 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 | 8 | 32µs | my $g = shift; | ||
| 85 | my $a = pop; | ||||
| 86 | 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 | $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 |