File | /usr/local/lib/perl5/site_perl/5.10.1/MooseX/AttributeHelpers/MethodProvider/ImmutableHash.pm |
Statements Executed | 18 |
Statement Execution Time | 521µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
2 | 1 | 1 | 24µs | 38µs | get | MooseX::AttributeHelpers::MethodProvider::ImmutableHash::
2 | 1 | 1 | 21µs | 34µs | exists | MooseX::AttributeHelpers::MethodProvider::ImmutableHash::
1 | 1 | 1 | 14µs | 1.41ms | BEGIN@2 | MooseX::AttributeHelpers::MethodProvider::ImmutableHash::
1 | 1 | 1 | 13µs | 23µs | keys | MooseX::AttributeHelpers::MethodProvider::ImmutableHash::
0 | 0 | 0 | 0s | 0s | __ANON__[:10] | MooseX::AttributeHelpers::MethodProvider::ImmutableHash::
0 | 0 | 0 | 0s | 0s | __ANON__[:15] | MooseX::AttributeHelpers::MethodProvider::ImmutableHash::
0 | 0 | 0 | 0s | 0s | __ANON__[:27] | MooseX::AttributeHelpers::MethodProvider::ImmutableHash::
0 | 0 | 0 | 0s | 0s | __ANON__[:32] | MooseX::AttributeHelpers::MethodProvider::ImmutableHash::
0 | 0 | 0 | 0s | 0s | __ANON__[:37] | MooseX::AttributeHelpers::MethodProvider::ImmutableHash::
0 | 0 | 0 | 0s | 0s | __ANON__[:47] | MooseX::AttributeHelpers::MethodProvider::ImmutableHash::
0 | 0 | 0 | 0s | 0s | __ANON__[:57] | MooseX::AttributeHelpers::MethodProvider::ImmutableHash::
0 | 0 | 0 | 0s | 0s | __ANON__[:62] | MooseX::AttributeHelpers::MethodProvider::ImmutableHash::
0 | 0 | 0 | 0s | 0s | __ANON__[:67] | MooseX::AttributeHelpers::MethodProvider::ImmutableHash::
0 | 0 | 0 | 0s | 0s | count | MooseX::AttributeHelpers::MethodProvider::ImmutableHash::
0 | 0 | 0 | 0s | 0s | defined | MooseX::AttributeHelpers::MethodProvider::ImmutableHash::
0 | 0 | 0 | 0s | 0s | elements | MooseX::AttributeHelpers::MethodProvider::ImmutableHash::
0 | 0 | 0 | 0s | 0s | empty | MooseX::AttributeHelpers::MethodProvider::ImmutableHash::
0 | 0 | 0 | 0s | 0s | kv | MooseX::AttributeHelpers::MethodProvider::ImmutableHash::
0 | 0 | 0 | 0s | 0s | values | MooseX::AttributeHelpers::MethodProvider::ImmutableHash::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package MooseX::AttributeHelpers::MethodProvider::ImmutableHash; | ||||
2 | 3 | 444µs | 2 | 2.81ms | # spent 1.41ms (14µs+1.40) within MooseX::AttributeHelpers::MethodProvider::ImmutableHash::BEGIN@2 which was called
# once (14µs+1.40ms) by Class::MOP::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Class/MOP.pm:103] at line 2 # spent 1.41ms making 1 call to MooseX::AttributeHelpers::MethodProvider::ImmutableHash::BEGIN@2
# spent 1.40ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:389] |
3 | |||||
4 | 1 | 600ns | our $VERSION = '0.23'; | ||
5 | 1 | 14µs | $VERSION = eval $VERSION; | ||
6 | 1 | 300ns | our $AUTHORITY = 'cpan:STEVAN'; | ||
7 | |||||
8 | # spent 34µs (21+13) within MooseX::AttributeHelpers::MethodProvider::ImmutableHash::exists which was called 2 times, avg 17µs/call:
# 2 times (21µs+13µs) by Class::MOP::Class:::after at line 181 of MooseX/AttributeHelpers/Trait/Base.pm, avg 17µs/call | ||||
9 | 4 | 13µs | my ($attr, $reader, $writer) = @_; | ||
10 | 1 | 16µs | 3 | 48µs | return sub { CORE::exists $reader->($_[0])->{$_[1]} ? 1 : 0 }; # spent 33µs making 1 call to Class::MOP::Class::__ANON__::SERIAL::1::get_class_attribute_map
# spent 15µs making 2 calls to Class::MOP::Method::__ANON__[Class/MOP/Method.pm:19], avg 8µs/call |
11 | } | ||||
12 | |||||
13 | sub defined : method { | ||||
14 | my ($attr, $reader, $writer) = @_; | ||||
15 | return sub { CORE::defined $reader->($_[0])->{$_[1]} ? 1 : 0 }; | ||||
16 | } | ||||
17 | |||||
18 | # spent 38µs (24+14) within MooseX::AttributeHelpers::MethodProvider::ImmutableHash::get which was called 2 times, avg 19µs/call:
# 2 times (24µs+14µs) by Class::MOP::Class:::after at line 181 of MooseX/AttributeHelpers/Trait/Base.pm, avg 19µs/call | ||||
19 | 4 | 15µs | my ($attr, $reader, $writer) = @_; | ||
20 | return sub { | ||||
21 | if ( @_ == 2 ) { | ||||
22 | $reader->($_[0])->{$_[1]} | ||||
23 | } else { | ||||
24 | my ( $self, @keys ) = @_; | ||||
25 | @{ $reader->($self) }{@keys} | ||||
26 | } | ||||
27 | }; | ||||
28 | } | ||||
29 | |||||
30 | # spent 23µs (13+9) within MooseX::AttributeHelpers::MethodProvider::ImmutableHash::keys which was called
# once (13µs+9µs) by Class::MOP::Class:::after at line 181 of MooseX/AttributeHelpers/Trait/Base.pm | ||||
31 | 2 | 8µs | my ($attr, $reader, $writer) = @_; | ||
32 | return sub { CORE::keys %{$reader->($_[0])} }; | ||||
33 | } | ||||
34 | |||||
35 | sub values : method { | ||||
36 | my ($attr, $reader, $writer) = @_; | ||||
37 | return sub { CORE::values %{$reader->($_[0])} }; | ||||
38 | } | ||||
39 | |||||
40 | sub kv : method { | ||||
41 | my ($attr, $reader, $writer) = @_; | ||||
42 | return sub { | ||||
43 | my $h = $reader->($_[0]); | ||||
44 | map { | ||||
45 | [ $_, $h->{$_} ] | ||||
46 | } CORE::keys %{$h} | ||||
47 | }; | ||||
48 | } | ||||
49 | |||||
50 | sub elements : method { | ||||
51 | my ($attr, $reader, $writer) = @_; | ||||
52 | return sub { | ||||
53 | my $h = $reader->($_[0]); | ||||
54 | map { | ||||
55 | $_, $h->{$_} | ||||
56 | } CORE::keys %{$h} | ||||
57 | }; | ||||
58 | } | ||||
59 | |||||
60 | sub count : method { | ||||
61 | my ($attr, $reader, $writer) = @_; | ||||
62 | return sub { scalar CORE::keys %{$reader->($_[0])} }; | ||||
63 | } | ||||
64 | |||||
65 | sub empty : method { | ||||
66 | my ($attr, $reader, $writer) = @_; | ||||
67 | return sub { scalar CORE::keys %{$reader->($_[0])} ? 1 : 0 }; | ||||
68 | } | ||||
69 | |||||
70 | 1 | 10µs | 1; | ||
71 | |||||
72 | __END__ | ||||
73 | |||||
74 | =pod | ||||
75 | |||||
76 | =head1 NAME | ||||
77 | |||||
78 | MooseX::AttributeHelpers::MethodProvider::ImmutableHash | ||||
79 | |||||
80 | =head1 DESCRIPTION | ||||
81 | |||||
82 | This is a role which provides the method generators for | ||||
83 | L<MooseX::AttributeHelpers::Collection::ImmutableHash>. | ||||
84 | |||||
85 | =head1 METHODS | ||||
86 | |||||
87 | =over 4 | ||||
88 | |||||
89 | =item B<meta> | ||||
90 | |||||
91 | =back | ||||
92 | |||||
93 | =head1 PROVIDED METHODS | ||||
94 | |||||
95 | =over 4 | ||||
96 | |||||
97 | =item B<count> | ||||
98 | |||||
99 | Returns the number of elements in the list. | ||||
100 | |||||
101 | =item B<empty> | ||||
102 | |||||
103 | If the list is populated, returns true. Otherwise, returns false. | ||||
104 | |||||
105 | =item B<exists> | ||||
106 | |||||
107 | Returns true if the given key is present in the hash | ||||
108 | |||||
109 | =item B<defined> | ||||
110 | |||||
111 | Returns true if the value of a given key is defined | ||||
112 | |||||
113 | =item B<get> | ||||
114 | |||||
115 | Returns an element of the hash by its key. | ||||
116 | |||||
117 | =item B<keys> | ||||
118 | |||||
119 | Returns the list of keys in the hash. | ||||
120 | |||||
121 | =item B<values> | ||||
122 | |||||
123 | Returns the list of values in the hash. | ||||
124 | |||||
125 | =item B<kv> | ||||
126 | |||||
127 | Returns the key, value pairs in the hash as array references | ||||
128 | |||||
129 | =item B<elements> | ||||
130 | |||||
131 | Returns the key, value pairs in the hash as a flattened list | ||||
132 | |||||
133 | =back | ||||
134 | |||||
135 | =head1 BUGS | ||||
136 | |||||
137 | All complex software has bugs lurking in it, and this module is no | ||||
138 | exception. If you find a bug please either email me, or add the bug | ||||
139 | to cpan-RT. | ||||
140 | |||||
141 | =head1 AUTHOR | ||||
142 | |||||
143 | Stevan Little E<lt>stevan@iinteractive.comE<gt> | ||||
144 | |||||
145 | =head1 COPYRIGHT AND LICENSE | ||||
146 | |||||
147 | Copyright 2007-2009 by Infinity Interactive, Inc. | ||||
148 | |||||
149 | L<http://www.iinteractive.com> | ||||
150 | |||||
151 | This library is free software; you can redistribute it and/or modify | ||||
152 | it under the same terms as Perl itself. | ||||
153 | |||||
154 | =cut | ||||
155 |