← Index
NYTProf Performance Profile   « block view • line view • sub view »
For /usr/bin/epoll_server.pl
  Run on Wed Jan 5 05:34:33 2011
Reported on Wed Jan 5 05:36:05 2011

File /usr/lib/perl5/vendor_perl/5.10.1/MooseX/Types/TypeDecorator.pm
Statements Executed 535
Statement Execution Time 12.1ms
Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1116.28ms7.14msMooseX::Types::TypeDecorator::::BEGIN@8MooseX::Types::TypeDecorator::BEGIN@8
64311.89ms2.26msMooseX::Types::TypeDecorator::::__type_constraintMooseX::Types::TypeDecorator::__type_constraint
20541.43ms10.3msMooseX::Types::TypeDecorator::::AUTOLOADMooseX::Types::TypeDecorator::AUTOLOAD
23531.27ms2.56msMooseX::Types::TypeDecorator::::__ANON__[:21]MooseX::Types::TypeDecorator::__ANON__[:21]
21441.08ms2.20msMooseX::Types::TypeDecorator::::isaMooseX::Types::TypeDecorator::isa
911683µs1.00msMooseX::Types::TypeDecorator::::newMooseX::Types::TypeDecorator::new
2012585µs585µsMooseX::Types::TypeDecorator::::CORE:matchMooseX::Types::TypeDecorator::CORE:match (opcode)
111215µs215µsMooseX::Types::TypeDecorator::::BEGIN@9MooseX::Types::TypeDecorator::BEGIN@9
111172µs190µsMooseX::Types::TypeDecorator::::BEGIN@10MooseX::Types::TypeDecorator::BEGIN@10
11192µs149µsMooseX::Types::TypeDecorator::::BEGIN@5MooseX::Types::TypeDecorator::BEGIN@5
11158µs239µsMooseX::Types::TypeDecorator::::BEGIN@13MooseX::Types::TypeDecorator::BEGIN@13
11153µs66µsMooseX::Types::TypeDecorator::::BEGIN@4MooseX::Types::TypeDecorator::BEGIN@4
11143µs310µsMooseX::Types::TypeDecorator::::BEGIN@11MooseX::Types::TypeDecorator::BEGIN@11
0000s0sMooseX::Types::TypeDecorator::::DESTROYMooseX::Types::TypeDecorator::DESTROY
0000s0sMooseX::Types::TypeDecorator::::__ANON__[:44]MooseX::Types::TypeDecorator::__ANON__[:44]
0000s0sMooseX::Types::TypeDecorator::::_throw_errorMooseX::Types::TypeDecorator::_throw_error
0000s0sMooseX::Types::TypeDecorator::::canMooseX::Types::TypeDecorator::can
0000s0sMooseX::Types::TypeDecorator::::metaMooseX::Types::TypeDecorator::meta
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package MooseX::Types::TypeDecorator;
212µsour $VERSION = "0.21";
3
43181µs279µs
# spent 66µs (53+13) within MooseX::Types::TypeDecorator::BEGIN@4 which was called # once (53µs+13µs) by MooseX::Types::BEGIN@11 at line 4
use strict;
# spent 66µs making 1 call to MooseX::Types::TypeDecorator::BEGIN@4 # spent 13µs making 1 call to strict::import
5394µs2206µs
# spent 149µs (92+57) within MooseX::Types::TypeDecorator::BEGIN@5 which was called # once (92µs+57µs) by MooseX::Types::BEGIN@11 at line 5
use warnings;
# spent 149µs making 1 call to MooseX::Types::TypeDecorator::BEGIN@5 # spent 57µs making 1 call to warnings::import
6
7
83599µs27.50ms
# spent 7.14ms (6.28+866µs) within MooseX::Types::TypeDecorator::BEGIN@8 which was called # once (6.28ms+866µs) by MooseX::Types::BEGIN@11 at line 8
use Carp::Clan qw( ^MooseX::Types );
# spent 7.14ms making 1 call to MooseX::Types::TypeDecorator::BEGIN@8 # spent 360µs making 1 call to Carp::Clan::import
93290µs1215µs
# spent 215µs within MooseX::Types::TypeDecorator::BEGIN@9 which was called # once (215µs+0s) by MooseX::Types::BEGIN@11 at line 9
use Moose::Util::TypeConstraints ();
# spent 215µs making 1 call to MooseX::Types::TypeDecorator::BEGIN@9
103242µs2208µs
# spent 190µs (172+18) within MooseX::Types::TypeDecorator::BEGIN@10 which was called # once (172µs+18µs) by MooseX::Types::BEGIN@11 at line 10
use Moose::Meta::TypeConstraint::Union;
# spent 190µs making 1 call to MooseX::Types::TypeDecorator::BEGIN@10 # spent 18µs making 1 call to UNIVERSAL::import
113914µs2577µs
# spent 310µs (43+267) within MooseX::Types::TypeDecorator::BEGIN@11 which was called # once (43µs+267µs) by MooseX::Types::BEGIN@11 at line 11
use Scalar::Util qw(blessed);
# spent 310µs making 1 call to MooseX::Types::TypeDecorator::BEGIN@11 # spent 267µs making 1 call to Exporter::import
12
13
# spent 239µs (58+181) within MooseX::Types::TypeDecorator::BEGIN@13 which was called # once (58µs+181µs) by MooseX::Types::BEGIN@11 at line 47
use overload(
14
# spent 2.56ms (1.27+1.29) within MooseX::Types::TypeDecorator::__ANON__[/usr/lib/perl5/vendor_perl/5.10.1/MooseX/Types/TypeDecorator.pm:21] which was called 23 times, avg 111µs/call: # 6 times (250µs+297µs) by Moose::Meta::Method::Accessor::_eval_code at line 26 of Moose/Meta/Method/Accessor.pm, avg 91µs/call # 5 times (181µs+470µs) by Moose::Util::TypeConstraints::find_or_create_isa_type_constraint at line 203 of Moose/Util/TypeConstraints.pm, avg 130µs/call # 5 times (395µs+231µs) by Moose::Util::TypeConstraints::find_or_parse_type_constraint at line 217 of Moose/Util/TypeConstraints.pm, avg 125µs/call # 5 times (303µs+201µs) by Moose::Util::TypeConstraints::CORE:subst at line 237 of Moose/Util/TypeConstraints.pm, avg 101µs/call # 2 times (145µs+87µs) by Moose::Meta::Role::Attribute::is_same_as at line 92 of Moose/Meta/Role/Attribute.pm, avg 116µs/call
'""' => sub {
15461.21ms my $self = shift @_;
16 if(blessed $self) {
# spent 765µs making 23 calls to MooseX::Types::TypeDecorator::__type_constraint, avg 33µs/call # spent 406µs making 23 calls to Moose::Meta::TypeConstraint::name, avg 18µs/call # spent 114µs making 23 calls to Scalar::Util::blessed, avg 5µs/call
17 return $self->__type_constraint->name;
18 } else {
19 return "$self";
20 }
21 },
22 '|' => sub {
23
24 ## It's kind of ugly that we need to know about Union Types, but this
25 ## is needed for syntax compatibility. Maybe someday we'll all just do
26 ## Or[Str,Str,Int]
27
28 my @args = @_[0,1]; ## arg 3 is special, see the overload docs.
29 my @tc = grep {blessed $_} map {
30 blessed $_ ? $_ :
31 Moose::Util::TypeConstraints::find_or_parse_type_constraint($_)
32 || __PACKAGE__->_throw_error( "$_ is not a type constraint")
33 } @args;
34
35 ( scalar @tc == scalar @args)
36 || __PACKAGE__->_throw_error(
37 "one of your type constraints is bad. Passed: ". join(', ', @args) ." Got: ". join(', ', @tc));
38
39 ( scalar @tc >= 2 )
40 || __PACKAGE__->_throw_error("You must pass in at least 2 type names to make a union");
41
42 my $union = Moose::Meta::TypeConstraint::Union->new(type_constraints=>\@tc);
43 return Moose::Util::TypeConstraints::register_type_constraint($union);
44 },
45 fallback => 1,
# spent 181µs making 1 call to overload::import
46
4731.89ms1239µs);
# spent 239µs making 1 call to MooseX::Types::TypeDecorator::BEGIN@13
48
49=head1 NAME
50
51MooseX::Types::TypeDecorator - More flexible access to a Type Constraint
52
53=head1 DESCRIPTION
54
55This is a decorator object that contains an underlying type constraint. We use
56this to control access to the type constraint and to add some features.
57
58=head1 METHODS
59
60This class defines the following methods.
61
62=head2 new
63
64Old school instantiation
65
66=cut
67
68
# spent 1.00ms (683µs+321µs) within MooseX::Types::TypeDecorator::new which was called 9 times, avg 112µs/call: # 9 times (683µs+321µs) by MooseX::Types::create_type_decorator at line 464 of MooseX/Types.pm, avg 112µs/call
sub new {
6927750µs my $class = shift @_;
70120µs9237µs if(my $arg = shift @_) {
# spent 237µs making 9 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:8], avg 26µs/call
71 if(blessed $arg && $arg->isa('Moose::Meta::TypeConstraint')) {
# spent 47µs making 9 calls to Scalar::Util::blessed, avg 5µs/call # spent 38µs making 9 calls to UNIVERSAL::isa, avg 4µs/call
72 return bless {'__type_constraint'=>$arg}, $class;
73 } elsif(
74 blessed $arg &&
75 $arg->isa('MooseX::Types::UndefinedType')
76 ) {
77 ## stub in case we'll need to handle these types differently
78 return bless {'__type_constraint'=>$arg}, $class;
79 } elsif(blessed $arg) {
80 __PACKAGE__->_throw_error("Argument must be ->isa('Moose::Meta::TypeConstraint') or ->isa('MooseX::Types::UndefinedType'), not ". blessed $arg);
81 } else {
82 __PACKAGE__->_throw_error("Argument cannot be '$arg'");
83 }
84 } else {
85 __PACKAGE__->_throw_error("This method [new] requires a single argument.");
86 }
87}
88
89=head2 __type_constraint ($type_constraint)
90
91Set/Get the type_constraint.
92
93=cut
94
95
# spent 2.26ms (1.89+377µs) within MooseX::Types::TypeDecorator::__type_constraint which was called 64 times, avg 35µs/call: # 23 times (683µs+82µs) by MooseX::Types::TypeDecorator::__ANON__[/usr/lib/perl5/vendor_perl/5.10.1/MooseX/Types/TypeDecorator.pm:21] at line 16, avg 33µs/call # 21 times (558µs+202µs) by MooseX::Types::TypeDecorator::isa at line 115, avg 36µs/call # 20 times (645µs+93µs) by MooseX::Types::TypeDecorator::AUTOLOAD at line 200, avg 37µs/call
sub __type_constraint {
962562.74ms my $self = shift @_;
97 if(blessed $self) {
# spent 377µs making 64 calls to Scalar::Util::blessed, avg 6µs/call
98 if(defined(my $tc = shift @_)) {
99 $self->{__type_constraint} = $tc;
100 }
101 return $self->{__type_constraint};
102 } else {
103 __PACKAGE__->_throw_error('cannot call __type_constraint as a class method');
104 }
105}
106
107=head2 isa
108
109handle $self->isa since AUTOLOAD can't.
110
111=cut
112
113
# spent 2.20ms (1.08+1.12) within MooseX::Types::TypeDecorator::isa which was called 21 times, avg 105µs/call: # 6 times (287µs+374µs) by Moose::Meta::Attribute::_process_options at line 303 of Moose/Meta/Attribute.pm, avg 110µs/call # 5 times (390µs+434µs) by Moose::Meta::TypeConstraint::Parameterizable::parameterize at line 67 of Moose/Meta/TypeConstraint/Parameterizable.pm, avg 165µs/call # 5 times (221µs+157µs) by Moose::Meta::TypeConstraint::Parameterized::compile_type_constraint at line 46 of Moose/Meta/TypeConstraint/Parameterized.pm, avg 76µs/call # 5 times (180µs+155µs) by Moose::Util::TypeConstraints::find_type_constraint at line 255 of Moose/Util/TypeConstraints.pm, avg 67µs/call
sub isa {
114421.18ms my ($self, $target) = @_;
115 if(defined $target) {
# spent 760µs making 21 calls to MooseX::Types::TypeDecorator::__type_constraint, avg 36µs/call # spent 245µs making 21 calls to Scalar::Util::blessed, avg 12µs/call # spent 115µs making 21 calls to UNIVERSAL::isa, avg 5µs/call
116 if(blessed $self) {
117 return $self->__type_constraint->isa($target);
118 } else {
119 return;
120 }
121 } else {
122 return;
123 }
124}
125
126
127=head2 can
128
129handle $self->can since AUTOLOAD can't.
130
131=cut
132
133sub can {
134 my ($self, $target) = @_;
135 if(defined $target) {
136 if(blessed $self) {
137 return $self->__type_constraint->can($target);
138 } else {
139 return;
140 }
141 } else {
142 return;
143 }
144}
145
146=head2 meta
147
148have meta examine the underlying type constraints
149
150=cut
151
152sub meta {
153 my $self = shift @_;
154 if(blessed $self) {
155 return $self->__type_constraint->meta;
156 }
157}
158
159=head2 _throw_error
160
161properly delegate error messages
162
163=cut
164
165sub _throw_error {
166 shift;
167 require Moose;
168 unshift @_, 'Moose';
169 goto &Moose::throw_error;
170}
171
172=head2 DESTROY
173
174We might need it later
175
176=cut
177
178sub DESTROY {
179 return;
180}
181
182=head2 AUTOLOAD
183
184Delegate to the decorator targe
185
186=cut
187
188
# spent 10.3ms (1.43+8.88) within MooseX::Types::TypeDecorator::AUTOLOAD which was called 20 times, avg 515µs/call: # 6 times (515µs+380µs) by Moose::Meta::Method::Accessor::_eval_code at line 26 of Moose/Meta/Method/Accessor.pm, avg 149µs/call # 5 times (391µs+610µs) by Moose::Meta::TypeConstraint::Parameterizable::parameterize at line 68 of Moose/Meta/TypeConstraint/Parameterizable.pm, avg 200µs/call # 4 times (201µs+7.45ms) by Moose::Meta::Attribute::verify_against_type_constraint at line 759 of Moose/Meta/Attribute.pm, avg 1.91ms/call # 4 times (272µs+393µs) by Moose::Util::TypeConstraints::__ANON__[/usr/lib/perl5/vendor_perl/5.10.1/i386-linux-thread-multi/Moose/Util/TypeConstraints.pm:750] at line 743 of Moose/Util/TypeConstraints.pm, avg 166µs/call # once (48µs+54µs) by Moose::Util::TypeConstraints::__ANON__[/usr/lib/perl5/vendor_perl/5.10.1/i386-linux-thread-multi/Moose/Util/TypeConstraints.pm:771] at line 764 of Moose/Util/TypeConstraints.pm
sub AUTOLOAD {
189
1901401.98ms my ($self, @args) = @_;
191 my ($method) = (our $AUTOLOAD =~ /([^:]+)$/);
# spent 585µs making 20 calls to MooseX::Types::TypeDecorator::CORE:match, avg 29µs/call
192
193 ## We delegate with this method in an attempt to support a value of
194 ## __type_constraint which is also AUTOLOADing, in particular the class
195 ## MooseX::Types::UndefinedType which AUTOLOADs during autovivication.
196
197 my $return;
198
199 eval {
200 $return = $self->__type_constraint->$method(@args);
# spent 7.27ms making 4 calls to Moose::Meta::TypeConstraint::check, avg 1.82ms/call # spent 738µs making 20 calls to MooseX::Types::TypeDecorator::__type_constraint, avg 37µs/call # spent 238µs making 11 calls to Moose::Meta::TypeConstraint::_compiled_type_constraint, avg 22µs/call # spent 48µs making 5 calls to Moose::Meta::TypeConstraint::name, avg 10µs/call
201 }; if($@) {
202 __PACKAGE__->_throw_error($@);
203 } else {
204 return $return;
205 }
206}
207
208=head1 AUTHOR
209
210See L<MooseX::Types/AUTHOR>.
211
212=head1 LICENSE
213
214This program is free software; you can redistribute it and/or modify
215it under the same terms as perl itself.
216
217=cut
218
21915µs1;
# spent 585µs within MooseX::Types::TypeDecorator::CORE:match which was called 20 times, avg 29µs/call: # 20 times (585µs+0s) by MooseX::Types::TypeDecorator::AUTOLOAD at line 191 of MooseX/Types/TypeDecorator.pm, avg 29µs/call
sub MooseX::Types::TypeDecorator::CORE:match; # xsub