File | /data/SimpleDB-Class/author.t/../lib/SimpleDB/Class/Item.pm |
Statements Executed | 2114 |
Statement Execution Time | 7.52ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 2.62ms | 11.2ms | BEGIN@18 | SimpleDB::Class::Item::
12 | 2 | 2 | 2.14ms | 4.18s | put | SimpleDB::Class::Item::
79 | 1 | 1 | 1.66ms | 17.7ms | stringify_values | SimpleDB::Class::Item::
18 | 4 | 4 | 809µs | 6.33ms | to_hashref | SimpleDB::Class::Item::
22 | 3 | 1 | 456µs | 4.37ms | stringify_value | SimpleDB::Class::Item::
89 | 2 | 2 | 451µs | 963µs | CORE:match (opcode) | SimpleDB::Class::Item::
4 | 4 | 4 | 345µs | 17.0ms | add_attributes | SimpleDB::Class::Item::
4 | 2 | 1 | 109µs | 11.2ms | parse_value | SimpleDB::Class::Item::
1 | 1 | 1 | 84µs | 320ms | copy | SimpleDB::Class::Item::
32 | 1 | 1 | 83µs | 83µs | _castor_attribute | SimpleDB::Class::Item::
2 | 2 | 2 | 60µs | 4.04ms | belongs_to | SimpleDB::Class::Item::
3 | 3 | 3 | 54µs | 92µs | set_domain_name | SimpleDB::Class::Item::
10 | 4 | 1 | 52µs | 68µs | _install_sub | SimpleDB::Class::Item::
9 | 1 | 1 | 44µs | 1.63ms | generate_uuid | SimpleDB::Class::Item::
1 | 1 | 1 | 39µs | 500µs | update | SimpleDB::Class::Item::
5 | 1 | 1 | 38µs | 2.91ms | __ANON__[../lib/SimpleDB/Class/Item.pm:87] | SimpleDB::Class::Item::
2 | 2 | 2 | 32µs | 42µs | has_many | SimpleDB::Class::Item::
1 | 1 | 1 | 31µs | 1.29ms | __ANON__[../lib/SimpleDB/Class/Item.pm:280] | SimpleDB::Class::Item::
1 | 1 | 1 | 29µs | 2.16ms | BEGIN@17 | SimpleDB::Class::Item::
8 | 1 | 1 | 22µs | 22µs | __ANON__[../lib/SimpleDB/Class/Item.pm:90] | SimpleDB::Class::Item::
1 | 1 | 1 | 19µs | 3.60ms | BEGIN@19 | SimpleDB::Class::Item::
4 | 1 | 1 | 11µs | 11µs | __ANON__[../lib/SimpleDB/Class/Item.pm:92] | SimpleDB::Class::Item::
1 | 1 | 1 | 9µs | 15µs | recast_using | SimpleDB::Class::Item::
1 | 1 | 1 | 8µs | 26µs | BEGIN@25 | SimpleDB::Class::Item::
3 | 1 | 1 | 6µs | 6µs | attributes | SimpleDB::Class::Item::
1 | 1 | 1 | 5µs | 5µs | BEGIN@20 | SimpleDB::Class::Item::
0 | 0 | 0 | 0s | 0s | __ANON__[../lib/SimpleDB/Class/Item.pm:113] | SimpleDB::Class::Item::
0 | 0 | 0 | 0s | 0s | __ANON__[../lib/SimpleDB/Class/Item.pm:208] | SimpleDB::Class::Item::
0 | 0 | 0 | 0s | 0s | __ANON__[../lib/SimpleDB/Class/Item.pm:289] | SimpleDB::Class::Item::
0 | 0 | 0 | 0s | 0s | __ANON__[../lib/SimpleDB/Class/Item.pm:316] | SimpleDB::Class::Item::
0 | 0 | 0 | 0s | 0s | __ANON__[../lib/SimpleDB/Class/Item.pm:48] | SimpleDB::Class::Item::
0 | 0 | 0 | 0s | 0s | __ANON__[../lib/SimpleDB/Class/Item.pm:89] | SimpleDB::Class::Item::
0 | 0 | 0 | 0s | 0s | __ANON__[../lib/SimpleDB/Class/Item.pm:91] | SimpleDB::Class::Item::
0 | 0 | 0 | 0s | 0s | delete | SimpleDB::Class::Item::
0 | 0 | 0 | 0s | 0s | delete_attribute | SimpleDB::Class::Item::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package SimpleDB::Class::Item; | ||||
2 | |||||
3 | =head1 NAME | ||||
4 | |||||
5 | SimpleDB::Class::Item - An object representation from an item in a SimpleDB domain. | ||||
6 | |||||
7 | =head1 DESCRIPTION | ||||
8 | |||||
9 | An object representation from an item in a SimpleDB domain. | ||||
10 | |||||
11 | =head1 METHODS | ||||
12 | |||||
13 | The following methods are available from this class. | ||||
14 | |||||
15 | =cut | ||||
16 | |||||
17 | 3 | 31µs | 2 | 4.30ms | # spent 2.16ms (29µs+2.14) within SimpleDB::Class::Item::BEGIN@17 which was called
# once (29µs+2.14ms) by Class::MOP::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Class/MOP.pm:103] at line 17 # spent 2.16ms making 1 call to SimpleDB::Class::Item::BEGIN@17
# spent 2.14ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:389] |
18 | 3 | 130µs | 2 | 11.3ms | # spent 11.2ms (2.62+8.59) within SimpleDB::Class::Item::BEGIN@18 which was called
# once (2.62ms+8.59ms) by Class::MOP::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Class/MOP.pm:103] at line 18 # spent 11.2ms making 1 call to SimpleDB::Class::Item::BEGIN@18
# spent 96µs making 1 call to Exporter::import |
19 | 3 | 72µs | 2 | 7.17ms | # spent 3.60ms (19µs+3.58) within SimpleDB::Class::Item::BEGIN@19 which was called
# once (19µs+3.58ms) by Class::MOP::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Class/MOP.pm:103] at line 19 # spent 3.60ms making 1 call to SimpleDB::Class::Item::BEGIN@19
# spent 3.58ms making 1 call to MooseX::Types::Base::import |
20 | 3 | 36µs | 1 | 5µs | # spent 5µs within SimpleDB::Class::Item::BEGIN@20 which was called
# once (5µs+0s) by Class::MOP::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Class/MOP.pm:103] at line 20 # spent 5µs making 1 call to SimpleDB::Class::Item::BEGIN@20 |
21 | |||||
22 | #-------------------------------------------------------- | ||||
23 | # spent 68µs (52+17) within SimpleDB::Class::Item::_install_sub which was called 10 times, avg 7µs/call:
# 4 times (23µs+7µs) by SimpleDB::Class::Item::add_attributes at line 113, avg 7µs/call
# 3 times (17µs+5µs) by SimpleDB::Class::Item::set_domain_name at line 48, avg 7µs/call
# 2 times (8µs+3µs) by SimpleDB::Class::Item::has_many at line 208, avg 5µs/call
# once (5µs+2µs) by SimpleDB::Class::Item::recast_using at line 316 | ||||
24 | 20 | 79µs | my ($name, $sub) = @_; | ||
25 | 3 | 1.34ms | 2 | 45µs | # spent 26µs (8+18) within SimpleDB::Class::Item::BEGIN@25 which was called
# once (8µs+18µs) by Class::MOP::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Class/MOP.pm:103] at line 25 # spent 26µs making 1 call to SimpleDB::Class::Item::BEGIN@25
# spent 18µs making 1 call to strict::unimport |
26 | *{$name} = Sub::Name::subname($name, $sub); # spent 16µs making 10 calls to Sub::Name::subname, avg 2µs/call | ||||
27 | } | ||||
28 | |||||
29 | #-------------------------------------------------------- | ||||
30 | |||||
31 | =head2 set_domain_name ( name ) | ||||
32 | |||||
33 | Class method. Used to set the SimpleDB domain name associated with a sublcass. | ||||
34 | |||||
35 | =head3 name | ||||
36 | |||||
37 | The domain name to set. | ||||
38 | |||||
39 | =head2 domain_name ( ) | ||||
40 | |||||
41 | Class method. After set_domain_name() has been called, there will be a domain_name method, that will return the value of the domain name. | ||||
42 | |||||
43 | =cut | ||||
44 | |||||
45 | # spent 92µs (54+38) within SimpleDB::Class::Item::set_domain_name which was called 3 times, avg 31µs/call:
# once (18µs+14µs) by Module::Find::useall at line 6 of lib/Foo/Child.pm
# once (18µs+12µs) by Module::Find::useall at line 6 of lib/Foo/Domain.pm
# once (18µs+12µs) by Module::Find::useall at line 6 of lib/Foo/Parent.pm | ||||
46 | 15 | 43µs | my ($class, $name) = @_; | ||
47 | # inject domain_name sub | ||||
48 | 56 | 214µs | 3 | 22µs | _install_sub($class.'::domain_name', sub { return $name }); # spent 22µs making 3 calls to SimpleDB::Class::Item::_install_sub, avg 7µs/call |
49 | # register the name and class with the schema | ||||
50 | my $names = SimpleDB::Class->domain_names; # spent 11µs making 3 calls to SimpleDB::Class::domain_names, avg 4µs/call | ||||
51 | $names->{$name} = $class; | ||||
52 | SimpleDB::Class->domain_names($names); # spent 5µs making 3 calls to SimpleDB::Class::domain_names, avg 2µs/call | ||||
53 | } | ||||
54 | |||||
55 | #-------------------------------------------------------- | ||||
56 | |||||
57 | =head2 add_attributes ( list ) | ||||
58 | |||||
59 | Class method. Adds more attributes to this class. B<NOTE:> This will add a method to your class which can be used as an accessor/mutator. Therefore make sure to avoid method name conflicts with this class. | ||||
60 | |||||
61 | =head3 list | ||||
62 | |||||
63 | A hashref that holds a list of attributes and their properties (a hashref itself). Example: title => { isa => 'Str', default => 'Untitled' } | ||||
64 | |||||
65 | =head4 attribute | ||||
66 | |||||
67 | The attribute name is key in the hashref. | ||||
68 | |||||
69 | =head4 isa | ||||
70 | |||||
71 | The type of data represented by this attribute. See L<SimpleDB::Class::Types> for the available types. | ||||
72 | |||||
73 | =head4 default | ||||
74 | |||||
75 | The default value for this attribute. This should be specified even if it is 'None' or 'Undefined' or 'Null', because actuall null queries are slow in SimpleDB. | ||||
76 | |||||
77 | =head4 trigger | ||||
78 | |||||
79 | A sub reference that will be called like a method (has reference to $self), and is also passed the new and old values of this attribute. Behind the scenes is a L<Moose> trigger. See also L<Moose::Manual::Attributes/"Triggers">. | ||||
80 | |||||
81 | =cut | ||||
82 | |||||
83 | # spent 17.0ms (345µs+16.7) within SimpleDB::Class::Item::add_attributes which was called 4 times, avg 4.25ms/call:
# once (152µs+11.2ms) by Module::Find::useall at line 15 of lib/Foo/Domain.pm
# once (81µs+2.75ms) by Module::Find::useall at line 7 of lib/Foo/Child.pm
# once (62µs+1.40ms) by Module::Find::useall at line 7 of lib/Foo/Parent.pm
# once (50µs+1.33ms) by Module::Find::useall at line 6 of lib/Foo/SubChild.pm | ||||
84 | 98 | 299µs | my ($class, %attributes) = @_; | ||
85 | my %defaults = ( | ||||
86 | Str => '', | ||||
87 | 5 | 38µs | 5 | 2.87ms | # spent 2.91ms (38µs+2.87) within SimpleDB::Class::Item::__ANON__[../lib/SimpleDB/Class/Item.pm:87] which was called 5 times, avg 582µs/call:
# 5 times (38µs+2.87ms) by Class::MOP::Mixin::AttributeCore::default at line 53 of Class/MOP/Mixin/AttributeCore.pm, avg 582µs/call # spent 2.87ms making 5 calls to DateTime::now, avg 575µs/call |
88 | Int => 0, | ||||
89 | ArrayRefOfInt => sub { [] }, | ||||
90 | 8 | 25µs | # spent 22µs within SimpleDB::Class::Item::__ANON__[../lib/SimpleDB/Class/Item.pm:90] which was called 8 times, avg 3µs/call:
# 8 times (22µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 53 of Class/MOP/Mixin/AttributeCore.pm, avg 3µs/call | ||
91 | ArrayRefOfDateTime => sub { [] }, | ||||
92 | 4 | 12µs | # spent 11µs within SimpleDB::Class::Item::__ANON__[../lib/SimpleDB/Class/Item.pm:92] which was called 4 times, avg 3µs/call:
# 4 times (11µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 53 of Class/MOP/Mixin/AttributeCore.pm, avg 3µs/call | ||
93 | MediumStr => '', | ||||
94 | ); | ||||
95 | foreach my $name (keys %attributes) { | ||||
96 | my $type = $attributes{$name}{isa} || 'Str'; | ||||
97 | my $isa = 'SimpleDB::Class::Types::Sdb'.$type; | ||||
98 | my %properties = ( | ||||
99 | is => 'rw', | ||||
100 | isa => $isa, | ||||
101 | coerce => 1, | ||||
102 | default => $attributes{$name}{default} || $defaults{$type}, | ||||
103 | ); | ||||
104 | if ($type ne 'Str') { # don't do any work we don't have to | ||||
105 | $properties{lazy} = 1; | ||||
106 | } | ||||
107 | if (defined $attributes{$name}{trigger}) { | ||||
108 | $properties{trigger} = $attributes{$name}{trigger}; | ||||
109 | } | ||||
110 | $class->meta->add_attribute($name, \%properties); # spent 16.5ms making 13 calls to Moose::Meta::Class::add_attribute, avg 1.27ms/call
# spent 77µs making 9 calls to Foo::Domain::meta, avg 9µs/call
# spent 24µs making 2 calls to Foo::Child::meta, avg 12µs/call
# spent 10µs making 1 call to Foo::Parent::meta
# spent 9µs making 1 call to Foo::SubChild::meta | ||||
111 | } | ||||
112 | my %new = (%{$class->attributes}, %attributes); # spent 6µs making 3 calls to SimpleDB::Class::Item::attributes, avg 2µs/call
# spent 2µs making 1 call to Foo::Child::attributes | ||||
113 | 21 | 79µs | 4 | 29µs | _install_sub($class.'::attributes', sub { return \%new; }); # spent 29µs making 4 calls to SimpleDB::Class::Item::_install_sub, avg 7µs/call |
114 | } | ||||
115 | |||||
116 | |||||
117 | #-------------------------------------------------------- | ||||
118 | |||||
119 | =head2 has_many ( method, class, attribute ) | ||||
120 | |||||
121 | Class method. Sets up a 1:N relationship between this class and a child class. | ||||
122 | |||||
123 | WARNING: With this method you need to be aware that SimpleDB is eventually consistent. See L<SimpleDB::Class/"Eventual Consistency"> for details. | ||||
124 | |||||
125 | =head3 method | ||||
126 | |||||
127 | The name of the method in this class you wish to use to access the relationship with the child class. | ||||
128 | |||||
129 | =head3 class | ||||
130 | |||||
131 | The class name of the class you're creating the child relationship with. | ||||
132 | |||||
133 | =head3 attribute | ||||
134 | |||||
135 | The attribute in the child class that represents this class' id. | ||||
136 | |||||
137 | =head3 options | ||||
138 | |||||
139 | A hash containing options that will modify the method created. | ||||
140 | |||||
141 | =head4 mate | ||||
142 | |||||
143 | The name of the attribute that will be created in C<class> to refer back to this object. If specified, a reference to this object will be set in C<class> when it is instantiated to avoid stale references. | ||||
144 | |||||
145 | =head4 consistent | ||||
146 | |||||
147 | A boolean which can enable SimpleDB's ConsistentRead option. Defaults to 0. | ||||
148 | |||||
149 | =head2 I<has_many_generated_method> ( [ options ] ) | ||||
150 | |||||
151 | This is the documentation for the method generated by C<has_many>. It returns a L<SimpleDB::Class::ResultSet> object with a list of the related children to this class. | ||||
152 | |||||
153 | =head3 options | ||||
154 | |||||
155 | A hash of options to modify the result set at run time. | ||||
156 | |||||
157 | =head4 where | ||||
158 | |||||
159 | A where clause as defined by L<SimpleDB::Class::SQL>. This new clause will automatically be added to the relationship clause, so whatever you specify here is only to further limit the results returned. | ||||
160 | |||||
161 | =head4 order_by | ||||
162 | |||||
163 | An order_by clause as defined by L<SimpleDB::Class::SQL>. By default no order is specified. | ||||
164 | |||||
165 | =head4 limit | ||||
166 | |||||
167 | A limit clause as defined by L<SimpleDB::Class::SQL>. By default all items in the relationship will be returned. | ||||
168 | |||||
169 | =head4 consistent | ||||
170 | |||||
171 | A boolean that can enable SimpleDB's ConsistentRead option. Setting this will override whatever was set in C<has_many>, if anything. | ||||
172 | |||||
173 | =head4 set | ||||
174 | |||||
175 | A hash reference of attribute names and values that will be applied to each object returned from the result set. The C<mate> option in C<has_many> can already set one of these. | ||||
176 | |||||
177 | =cut | ||||
178 | |||||
179 | # spent 42µs (32+11) within SimpleDB::Class::Item::has_many which was called 2 times, avg 21µs/call:
# once (19µs+5µs) by Module::Find::useall at line 8 of lib/Foo/Parent.pm
# once (13µs+5µs) by Module::Find::useall at line 23 of lib/Foo/Domain.pm | ||||
180 | 4 | 31µs | my ($class, $name, $classname, $attribute, %options) = @_; | ||
181 | _install_sub($class.'::'.$name, sub { | ||||
182 | 30 | 101µs | my ($self, %sub_options) = @_; | ||
183 | my %search_options = ( # spent 17µs making 3 calls to SimpleDB::Class::Item::id, avg 6µs/call | ||||
184 | where => {$attribute => $self->id}, | ||||
185 | ); | ||||
186 | if (exists $sub_options{where}) { | ||||
187 | $search_options{where}{'-and'} = $sub_options{where}; | ||||
188 | } | ||||
189 | if ($sub_options{order_by}) { | ||||
190 | $search_options{order_by} = $sub_options{order_by}; | ||||
191 | } | ||||
192 | if ($sub_options{limit}) { | ||||
193 | $search_options{limit} = $sub_options{limit}; | ||||
194 | } | ||||
195 | if (exists $sub_options{set}) { | ||||
196 | $search_options{set} = $sub_options{set}; | ||||
197 | } | ||||
198 | if ($options{mate}) { | ||||
199 | $search_options{set}{$options{mate}} = $self; | ||||
200 | } | ||||
201 | if (exists $options{consistent}) { | ||||
202 | $search_options{consistent} = $options{consistent}; | ||||
203 | } | ||||
204 | if (exists $sub_options{consistent}) { | ||||
205 | $search_options{consistent} = $sub_options{consistent}; | ||||
206 | } | ||||
207 | return $self->simpledb->domain($classname)->search(%search_options); # spent 426µs making 3 calls to SimpleDB::Class::Domain::search, avg 142µs/call
# spent 246µs making 3 calls to SimpleDB::Class::domain, avg 82µs/call
# spent 11µs making 3 calls to SimpleDB::Class::Item::simpledb, avg 4µs/call | ||||
208 | }); # spent 11µs making 2 calls to SimpleDB::Class::Item::_install_sub, avg 5µs/call | ||||
209 | } | ||||
210 | |||||
211 | #-------------------------------------------------------- | ||||
212 | |||||
213 | =head2 belongs_to ( method, class, attribute ) | ||||
214 | |||||
215 | Class method. Adds a 1:N relationship between another class and this one. | ||||
216 | |||||
217 | =head3 method | ||||
218 | |||||
219 | The method name to create to represent this relationship in this class. | ||||
220 | |||||
221 | =head3 class | ||||
222 | |||||
223 | The class name of the parent class you're relating this class to. | ||||
224 | |||||
225 | =head3 attribute | ||||
226 | |||||
227 | The attribute in this class' attribute list that represents the id of the parent class. | ||||
228 | |||||
229 | =head3 options | ||||
230 | |||||
231 | A hash of options to modify the created method. | ||||
232 | |||||
233 | =head4 mate | ||||
234 | |||||
235 | The name of the attribute that will be created in C<class> to refer back to this object. If specified, a reference to this object will be set in C<class> when it is instantiated to avoid stale references. This would only be useful in the case of a 1:1 relationship. | ||||
236 | |||||
237 | =head4 consistent | ||||
238 | |||||
239 | A boolean indicating whether to enable the SimpleDB's ConsistentRead option. | ||||
240 | |||||
241 | =head2 I<belongs_to_generated_method> ( [ item ] ) | ||||
242 | |||||
243 | This is the documentation for the method that C<belongs_to> generates. This method caches the item it retrieves for faster future retrievals. | ||||
244 | |||||
245 | B<NOTE:> Will return C<undef> if the attribute specified has no value at the time it is called. | ||||
246 | |||||
247 | =head3 item | ||||
248 | |||||
249 | You can optionally precache the item that this method would produce, if you already have it by passing it to the method here. If you choose to use this option, make sure what you're setting here actually matches the id attribute that would normally be used to find the item in question. | ||||
250 | |||||
251 | =head2 has_I<belongs_to_generated_method> | ||||
252 | |||||
253 | Returns a boolean indicating whether the generated method is storing a cached result. | ||||
254 | |||||
255 | =head2 clear_I<belongs_to_generated_method> | ||||
256 | |||||
257 | Clears the cached result stored by the generated method. This method will be automatically called if a new value is set for the attribute. | ||||
258 | |||||
259 | =cut | ||||
260 | |||||
261 | # spent 4.04ms (60µs+3.98) within SimpleDB::Class::Item::belongs_to which was called 2 times, avg 2.02ms/call:
# once (33µs+2.11ms) by Module::Find::useall at line 11 of lib/Foo/Child.pm
# once (27µs+1.87ms) by Module::Find::useall at line 24 of lib/Foo/Domain.pm | ||||
262 | 10 | 49µs | my ($class, $name, $classname, $attribute, %options) = @_; | ||
263 | my $clearer = 'clear_'.$name; | ||||
264 | my $predicate = 'has_'.$name; | ||||
265 | $class->meta->add_attribute($name, { | ||||
266 | is => 'rw', | ||||
267 | lazy => 1, | ||||
268 | # spent 1.29ms (31µs+1.26) within SimpleDB::Class::Item::__ANON__[../lib/SimpleDB/Class/Item.pm:280] which was called
# once (31µs+1.26ms) by Class::MOP::Mixin::AttributeCore::default at line 53 of Class/MOP/Mixin/AttributeCore.pm | ||||
269 | 7 | 23µs | my $self = shift; | ||
270 | my $id = $self->$attribute; # spent 18µs making 1 call to Foo::Domain::parentId | ||||
271 | return undef unless ($id ne ''); | ||||
272 | my %find_options; | ||||
273 | if ($options{mate}) { | ||||
274 | $find_options{set} = { $options{mate} => $self }; | ||||
275 | } | ||||
276 | if (exists $options{consistent}) { | ||||
277 | $find_options{consistent} = $options{consistent}; | ||||
278 | } | ||||
279 | return $self->simpledb->domain($classname)->find($id, %find_options); # spent 1.14ms making 1 call to SimpleDB::Class::Domain::find
# spent 94µs making 1 call to SimpleDB::Class::domain
# spent 4µs making 1 call to SimpleDB::Class::Item::simpledb | ||||
280 | }, | ||||
281 | predicate => $predicate, # spent 3.47ms making 2 calls to Moose::Meta::Class::add_attribute, avg 1.73ms/call
# spent 8µs making 1 call to Foo::Child::meta
# spent 8µs making 1 call to Foo::Domain::meta | ||||
282 | clearer => $clearer, | ||||
283 | }); | ||||
284 | $class->meta->add_after_method_modifier($attribute, sub { | ||||
285 | 62 | 140µs | my ($self, $value) = @_; | ||
286 | if (defined $value) { # spent 7µs making 2 calls to Foo::Domain::clear_parent, avg 3µs/call | ||||
287 | $self->$clearer; | ||||
288 | } | ||||
289 | }); # spent 482µs making 2 calls to Class::MOP::Class::add_after_method_modifier, avg 241µs/call
# spent 8µs making 1 call to Foo::Child::meta
# spent 8µs making 1 call to Foo::Domain::meta | ||||
290 | } | ||||
291 | |||||
292 | #-------------------------------------------------------- | ||||
293 | |||||
294 | =head2 attributes ( ) | ||||
295 | |||||
296 | Class method. Returns the hashref of attributes set by the add_attributes() method. | ||||
297 | |||||
298 | =cut | ||||
299 | 3 | 10µs | # spent 6µs within SimpleDB::Class::Item::attributes which was called 3 times, avg 2µs/call:
# 3 times (6µs+0s) by SimpleDB::Class::Item::add_attributes at line 112, avg 2µs/call | ||
300 | |||||
301 | |||||
302 | #-------------------------------------------------------- | ||||
303 | |||||
304 | =head2 recast_using ( attribute_name ) | ||||
305 | |||||
306 | Class method. Sets an attribue name to use to recast this object as another class. This allows you to pull multiple object types from the same domain. If the attribute is defined when reading the information from SimpleDB, the object will be cast as the classname returned, rather than the classname associated with the domain. The new class must be a subclass of the class associated with the domain, because you cannot C<set_domain_name> for the same domain twice, or you will break SimpleDB::Class. | ||||
307 | |||||
308 | =head3 attribute_name | ||||
309 | |||||
310 | The name of an attribute defined by C<add_attributes>. | ||||
311 | |||||
312 | =cut | ||||
313 | |||||
314 | # spent 15µs (9+6) within SimpleDB::Class::Item::recast_using which was called
# once (9µs+6µs) by Module::Find::useall at line 12 of lib/Foo/Child.pm | ||||
315 | 2 | 8µs | my ($class, $attribute_name) = @_; | ||
316 | 3 | 17µs | 1 | 6µs | _install_sub($class.'::_castor_attribute', sub { return $attribute_name }); # spent 6µs making 1 call to SimpleDB::Class::Item::_install_sub |
317 | } | ||||
318 | |||||
319 | # spent 83µs within SimpleDB::Class::Item::_castor_attribute which was called 32 times, avg 3µs/call:
# 32 times (83µs+0s) by SimpleDB::Class::Role::Itemized::determine_item_class at line 70 of ../lib/SimpleDB/Class/Role/Itemized.pm, avg 3µs/call | ||||
320 | 32 | 103µs | return undef; | ||
321 | } | ||||
322 | |||||
323 | #-------------------------------------------------------- | ||||
324 | |||||
325 | =head2 update ( attributes ) | ||||
326 | |||||
327 | Update a bunch of attributes all at once. Returns a reference to L<$self> so it can be chained into other methods. | ||||
328 | |||||
329 | =head3 attributes | ||||
330 | |||||
331 | A hash reference containing attribute names and values. | ||||
332 | |||||
333 | =cut | ||||
334 | |||||
335 | # spent 500µs (39+461) within SimpleDB::Class::Item::update which was called
# once (39µs+461µs) by SimpleDB::Class::Item::copy at line 415 | ||||
336 | 13 | 23µs | my ($self, $attributes) = @_; | ||
337 | my $registered_attributes = $self->attributes; # spent 800ns making 1 call to Foo::Domain::attributes | ||||
338 | foreach my $attribute (keys %{$attributes}) { | ||||
339 | $self->$attribute($attributes->{$attribute}); # spent 92µs making 1 call to Foo::Domain::size
# spent 61µs making 1 call to Foo::Domain::parentId
# spent 56µs making 1 call to Foo::Domain::quantity
# spent 52µs making 1 call to Foo::Domain::components
# spent 45µs making 1 call to Foo::Domain::start_date
# spent 44µs making 1 call to Foo::Domain::notes
# spent 42µs making 1 call to Foo::Domain::color
# spent 37µs making 1 call to Foo::Domain::size_formatted
# spent 31µs making 1 call to Foo::Domain::properties | ||||
340 | } | ||||
341 | return $self; | ||||
342 | } | ||||
343 | |||||
344 | |||||
345 | #-------------------------------------------------------- | ||||
346 | |||||
347 | =head2 new ( params ) | ||||
348 | |||||
349 | Constructor. | ||||
350 | |||||
351 | =head3 params | ||||
352 | |||||
353 | A hash. | ||||
354 | |||||
355 | =head4 id | ||||
356 | |||||
357 | The unique identifier (ItemName) of the item represented by this class. If you don't pass this in, an item ID will be generated for you automatically. | ||||
358 | |||||
359 | =head4 simpledb | ||||
360 | |||||
361 | Required. A L<SimpleDB::Class> object. | ||||
362 | |||||
363 | =cut | ||||
364 | |||||
365 | #-------------------------------------------------------- | ||||
366 | |||||
367 | =head2 simpledb ( ) | ||||
368 | |||||
369 | Returns the simpledb passed into the constructor. | ||||
370 | |||||
371 | =cut | ||||
372 | |||||
373 | 1 | 3µs | 1 | 1.79ms | has simpledb => ( # spent 1.79ms making 1 call to Moose::has |
374 | is => 'ro', | ||||
375 | required => 1, | ||||
376 | ); | ||||
377 | |||||
378 | #-------------------------------------------------------- | ||||
379 | |||||
380 | =head2 id ( ) | ||||
381 | |||||
382 | Returns the unique id of this item. B<Note:> The primary key C<ItemName> (or C<id> as we call it) is a special property of an item that doesn't exist in it's own data. So if you want to search on the id, you have to use C<itemName()> in your queries as the attribute name. | ||||
383 | |||||
384 | =cut | ||||
385 | |||||
386 | 1 | 4µs | 2 | 1.44ms | has id => ( # spent 1.33ms making 1 call to Moose::has
# spent 112µs making 1 call to __TYPE__::SimpleDB::Class::Types::SdbStr |
387 | is => 'ro', | ||||
388 | isa => SdbStr, | ||||
389 | builder => 'generate_uuid', | ||||
390 | lazy => 1, | ||||
391 | ); | ||||
392 | |||||
393 | #-------------------------------------------------------- | ||||
394 | |||||
395 | =head2 copy ( [ id ] ) | ||||
396 | |||||
397 | Creates a duplicate of this object, inserts it into the database, and returns a reference to it. | ||||
398 | |||||
399 | =head3 id | ||||
400 | |||||
401 | If you want to assign a specific id to the copy, then you can do it with this parameter. | ||||
402 | |||||
403 | =cut | ||||
404 | |||||
405 | # spent 320ms (84µs+320) within SimpleDB::Class::Item::copy which was called
# once (84µs+320ms) by main::RUNTIME at line 65 of 05.Domain_and_Item.t | ||||
406 | 16 | 58µs | my ($self, $id) = @_; | ||
407 | my %properties; | ||||
408 | foreach my $name (keys %{$self->attributes}) { # spent 3µs making 1 call to Foo::Domain::attributes | ||||
409 | $properties{$name} = $self->$name; # spent 30µs making 1 call to Foo::Domain::parentId
# spent 5µs making 1 call to Foo::Domain::components
# spent 5µs making 1 call to Foo::Domain::notes
# spent 5µs making 1 call to Foo::Domain::start_date
# spent 4µs making 1 call to Foo::Domain::quantity
# spent 4µs making 1 call to Foo::Domain::properties
# spent 4µs making 1 call to Foo::Domain::color
# spent 2µs making 1 call to Foo::Domain::size_formatted
# spent 1µs making 1 call to Foo::Domain::size | ||||
410 | } | ||||
411 | my %params = (simpledb => $self->simpledb); # spent 4µs making 1 call to SimpleDB::Class::Item::simpledb | ||||
412 | if (defined $id) { | ||||
413 | $params{id} = $id; | ||||
414 | } | ||||
415 | my $new = $self->new(\%params)->update(\%properties)->put; # spent 318ms making 1 call to SimpleDB::Class::Item::put
# spent 814µs making 1 call to Moose::Object::new
# spent 500µs making 1 call to SimpleDB::Class::Item::update | ||||
416 | return $new; | ||||
417 | } | ||||
418 | |||||
419 | #-------------------------------------------------------- | ||||
420 | |||||
421 | =head2 delete | ||||
422 | |||||
423 | Removes this item from the database. | ||||
424 | |||||
425 | =cut | ||||
426 | |||||
427 | sub delete { | ||||
428 | my ($self) = @_; | ||||
429 | my $db = $self->simpledb; | ||||
430 | my $domain_name = $db->add_domain_prefix($self->domain_name); | ||||
431 | eval{$db->cache->delete($domain_name, $self->id)}; | ||||
432 | $db->http->send_request('DeleteAttributes', {ItemName => $self->id, DomainName=>$domain_name}); | ||||
433 | } | ||||
434 | |||||
435 | #-------------------------------------------------------- | ||||
436 | |||||
437 | =head2 delete_attribute | ||||
438 | |||||
439 | Removes a specific attribute from this item in the database. Great in conjunction with add_attribute(). | ||||
440 | |||||
441 | =cut | ||||
442 | |||||
443 | sub delete_attribute { | ||||
444 | my ($self, $name) = @_; | ||||
445 | my $attributes = $self->attributes; | ||||
446 | delete $attributes->{$name}; | ||||
447 | $self->attributes($attributes); | ||||
448 | my $db = $self->simpledb; | ||||
449 | my $domain_name = $db->add_domain_prefix($self->domain_name); | ||||
450 | eval{$db->cache->set($domain_name, $self->id, $attributes)}; | ||||
451 | $db->http->send_request('DeleteAttributes', { ItemName => $self->id, DomainName => $domain_name, 'Attribute.0.Name' => $name } ); | ||||
452 | } | ||||
453 | |||||
454 | #-------------------------------------------------------- | ||||
455 | |||||
456 | =head2 generate_uuid ( ) | ||||
457 | |||||
458 | Class method. Generates a unique UUID that can be used as a unique id for new items. | ||||
459 | |||||
460 | =cut | ||||
461 | |||||
462 | # spent 1.63ms (44µs+1.58) within SimpleDB::Class::Item::generate_uuid which was called 9 times, avg 181µs/call:
# 9 times (44µs+1.58ms) by SimpleDB::Class::Item::id at line 388 of accessor id defined at ../lib/SimpleDB/Class/Item.pm, avg 181µs/call | ||||
463 | 9 | 49µs | 9 | 1.58ms | return create_UUID_as_string(UUID_V4); # spent 1.58ms making 9 calls to UUID::Tiny::create_uuid_as_string, avg 176µs/call |
464 | } | ||||
465 | |||||
466 | #-------------------------------------------------------- | ||||
467 | |||||
468 | =head2 put ( ) | ||||
469 | |||||
470 | Inserts/updates the current attributes of this Item object to the database. Returns a reference to L<$self> so it can be chained into other methods. | ||||
471 | |||||
472 | =cut | ||||
473 | |||||
474 | # spent 4.18s (2.14ms+4.18) within SimpleDB::Class::Item::put which was called 12 times, avg 349ms/call:
# 11 times (1.96ms+3.86s) by SimpleDB::Class::Domain::insert at line 218 of ../lib/SimpleDB/Class/Domain.pm, avg 351ms/call
# once (179µs+318ms) by SimpleDB::Class::Item::copy at line 415 | ||||
475 | 665 | 1.76ms | my ($self) = @_; | ||
476 | my $db = $self->simpledb; # spent 46µs making 12 calls to SimpleDB::Class::Item::simpledb, avg 4µs/call | ||||
477 | my $domain_name = $db->add_domain_prefix($self->domain_name); # spent 130µs making 12 calls to SimpleDB::Class::add_domain_prefix, avg 11µs/call
# spent 21µs making 8 calls to Foo::Domain::domain_name, avg 3µs/call
# spent 7µs making 2 calls to Foo::Parent::domain_name, avg 3µs/call
# spent 6µs making 2 calls to Foo::Child::domain_name, avg 3µs/call | ||||
478 | my $i = 0; | ||||
479 | my $attributes = $self->to_hashref; # spent 5.37ms making 12 calls to SimpleDB::Class::Item::to_hashref, avg 448µs/call | ||||
480 | |||||
481 | # build the parameter list | ||||
482 | my $params = {ItemName => $self->id, DomainName=>$domain_name}; # spent 2.04ms making 12 calls to SimpleDB::Class::Item::id, avg 170µs/call | ||||
483 | foreach my $name (keys %{$attributes}) { | ||||
484 | my $values = $self->stringify_values($name, $self->$name); # spent 17.7ms making 79 calls to SimpleDB::Class::Item::stringify_values, avg 224µs/call
# spent 140µs making 8 calls to Foo::Domain::parentId, avg 18µs/call
# spent 36µs making 2 calls to Foo::Child::domainId, avg 18µs/call
# spent 21µs making 8 calls to Foo::Domain::properties, avg 3µs/call
# spent 21µs making 8 calls to Foo::Domain::notes, avg 3µs/call
# spent 20µs making 8 calls to Foo::Domain::quantity, avg 3µs/call
# spent 19µs making 8 calls to Foo::Domain::components, avg 2µs/call
# spent 19µs making 8 calls to Foo::Domain::start_date, avg 2µs/call
# spent 18µs making 8 calls to Foo::Domain::size, avg 2µs/call
# spent 17µs making 8 calls to Foo::Domain::color, avg 2µs/call
# spent 16µs making 8 calls to Foo::Domain::size_formatted, avg 2µs/call
# spent 4µs making 2 calls to Foo::Child::class, avg 2µs/call
# spent 4µs making 2 calls to Foo::Parent::title, avg 2µs/call
# spent 2µs making 1 call to Foo::SubChild::tribe | ||||
485 | unless (ref $values eq 'ARRAY') { | ||||
486 | $values = [$values]; | ||||
487 | } | ||||
488 | foreach my $value (@{$values}) { | ||||
489 | $params->{'Attribute.'.$i.'.Name'} = $name; | ||||
490 | $params->{'Attribute.'.$i.'.Value'} = $value; | ||||
491 | $params->{'Attribute.'.$i.'.Replace'} = 'true'; | ||||
492 | $i++; | ||||
493 | } | ||||
494 | } | ||||
495 | |||||
496 | # push changes | ||||
497 | eval{$db->cache->set($domain_name, $self->id, $attributes)}; # spent 6.66ms making 12 calls to SimpleDB::Class::Cache::set, avg 555µs/call
# spent 63µs making 12 calls to SimpleDB::Class::cache, avg 5µs/call
# spent 27µs making 12 calls to SimpleDB::Class::Item::id, avg 2µs/call | ||||
498 | $db->http->send_request('PutAttributes', $params); # spent 4.15s making 12 calls to SimpleDB::Client::send_request, avg 346ms/call
# spent 98µs making 12 calls to SimpleDB::Class::http, avg 8µs/call | ||||
499 | return $self; | ||||
500 | } | ||||
501 | |||||
502 | #-------------------------------------------------------- | ||||
503 | |||||
504 | =head2 to_hashref ( ) | ||||
505 | |||||
506 | Returns a hash reference of the attributes asscoiated with this item. | ||||
507 | |||||
508 | =cut | ||||
509 | |||||
510 | # spent 6.33ms (809µs+5.52) within SimpleDB::Class::Item::to_hashref which was called 18 times, avg 351µs/call:
# 12 times (523µs+4.85ms) by SimpleDB::Class::Item::put at line 479, avg 448µs/call
# 3 times (122µs+460µs) by SimpleDB::Class::ResultSet::next at line 470 of ../lib/SimpleDB/Class/ResultSet.pm, avg 194µs/call
# 2 times (90µs+120µs) by SimpleDB::Class::Domain::find at line 168 of ../lib/SimpleDB/Class/Domain.pm, avg 105µs/call
# once (74µs+85µs) by main::RUNTIME at line 43 of 05.Domain_and_Item.t | ||||
511 | 338 | 633µs | my ($self) = @_; | ||
512 | my %properties; | ||||
513 | foreach my $attribute (keys %{$self->attributes}) { # spent 36µs making 14 calls to Foo::Domain::attributes, avg 3µs/call
# spent 6µs making 2 calls to Foo::Parent::attributes, avg 3µs/call
# spent 3µs making 1 call to Foo::Child::attributes
# spent 2µs making 1 call to Foo::SubChild::attributes | ||||
514 | next if $attribute eq 'id'; | ||||
515 | $properties{$attribute} = $self->$attribute; # spent 3.29ms making 14 calls to Foo::Domain::start_date, avg 235µs/call
# spent 660µs making 14 calls to Foo::Domain::components, avg 47µs/call
# spent 590µs making 14 calls to Foo::Domain::notes, avg 42µs/call
# spent 408µs making 14 calls to Foo::Domain::parentId, avg 29µs/call
# spent 254µs making 14 calls to Foo::Domain::properties, avg 18µs/call
# spent 78µs making 2 calls to Foo::Child::domainId, avg 39µs/call
# spent 66µs making 14 calls to Foo::Domain::quantity, avg 5µs/call
# spent 50µs making 14 calls to Foo::Domain::color, avg 4µs/call
# spent 26µs making 14 calls to Foo::Domain::size_formatted, avg 2µs/call
# spent 25µs making 14 calls to Foo::Domain::size, avg 2µs/call
# spent 9µs making 2 calls to Foo::Parent::title, avg 4µs/call
# spent 8µs making 2 calls to Foo::Child::class, avg 4µs/call
# spent 4µs making 1 call to Foo::SubChild::tribe | ||||
516 | } | ||||
517 | return \%properties; | ||||
518 | } | ||||
519 | |||||
520 | #-------------------------------------------------------- | ||||
521 | |||||
522 | =head2 parse_value ( name, value ) | ||||
523 | |||||
524 | Class method. Returns the proper type for an attribute value in this class. So it could take a date string and turn it into a L<DateTime> object. See C<stringify_value> for the opposite. | ||||
525 | |||||
526 | =head3 name | ||||
527 | |||||
528 | The name of the attribute to parse. | ||||
529 | |||||
530 | =head3 value | ||||
531 | |||||
532 | The current stringified value to parse. | ||||
533 | |||||
534 | =cut | ||||
535 | |||||
536 | # spent 11.2ms (109µs+11.1) within SimpleDB::Class::Item::parse_value which was called 4 times, avg 2.81ms/call:
# 2 times (59µs+10.7ms) by SimpleDB::Class::Domain::max at line 357 of ../lib/SimpleDB/Class/Domain.pm, avg 5.39ms/call
# 2 times (50µs+405µs) by SimpleDB::Class::Domain::min at line 408 of ../lib/SimpleDB/Class/Domain.pm, avg 227µs/call | ||||
537 | 24 | 96µs | my ($class, $name, $value) = @_; | ||
538 | return $name if ($name eq 'itemName()'); | ||||
539 | |||||
540 | # find type | ||||
541 | my $attribute = $class->meta->find_attribute_by_name($name); # spent 262µs making 4 calls to Class::MOP::Class::find_attribute_by_name, avg 66µs/call
# spent 93µs making 4 calls to Foo::Domain::meta, avg 23µs/call | ||||
542 | SimpleDB::Class::Exception::InvalidParam->throw( | ||||
543 | name => 'name', | ||||
544 | value => $name, | ||||
545 | error => q{There is no attribute called '}.$name.q{'.}, | ||||
546 | ) unless defined $attribute; | ||||
547 | my $isa = $attribute->type_constraint; # spent 21µs making 4 calls to Moose::Meta::Mixin::AttributeCore::type_constraint, avg 5µs/call | ||||
548 | |||||
549 | # coerce | ||||
550 | $isa->coerce($value); # spent 10.8ms making 4 calls to Moose::Meta::TypeConstraint::coerce, avg 2.69ms/call | ||||
551 | } | ||||
552 | |||||
553 | #-------------------------------------------------------- | ||||
554 | |||||
555 | =head2 stringify_value ( name, value ) | ||||
556 | |||||
557 | Class method. Formats an attribute as a string using one of the L<SimpleDB::Class::Types> to_* functions in this class. See C<parse_value>, as this is the reverse of that. | ||||
558 | |||||
559 | =head3 name | ||||
560 | |||||
561 | The name of the attribute to format. | ||||
562 | |||||
563 | =head3 value | ||||
564 | |||||
565 | The value to format. | ||||
566 | |||||
567 | =cut | ||||
568 | |||||
569 | # spent 4.37ms (456µs+3.91) within SimpleDB::Class::Item::stringify_value which was called 22 times, avg 199µs/call:
# 13 times (269µs+2.01ms) by SimpleDB::Class::SQL::recurse_where at line 337 of ../lib/SimpleDB/Class/SQL.pm, avg 175µs/call
# 7 times (179µs+1.91ms) by SimpleDB::Class::SQL::recurse_where at line 294 of ../lib/SimpleDB/Class/SQL.pm, avg 298µs/call
# 2 times (7µs+0s) by SimpleDB::Class::SQL::recurse_where at line 316 of ../lib/SimpleDB/Class/SQL.pm, avg 4µs/call | ||||
570 | 128 | 385µs | my ($class, $name, $value) = @_; | ||
571 | return $value if ($name eq 'itemName()'); | ||||
572 | |||||
573 | # find type | ||||
574 | my $attribute = $class->meta->find_attribute_by_name($name); # spent 886µs making 18 calls to Class::MOP::Class::find_attribute_by_name, avg 49µs/call
# spent 256µs making 17 calls to Foo::Domain::meta, avg 15µs/call
# spent 15µs making 1 call to Foo::Child::meta | ||||
575 | SimpleDB::Class::Exception::InvalidParam->throw( | ||||
576 | name => 'name', | ||||
577 | value => $name, | ||||
578 | error => q{There is no attribute called '}.$name.q{'.}, | ||||
579 | ) unless defined $attribute; | ||||
580 | my $isa = $attribute->type_constraint; # spent 51µs making 18 calls to Moose::Meta::Mixin::AttributeCore::type_constraint, avg 3µs/call | ||||
581 | |||||
582 | # coerce | ||||
583 | # special cases for int stuff because technically ints are already strings | ||||
584 | 1 | 101µs | 42 | 1.78ms | if ($isa =~ /Int$/) { # spent 1.25ms making 6 calls to MooseX::Types::__ANON__[MooseX/Types.pm:486], avg 209µs/call
# spent 318µs making 18 calls to SimpleDB::Class::Item::CORE:match, avg 18µs/call
# spent 209µs making 18 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:8], avg 12µs/call |
585 | return to_SdbIntAsStr($value); | ||||
586 | } | ||||
587 | else { | ||||
588 | return to_SdbStr($value); # spent 1.13ms making 12 calls to MooseX::Types::__ANON__[MooseX/Types.pm:486], avg 95µs/call | ||||
589 | } | ||||
590 | } | ||||
591 | |||||
592 | #-------------------------------------------------------- | ||||
593 | |||||
594 | =head2 stringify_values ( name, values ) | ||||
595 | |||||
596 | Class method. Same as C<stringify_value>, but takes into account array types in addition to scalars. | ||||
597 | |||||
598 | =head3 name | ||||
599 | |||||
600 | The name of the attribute to format. | ||||
601 | |||||
602 | =head3 values | ||||
603 | |||||
604 | The value to format. | ||||
605 | |||||
606 | =cut | ||||
607 | |||||
608 | # spent 17.7ms (1.66+16.0) within SimpleDB::Class::Item::stringify_values which was called 79 times, avg 224µs/call:
# 79 times (1.66ms+16.0ms) by SimpleDB::Class::Item::put at line 484, avg 224µs/call | ||||
609 | 521 | 931µs | my ($class, $name, $value) = @_; | ||
610 | return $name if ($name eq 'itemName()'); | ||||
611 | |||||
612 | # find type | ||||
613 | my $attribute = $class->meta->find_attribute_by_name($name); # spent 2.81ms making 79 calls to Class::MOP::Class::find_attribute_by_name, avg 36µs/call
# spent 638µs making 72 calls to Foo::Domain::meta, avg 9µs/call
# spent 28µs making 2 calls to Foo::Parent::meta, avg 14µs/call
# spent 26µs making 3 calls to Foo::SubChild::meta, avg 8µs/call
# spent 25µs making 2 calls to Foo::Child::meta, avg 12µs/call | ||||
614 | SimpleDB::Class::Exception::InvalidParam->throw( | ||||
615 | name => 'name', | ||||
616 | value => $name, | ||||
617 | error => q{There is no attribute called '}.$name.q{'.}, | ||||
618 | ) unless defined $attribute; | ||||
619 | my $isa = $attribute->type_constraint; # spent 142µs making 79 calls to Moose::Meta::Mixin::AttributeCore::type_constraint, avg 2µs/call | ||||
620 | |||||
621 | # coerce | ||||
622 | # special cases for int stuff because technically ints are already strings | ||||
623 | 1 | 581µs | 332 | 6.91ms | if ($isa eq 'SimpleDB::Class::Types::SdbArrayRefOfInt') { # spent 5.09ms making 32 calls to MooseX::Types::__ANON__[MooseX/Types.pm:486], avg 159µs/call
# spent 1.17ms making 229 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:8], avg 5µs/call
# spent 645µs making 71 calls to SimpleDB::Class::Item::CORE:match, avg 9µs/call |
624 | return to_SdbArrayRefOfIntAsStr($value); | ||||
625 | } | ||||
626 | elsif ($isa eq 'SimpleDB::Class::Types::SdbInt') { | ||||
627 | return to_SdbIntAsStr($value); | ||||
628 | } | ||||
629 | elsif ($isa =~ m/ArrayRefOf|HashRef|MediumStr/) { | ||||
630 | return to_SdbArrayRefOfStr($value); | ||||
631 | } | ||||
632 | else { | ||||
633 | return to_SdbStr($value); # spent 5.73ms making 47 calls to MooseX::Types::__ANON__[MooseX/Types.pm:486], avg 122µs/call | ||||
634 | } | ||||
635 | } | ||||
636 | |||||
637 | =head1 LEGAL | ||||
638 | |||||
639 | SimpleDB::Class is Copyright 2009-2010 Plain Black Corporation (L<http://www.plainblack.com/>) and is licensed under the same terms as Perl itself. | ||||
640 | |||||
641 | =cut | ||||
642 | |||||
643 | 1 | 15µs | 1; | ||
# spent 963µs (451+511) within SimpleDB::Class::Item::CORE:match which was called 89 times, avg 11µs/call:
# 71 times (342µs+303µs) by SimpleDB::Class::Item::stringify_values at line 623 of ../lib/SimpleDB/Class/Item.pm, avg 9µs/call
# 18 times (109µs+209µs) by SimpleDB::Class::Item::stringify_value at line 584 of ../lib/SimpleDB/Class/Item.pm, avg 18µs/call |