| Filename | /home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/MooseX/Types/Base.pm |
| Statements | Executed 8616 statements in 118ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 33 | 3 | 3 | 72.2ms | 481ms | MooseX::Types::Base::import |
| 648 | 1 | 1 | 24.8ms | 51.7ms | MooseX::Types::Base::get_type |
| 648 | 1 | 1 | 16.2ms | 21.4ms | MooseX::Types::Base::has_type |
| 1 | 1 | 1 | 3.72ms | 25.1ms | MooseX::Types::Base::BEGIN@16 |
| 89 | 2 | 2 | 3.22ms | 4.41ms | MooseX::Types::Base::type_names |
| 151 | 4 | 1 | 3.09ms | 3.09ms | MooseX::Types::Base::type_storage |
| 69 | 1 | 1 | 2.05ms | 5.74ms | MooseX::Types::Base::__ANON__[:73] |
| 69 | 1 | 1 | 1.53ms | 3.03ms | MooseX::Types::Base::__ANON__[:78] |
| 1 | 1 | 1 | 1.33ms | 2.23ms | MooseX::Types::Base::BEGIN@12 |
| 9 | 1 | 1 | 266µs | 425µs | MooseX::Types::Base::add_type |
| 9 | 1 | 1 | 194µs | 443µs | MooseX::Types::Base::__ANON__[:86] |
| 1 | 1 | 1 | 71µs | 23.4ms | MooseX::Types::Base::BEGIN@3 |
| 1 | 1 | 1 | 52µs | 109µs | MooseX::Types::Base::BEGIN@202 |
| 1 | 1 | 1 | 46µs | 123µs | MooseX::Types::Base::BEGIN@187 |
| 1 | 1 | 1 | 43µs | 908µs | MooseX::Types::Base::BEGIN@13 |
| 1 | 1 | 1 | 43µs | 10.7ms | MooseX::Types::Base::BEGIN@14 |
| 1 | 1 | 1 | 41µs | 413µs | MooseX::Types::Base::BEGIN@11 |
| 1 | 1 | 1 | 37µs | 97µs | MooseX::Types::Base::BEGIN@244 |
| 0 | 0 | 0 | 0s | 0s | MooseX::Types::Base::get_registered_class_type |
| 0 | 0 | 0 | 0s | 0s | MooseX::Types::Base::get_registered_role_type |
| 0 | 0 | 0 | 0s | 0s | MooseX::Types::Base::register_class_type |
| 0 | 0 | 0 | 0s | 0s | MooseX::Types::Base::register_role_type |
| 0 | 0 | 0 | 0s | 0s | MooseX::Types::Base::registered_class_types |
| 0 | 0 | 0 | 0s | 0s | MooseX::Types::Base::registered_role_types |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package MooseX::Types::Base; | ||||
| 2 | 1 | 4µs | our $VERSION = "0.23"; | ||
| 3 | 3 | 174µs | 2 | 46.7ms | # spent 23.4ms (71µs+23.3) within MooseX::Types::Base::BEGIN@3 which was called:
# once (71µs+23.3ms) by MooseX::Types::BEGIN@12 at line 3 # spent 23.4ms making 1 call to MooseX::Types::Base::BEGIN@3
# spent 23.3ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:456] |
| 4 | |||||
| 5 | =head1 NAME | ||||
| 6 | |||||
| - - | |||||
| 11 | 3 | 124µs | 2 | 785µs | # spent 413µs (41+372) within MooseX::Types::Base::BEGIN@11 which was called:
# once (41µs+372µs) by MooseX::Types::BEGIN@12 at line 11 # spent 413µs making 1 call to MooseX::Types::Base::BEGIN@11
# spent 372µs making 1 call to Carp::Clan::import |
| 12 | 3 | 572µs | 2 | 2.45ms | # spent 2.23ms (1.33+902µs) within MooseX::Types::Base::BEGIN@12 which was called:
# once (1.33ms+902µs) by MooseX::Types::BEGIN@12 at line 12 # spent 2.23ms making 1 call to MooseX::Types::Base::BEGIN@12
# spent 225µs making 1 call to Exporter::import |
| 13 | 3 | 142µs | 2 | 1.77ms | # spent 908µs (43+864) within MooseX::Types::Base::BEGIN@13 which was called:
# once (43µs+864µs) by MooseX::Types::BEGIN@12 at line 13 # spent 908µs making 1 call to MooseX::Types::Base::BEGIN@13
# spent 864µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756] |
| 14 | 3 | 176µs | 2 | 21.3ms | # spent 10.7ms (43µs+10.6) within MooseX::Types::Base::BEGIN@14 which was called:
# once (43µs+10.6ms) by MooseX::Types::BEGIN@12 at line 14 # spent 10.7ms making 1 call to MooseX::Types::Base::BEGIN@14
# spent 10.6ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:456] |
| 15 | |||||
| 16 | 3 | 2.72ms | 2 | 33.4ms | # spent 25.1ms (3.72+21.4) within MooseX::Types::Base::BEGIN@16 which was called:
# once (3.72ms+21.4ms) by MooseX::Types::BEGIN@12 at line 16 # spent 25.1ms making 1 call to MooseX::Types::Base::BEGIN@16
# spent 8.24ms making 1 call to namespace::clean::import |
| 17 | |||||
| 18 | =head1 DESCRIPTION | ||||
| 19 | |||||
| - - | |||||
| 26 | 1 | 3µs | my $UndefMsg = q{Unable to find type '%s' in library '%s'}; | ||
| 27 | |||||
| 28 | =head1 METHODS | ||||
| 29 | |||||
| - - | |||||
| 32 | =head2 import | ||||
| 33 | |||||
| - - | |||||
| 39 | # spent 481ms (72.2+409) within MooseX::Types::Base::import which was called 33 times, avg 14.6ms/call:
# 31 times (68.7ms+375ms) by MooseX::Types::Combine::import at line 58 of MooseX/Types/Combine.pm, avg 14.3ms/call
# once (1.20ms+17.9ms) by MooseX::Types::import at line 358 of MooseX/Types.pm
# once (2.35ms+16.1ms) by Markdent::Types::Internal::BEGIN@24 at line 24 of Markdent/Types/Internal.pm | ||||
| 40 | 33 | 260µs | my ($class, @args) = @_; | ||
| 41 | |||||
| 42 | # filter or create options hash for S:E | ||||
| 43 | 33 | 217µs | my $options = (@args and (ref($args[0]) eq 'HASH')) ? $args[0] : undef; | ||
| 44 | 33 | 71µs | unless ($options) { | ||
| 45 | 1 | 6µs | $options = {foo => 23}; | ||
| 46 | 1 | 6µs | unshift @args, $options; | ||
| 47 | } | ||||
| 48 | |||||
| 49 | # all types known to us | ||||
| 50 | 33 | 878µs | 33 | 1.40ms | my @types = $class->type_names; # spent 1.40ms making 33 calls to MooseX::Types::Base::type_names, avg 42µs/call |
| 51 | |||||
| 52 | # determine the wrapper, -into is supported for compatibility reasons | ||||
| 53 | 33 | 204µs | my $wrapper = $options->{ -wrapper } || 'MooseX::Types'; | ||
| 54 | $args[0]->{into} = $options->{ -into } | ||||
| 55 | 33 | 333µs | if exists $options->{ -into }; | ||
| 56 | |||||
| 57 | 33 | 83µs | my (%ex_spec, %ex_util); | ||
| 58 | TYPE: | ||||
| 59 | 33 | 1.71ms | for my $type_short (@types) { | ||
| 60 | |||||
| 61 | # find type name and object, create undefined message | ||||
| 62 | 648 | 7.92ms | 648 | 51.7ms | my $type_full = $class->get_type($type_short) # spent 51.7ms making 648 calls to MooseX::Types::Base::get_type, avg 80µs/call |
| 63 | or croak "No fully qualified type name stored for '$type_short'"; | ||||
| 64 | 648 | 6.72ms | 648 | 79.8ms | my $type_cons = find_type_constraint($type_full); # spent 79.8ms making 648 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 123µs/call |
| 65 | 648 | 5.25ms | my $undef_msg = sprintf($UndefMsg, $type_short, $class); | ||
| 66 | |||||
| 67 | # the type itself | ||||
| 68 | push @{ $ex_spec{exports} }, | ||||
| 69 | $type_short, | ||||
| 70 | # spent 5.74ms (2.05+3.69) within MooseX::Types::Base::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/MooseX/Types/Base.pm:73] which was called 69 times, avg 83µs/call:
# 69 times (2.05ms+3.69ms) by Sub::Exporter::default_generator at line 856 of Sub/Exporter.pm, avg 83µs/call | ||||
| 71 | 69 | 1.93ms | 69 | 3.69ms | bless $wrapper->type_export_generator($type_short, $type_full), # spent 3.69ms making 69 calls to MooseX::Types::type_export_generator, avg 53µs/call |
| 72 | 'MooseX::Types::EXPORTED_TYPE_CONSTRAINT'; | ||||
| 73 | 648 | 8.81ms | }; | ||
| 74 | |||||
| 75 | # the check helper | ||||
| 76 | push @{ $ex_spec{exports} }, | ||||
| 77 | "is_${type_short}", | ||||
| 78 | 717 | 9.68ms | 69 | 1.50ms | # spent 3.03ms (1.53+1.50) within MooseX::Types::Base::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/MooseX/Types/Base.pm:78] which was called 69 times, avg 44µs/call:
# 69 times (1.53ms+1.50ms) by Sub::Exporter::default_generator at line 856 of Sub/Exporter.pm, avg 44µs/call # spent 1.50ms making 69 calls to MooseX::Types::check_export_generator, avg 22µs/call |
| 79 | |||||
| 80 | # only export coercion helper if full (for libraries) or coercion is defined | ||||
| 81 | next TYPE | ||||
| 82 | unless $options->{ -full } | ||||
| 83 | 648 | 18.4ms | 1278 | 12.9ms | or ($type_cons and $type_cons->has_coercion); # spent 7.55ms making 639 calls to Moose::Meta::TypeConstraint::has_coercion, avg 12µs/call
# spent 5.35ms making 639 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 8µs/call |
| 84 | push @{ $ex_spec{exports} }, | ||||
| 85 | "to_${type_short}", | ||||
| 86 | 18 | 293µs | 9 | 249µs | # spent 443µs (194+249) within MooseX::Types::Base::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/MooseX/Types/Base.pm:86] which was called 9 times, avg 49µs/call:
# 9 times (194µs+249µs) by Sub::Exporter::default_generator at line 856 of Sub/Exporter.pm, avg 49µs/call # spent 249µs making 9 calls to MooseX::Types::coercion_export_generator, avg 28µs/call |
| 87 | 9 | 87µs | $ex_util{ $type_short }{to}++; # shortcut to remember this exists | ||
| 88 | } | ||||
| 89 | |||||
| 90 | # create S:E exporter and increase export level unless specified explicitly | ||||
| 91 | 33 | 462µs | 33 | 179ms | my $exporter = build_exporter \%ex_spec; # spent 179ms making 33 calls to Sub::Exporter::build_exporter, avg 5.42ms/call |
| 92 | 33 | 130µs | $options->{into_level}++ | ||
| 93 | unless $options->{into}; | ||||
| 94 | |||||
| 95 | # remember requested symbols to determine what helpers to auto-export | ||||
| 96 | my %was_requested = | ||||
| 97 | map { ($_ => 1) } | ||||
| 98 | 33 | 562µs | grep { not ref } | ||
| 99 | @args; | ||||
| 100 | |||||
| 101 | # determine which additional symbols (helpers) to export along | ||||
| 102 | 33 | 70µs | my %add; | ||
| 103 | EXPORT: | ||||
| 104 | 33 | 856µs | for my $type (grep { exists $was_requested{ $_ } } @types) { | ||
| 105 | 69 | 366µs | $add{ "is_$type" }++ | ||
| 106 | unless $was_requested{ "is_$type" }; | ||||
| 107 | next EXPORT | ||||
| 108 | 69 | 337µs | unless exists $ex_util{ $type }{to}; | ||
| 109 | 9 | 55µs | $add{ "to_$type" }++ | ||
| 110 | unless $was_requested{ "to_$type" }; | ||||
| 111 | } | ||||
| 112 | |||||
| 113 | # and on to the real exporter | ||||
| 114 | 33 | 351µs | my @new_args = (@args, keys %add); | ||
| 115 | 33 | 2.21ms | 33 | 84.0ms | return $class->$exporter(@new_args); # spent 84.0ms making 33 calls to Sub::Exporter::__ANON__[Sub/Exporter.pm:756], avg 2.55ms/call |
| 116 | } | ||||
| 117 | |||||
| 118 | =head2 get_type | ||||
| 119 | |||||
| - - | |||||
| 124 | # spent 51.7ms (24.8+26.9) within MooseX::Types::Base::get_type which was called 648 times, avg 80µs/call:
# 648 times (24.8ms+26.9ms) by MooseX::Types::Base::import at line 62, avg 80µs/call | ||||
| 125 | 648 | 2.50ms | my ($class, $type) = @_; | ||
| 126 | |||||
| 127 | # useful message if the type couldn't be found | ||||
| 128 | 648 | 6.20ms | 648 | 21.4ms | croak "Unknown type '$type' in library '$class'" # spent 21.4ms making 648 calls to MooseX::Types::Base::has_type, avg 33µs/call |
| 129 | unless $class->has_type($type); | ||||
| 130 | |||||
| 131 | # return real name of the type | ||||
| 132 | 648 | 13.3ms | 648 | 5.46ms | return $class->type_storage->{ $type }; # spent 4.34ms making 594 calls to MooseX::Types::Moose::type_storage, avg 7µs/call
# spent 1.12ms making 54 calls to MooseX::Types::Base::type_storage, avg 21µs/call |
| 133 | } | ||||
| 134 | |||||
| 135 | =head2 type_names | ||||
| 136 | |||||
| - - | |||||
| 141 | # spent 4.41ms (3.22+1.19) within MooseX::Types::Base::type_names which was called 89 times, avg 50µs/call:
# 56 times (2.15ms+865µs) by MooseX::Types::Combine::import at line 44 of MooseX/Types/Combine.pm, avg 54µs/call
# 33 times (1.08ms+322µs) by MooseX::Types::Base::import at line 50, avg 42µs/call | ||||
| 142 | 89 | 325µs | my ($class) = @_; | ||
| 143 | |||||
| 144 | # return short names of all stored types | ||||
| 145 | 89 | 2.66ms | 89 | 1.19ms | return keys %{ $class->type_storage }; # spent 764µs making 34 calls to MooseX::Types::Base::type_storage, avg 22µs/call
# spent 423µs making 55 calls to MooseX::Types::Moose::type_storage, avg 8µs/call |
| 146 | } | ||||
| 147 | |||||
| 148 | =head2 add_type | ||||
| 149 | |||||
| - - | |||||
| 154 | # spent 425µs (266+158) within MooseX::Types::Base::add_type which was called 9 times, avg 47µs/call:
# 9 times (266µs+158µs) by MooseX::Types::import at line 354 of MooseX/Types.pm, avg 47µs/call | ||||
| 155 | 9 | 35µs | my ($class, $type) = @_; | ||
| 156 | |||||
| 157 | # store type with library prefix as real name | ||||
| 158 | 9 | 211µs | 9 | 158µs | $class->type_storage->{ $type } = "${class}::${type}"; # spent 158µs making 9 calls to MooseX::Types::Base::type_storage, avg 18µs/call |
| 159 | } | ||||
| 160 | |||||
| 161 | =head2 has_type | ||||
| 162 | |||||
| - - | |||||
| 168 | # spent 21.4ms (16.2+5.22) within MooseX::Types::Base::has_type which was called 648 times, avg 33µs/call:
# 648 times (16.2ms+5.22ms) by MooseX::Types::Base::get_type at line 128, avg 33µs/call | ||||
| 169 | 648 | 2.10ms | my ($class, $type) = @_; | ||
| 170 | |||||
| 171 | # check if we stored a type under that name | ||||
| 172 | 648 | 13.2ms | 648 | 5.22ms | return ! ! $class->type_storage->{ $type }; # spent 4.16ms making 594 calls to MooseX::Types::Moose::type_storage, avg 7µs/call
# spent 1.05ms making 54 calls to MooseX::Types::Base::type_storage, avg 19µs/call |
| 173 | } | ||||
| 174 | |||||
| 175 | =head2 type_storage | ||||
| 176 | |||||
| - - | |||||
| 183 | # spent 3.09ms within MooseX::Types::Base::type_storage which was called 151 times, avg 20µs/call:
# 54 times (1.12ms+0s) by MooseX::Types::Base::get_type at line 132, avg 21µs/call
# 54 times (1.05ms+0s) by MooseX::Types::Base::has_type at line 172, avg 19µs/call
# 34 times (764µs+0s) by MooseX::Types::Base::type_names at line 145, avg 22µs/call
# 9 times (158µs+0s) by MooseX::Types::Base::add_type at line 158, avg 18µs/call | ||||
| 184 | 151 | 467µs | my ($class) = @_; | ||
| 185 | |||||
| 186 | # return a reference to the storage in ourself | ||||
| 187 | 154 | 587µs | 2 | 199µs | # spent 123µs (46+76) within MooseX::Types::Base::BEGIN@187 which was called:
# once (46µs+76µs) by MooseX::Types::BEGIN@12 at line 187 # spent 123µs making 1 call to MooseX::Types::Base::BEGIN@187
# spent 76µs making 1 call to strict::unimport |
| 188 | 151 | 2.97ms | return \%{ $class . '::__MOOSEX_TYPELIBRARY_STORAGE' }; | ||
| 189 | } | ||||
| 190 | } | ||||
| 191 | |||||
| 192 | =head2 registered_class_types | ||||
| 193 | |||||
| - - | |||||
| 198 | sub registered_class_types { | ||||
| 199 | my ($class) = @_; | ||||
| 200 | |||||
| 201 | { | ||||
| 202 | 3 | 542µs | 2 | 167µs | # spent 109µs (52+57) within MooseX::Types::Base::BEGIN@202 which was called:
# once (52µs+57µs) by MooseX::Types::BEGIN@12 at line 202 # spent 109µs making 1 call to MooseX::Types::Base::BEGIN@202
# spent 57µs making 1 call to strict::unimport |
| 203 | return \%{ $class . '::__MOOSEX_TYPELIBRARY_CLASS_TYPES' }; | ||||
| 204 | } | ||||
| 205 | } | ||||
| 206 | |||||
| 207 | =head2 register_class_type | ||||
| 208 | |||||
| - - | |||||
| 213 | sub register_class_type { | ||||
| 214 | my ($class, $type) = @_; | ||||
| 215 | |||||
| 216 | croak "Not a class_type" | ||||
| 217 | unless $type->isa('Moose::Meta::TypeConstraint::Class'); | ||||
| 218 | |||||
| 219 | $class->registered_class_types->{$type->class} = $type; | ||||
| 220 | } | ||||
| 221 | |||||
| 222 | =head2 get_registered_class_type | ||||
| 223 | |||||
| - - | |||||
| 228 | sub get_registered_class_type { | ||||
| 229 | my ($class, $name) = @_; | ||||
| 230 | |||||
| 231 | $class->registered_class_types->{$name}; | ||||
| 232 | } | ||||
| 233 | |||||
| 234 | =head2 registered_role_types | ||||
| 235 | |||||
| - - | |||||
| 240 | sub registered_role_types { | ||||
| 241 | my ($class) = @_; | ||||
| 242 | |||||
| 243 | { | ||||
| 244 | 3 | 482µs | 2 | 157µs | # spent 97µs (37+60) within MooseX::Types::Base::BEGIN@244 which was called:
# once (37µs+60µs) by MooseX::Types::BEGIN@12 at line 244 # spent 97µs making 1 call to MooseX::Types::Base::BEGIN@244
# spent 60µs making 1 call to strict::unimport |
| 245 | return \%{ $class . '::__MOOSEX_TYPELIBRARY_ROLE_TYPES' }; | ||||
| 246 | } | ||||
| 247 | } | ||||
| 248 | |||||
| 249 | =head2 register_role_type | ||||
| 250 | |||||
| - - | |||||
| 255 | sub register_role_type { | ||||
| 256 | my ($class, $type) = @_; | ||||
| 257 | |||||
| 258 | croak "Not a role_type" | ||||
| 259 | unless $type->isa('Moose::Meta::TypeConstraint::Role'); | ||||
| 260 | |||||
| 261 | $class->registered_role_types->{$type->role} = $type; | ||||
| 262 | } | ||||
| 263 | |||||
| 264 | =head2 get_registered_role_type | ||||
| 265 | |||||
| - - | |||||
| 270 | sub get_registered_role_type { | ||||
| 271 | my ($class, $name) = @_; | ||||
| 272 | |||||
| 273 | $class->registered_role_types->{$name}; | ||||
| 274 | } | ||||
| 275 | |||||
| 276 | =head1 SEE ALSO | ||||
| 277 | |||||
| - - | |||||
| 291 | 1 | 58µs | 1 | 30.0ms | 1; # spent 30.0ms making 1 call to B::Hooks::EndOfScope::__ANON__[B/Hooks/EndOfScope.pm:26] |