| Filename | /home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/MooseX/Types.pm |
| Statements | Executed 1092 statements in 21.2ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 7.77ms | 1.17s | MooseX::Types::BEGIN@2 |
| 1 | 1 | 1 | 4.51ms | 97.6ms | MooseX::Types::BEGIN@12 |
| 1 | 1 | 1 | 3.59ms | 10.4ms | MooseX::Types::BEGIN@11 |
| 69 | 1 | 1 | 2.57ms | 3.69ms | MooseX::Types::type_export_generator |
| 1 | 1 | 1 | 2.14ms | 13.0ms | MooseX::Types::BEGIN@15 |
| 68 | 1 | 1 | 1.79ms | 8.01ms | MooseX::Types::create_type_decorator |
| 1 | 1 | 1 | 1.70ms | 2.58ms | MooseX::Types::BEGIN@14 |
| 68 | 1 | 1 | 1.58ms | 10.5ms | MooseX::Types::create_base_type_constraint |
| 69 | 1 | 1 | 1.50ms | 1.50ms | MooseX::Types::check_export_generator |
| 2 | 2 | 2 | 890µs | 52.4ms | MooseX::Types::import |
| 6 | 1 | 1 | 320µs | 33.2ms | MooseX::Types::create_arged_type_constraint |
| 9 | 1 | 1 | 249µs | 249µs | MooseX::Types::coercion_export_generator |
| 1 | 1 | 1 | 146µs | 146µs | MooseX::Types::BEGIN@22 |
| 1 | 1 | 1 | 48µs | 32.0ms | MooseX::Types::BEGIN@10 |
| 1 | 1 | 1 | 47µs | 8.42ms | MooseX::Types::BEGIN@20 |
| 1 | 1 | 1 | 43µs | 186µs | MooseX::Types::BEGIN@18 |
| 1 | 1 | 1 | 42µs | 388µs | MooseX::Types::BEGIN@16 |
| 1 | 1 | 1 | 42µs | 195µs | MooseX::Types::BEGIN@17 |
| 1 | 1 | 1 | 42µs | 203µs | MooseX::Types::BEGIN@13 |
| 1 | 1 | 1 | 42µs | 111µs | MooseX::Types::BEGIN@339 |
| 9 | 1 | 1 | 31µs | 31µs | MooseX::Types::CORE:match (opcode) |
| 0 | 0 | 0 | 0s | 0s | MooseX::Types::__ANON__[:417] |
| 0 | 0 | 0 | 0s | 0s | MooseX::Types::__ANON__[:486] |
| 0 | 0 | 0 | 0s | 0s | MooseX::Types::__ANON__[:504] |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package MooseX::Types; | ||||
| 2 | 3 | 441µs | 2 | 1.20s | # spent 1.17s (7.77ms+1.17) within MooseX::Types::BEGIN@2 which was called:
# once (7.77ms+1.17s) by Markdent::Types::Internal::BEGIN@11 at line 2 # spent 1.17s making 1 call to MooseX::Types::BEGIN@2
# spent 25.4ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:456] |
| 3 | |||||
| 4 | =head1 NAME | ||||
| 5 | |||||
| - - | |||||
| 10 | 3 | 157µs | 2 | 63.9ms | # spent 32.0ms (48µs+31.9) within MooseX::Types::BEGIN@10 which was called:
# once (48µs+31.9ms) by Markdent::Types::Internal::BEGIN@11 at line 10 # spent 32.0ms making 1 call to MooseX::Types::BEGIN@10
# spent 31.9ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:456] |
| 11 | 3 | 601µs | 1 | 10.4ms | # spent 10.4ms (3.59+6.83) within MooseX::Types::BEGIN@11 which was called:
# once (3.59ms+6.83ms) by Markdent::Types::Internal::BEGIN@11 at line 11 # spent 10.4ms making 1 call to MooseX::Types::BEGIN@11 |
| 12 | 3 | 532µs | 1 | 97.6ms | # spent 97.6ms (4.51+93.1) within MooseX::Types::BEGIN@12 which was called:
# once (4.51ms+93.1ms) by Markdent::Types::Internal::BEGIN@11 at line 12 # spent 97.6ms making 1 call to MooseX::Types::BEGIN@12 |
| 13 | 3 | 109µs | 2 | 365µs | # spent 203µs (42+162) within MooseX::Types::BEGIN@13 which was called:
# once (42µs+162µs) by Markdent::Types::Internal::BEGIN@11 at line 13 # spent 203µs making 1 call to MooseX::Types::BEGIN@13
# spent 162µs making 1 call to Exporter::import |
| 14 | 3 | 559µs | 1 | 2.58ms | # spent 2.58ms (1.70+884µs) within MooseX::Types::BEGIN@14 which was called:
# once (1.70ms+884µs) by Markdent::Types::Internal::BEGIN@11 at line 14 # spent 2.58ms making 1 call to MooseX::Types::BEGIN@14 |
| 15 | 3 | 535µs | 1 | 13.0ms | # spent 13.0ms (2.14+10.8) within MooseX::Types::BEGIN@15 which was called:
# once (2.14ms+10.8ms) by Markdent::Types::Internal::BEGIN@11 at line 15 # spent 13.0ms making 1 call to MooseX::Types::BEGIN@15 |
| 16 | 3 | 116µs | 2 | 734µs | # spent 388µs (42+346) within MooseX::Types::BEGIN@16 which was called:
# once (42µs+346µs) by Markdent::Types::Internal::BEGIN@11 at line 16 # spent 388µs making 1 call to MooseX::Types::BEGIN@16
# spent 346µs making 1 call to Carp::Clan::import |
| 17 | 3 | 112µs | 2 | 349µs | # spent 195µs (42+153) within MooseX::Types::BEGIN@17 which was called:
# once (42µs+153µs) by Markdent::Types::Internal::BEGIN@11 at line 17 # spent 195µs making 1 call to MooseX::Types::BEGIN@17
# spent 153µs making 1 call to Exporter::import |
| 18 | 3 | 158µs | 2 | 329µs | # spent 186µs (43+143) within MooseX::Types::BEGIN@18 which was called:
# once (43µs+143µs) by Markdent::Types::Internal::BEGIN@11 at line 18 # spent 186µs making 1 call to MooseX::Types::BEGIN@18
# spent 143µs making 1 call to Exporter::import |
| 19 | |||||
| 20 | 3 | 144µs | 2 | 16.8ms | # spent 8.42ms (47µs+8.37) within MooseX::Types::BEGIN@20 which was called:
# once (47µs+8.37ms) by Markdent::Types::Internal::BEGIN@11 at line 20 # spent 8.42ms making 1 call to MooseX::Types::BEGIN@20
# spent 8.37ms making 1 call to namespace::clean::import |
| 21 | |||||
| 22 | 3 | 574µs | 1 | 146µs | # spent 146µs within MooseX::Types::BEGIN@22 which was called:
# once (146µs+0s) by Markdent::Types::Internal::BEGIN@11 at line 22 # spent 146µs making 1 call to MooseX::Types::BEGIN@22 |
| 23 | 1 | 4µs | our $VERSION = '0.23'; | ||
| 24 | 1 | 4µs | my $UndefMsg = q{Action for type '%s' not yet defined in library '%s'}; | ||
| 25 | |||||
| 26 | =head1 SYNOPSIS | ||||
| 27 | |||||
| - - | |||||
| 330 | # spent 52.4ms (890µs+51.5) within MooseX::Types::import which was called 2 times, avg 26.2ms/call:
# once (705µs+36.1ms) by Markdent::Types::Internal::BEGIN@11 at line 11 of Markdent/Types/Internal.pm
# once (185µs+15.4ms) by MooseX::Types::Moose::BEGIN@13 at line 13 of MooseX/Types/Moose.pm | ||||
| 331 | 18 | 406µs | my ($class, %args) = @_; | ||
| 332 | my $callee = caller; | ||||
| 333 | |||||
| 334 | # everyone should want this | ||||
| 335 | 2 | 24µs | strict->import; # spent 24µs making 2 calls to strict::import, avg 12µs/call | ||
| 336 | 2 | 136µs | warnings->import; # spent 136µs making 2 calls to warnings::import, avg 68µs/call | ||
| 337 | |||||
| 338 | # inject base class into new library | ||||
| 339 | 3 | 2.33ms | 2 | 181µs | # spent 111µs (42+69) within MooseX::Types::BEGIN@339 which was called:
# once (42µs+69µs) by Markdent::Types::Internal::BEGIN@11 at line 339 # spent 111µs making 1 call to MooseX::Types::BEGIN@339
# spent 70µs making 1 call to strict::unimport |
| 340 | 2 | 97µs | unshift @{ $callee . '::ISA' }, 'MooseX::Types::Base'; | ||
| 341 | } | ||||
| 342 | |||||
| 343 | # generate predeclared type helpers | ||||
| 344 | 4 | 64µs | if (my @orig_declare = @{ $args{ -declare } || [] }) { | ||
| 345 | 1 | 198µs | my ($tags, $declare) = filter_tags @orig_declare; # spent 198µs making 1 call to MooseX::Types::Util::filter_tags | ||
| 346 | my @to_export; | ||||
| 347 | |||||
| 348 | for my $type (@$declare) { | ||||
| 349 | |||||
| 350 | 27 | 286µs | 9 | 31µs | croak "Cannot create a type containing '::' ($type) at the moment" # spent 31µs making 9 calls to MooseX::Types::CORE:match, avg 3µs/call |
| 351 | if $type =~ /::/; | ||||
| 352 | |||||
| 353 | # add type to library and remember to export | ||||
| 354 | 9 | 425µs | $callee->add_type($type); # spent 425µs making 9 calls to MooseX::Types::Base::add_type, avg 47µs/call | ||
| 355 | push @to_export, $type; | ||||
| 356 | } | ||||
| 357 | |||||
| 358 | 1 | 19.1ms | $callee->import({ -full => 1, -into => $callee }, @to_export); # spent 19.1ms making 1 call to MooseX::Types::Base::import | ||
| 359 | } | ||||
| 360 | |||||
| 361 | # run type constraints import | ||||
| 362 | 2 | 16.4ms | Moose::Util::TypeConstraints->import({ into => $callee }); # spent 16.4ms making 2 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:456], avg 8.21ms/call | ||
| 363 | |||||
| 364 | # override some with versions that check for syntax errors | ||||
| 365 | 2 | 15.2ms | MooseX::Types::CheckedUtilExports->import({ into => $callee }); # spent 15.2ms making 2 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:456], avg 7.58ms/call | ||
| 366 | |||||
| 367 | 1; | ||||
| 368 | } | ||||
| 369 | |||||
| 370 | =head2 type_export_generator | ||||
| 371 | |||||
| - - | |||||
| 379 | # spent 3.69ms (2.57+1.12) within MooseX::Types::type_export_generator which was called 69 times, avg 53µs/call:
# 69 times (2.57ms+1.12ms) by MooseX::Types::Base::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/MooseX/Types/Base.pm:73] at line 71 of MooseX/Types/Base.pm, avg 53µs/call | ||||
| 380 | 138 | 3.87ms | my ($class, $type, $name) = @_; | ||
| 381 | |||||
| 382 | ## Return an anonymous subroutine that will generate the proxied type | ||||
| 383 | ## constraint for you. | ||||
| 384 | |||||
| 385 | return subname "__TYPE__::$name" => sub { | ||||
| 386 | 340 | 2.72ms | 68 | 10.5ms | my $type_constraint = $class->create_base_type_constraint($name); # spent 10.5ms making 68 calls to MooseX::Types::create_base_type_constraint, avg 154µs/call |
| 387 | |||||
| 388 | 6 | 202µs | if(defined(my $params = shift @_)) { | ||
| 389 | ## We currently only allow a TC to accept a single, ArrayRef | ||||
| 390 | ## parameter, as in HashRef[Int], where [Int] is what's inside the | ||||
| 391 | ## ArrayRef passed. | ||||
| 392 | 12 | 33.2ms | if(reftype $params eq 'ARRAY') { # spent 33.2ms making 6 calls to MooseX::Types::create_arged_type_constraint, avg 5.53ms/call
# spent 41µs making 6 calls to Scalar::Util::reftype, avg 7µs/call | ||
| 393 | $type_constraint = $class->create_arged_type_constraint($name, @$params); | ||||
| 394 | } elsif(!defined $type_constraint) { | ||||
| 395 | croak "Syntax error in type definition (did you forget a comma" | ||||
| 396 | . " after $type?)"; | ||||
| 397 | } else { | ||||
| 398 | croak "Argument must be an ArrayRef to create a parameterized " | ||||
| 399 | . "type, Eg.: ${type}[Int]. Got: ".ref($params)."." | ||||
| 400 | } | ||||
| 401 | } | ||||
| 402 | |||||
| 403 | 9 | 240µs | $type_constraint = defined($type_constraint) ? $type_constraint # spent 240µs making 9 calls to MooseX::Types::UndefinedType::new, avg 27µs/call | ||
| 404 | : MooseX::Types::UndefinedType->new($name); | ||||
| 405 | |||||
| 406 | 68 | 8.01ms | my $type_decorator = $class->create_type_decorator($type_constraint); # spent 8.01ms making 68 calls to MooseX::Types::create_type_decorator, avg 118µs/call | ||
| 407 | |||||
| 408 | ## If there are additional args, that means it's probably stuff that | ||||
| 409 | ## needs to be returned to the subtype. Not an ideal solution here but | ||||
| 410 | ## doesn't seem to cause trouble. | ||||
| 411 | |||||
| 412 | 63 | 1.13ms | if(@_) { | ||
| 413 | return ($type_decorator, @_); | ||||
| 414 | } else { | ||||
| 415 | return $type_decorator; | ||||
| 416 | } | ||||
| 417 | 69 | 1.12ms | }; # spent 1.12ms making 69 calls to Sub::Name::subname, avg 16µs/call | ||
| 418 | } | ||||
| 419 | |||||
| 420 | =head2 create_arged_type_constraint ($name, @args) | ||||
| 421 | |||||
| - - | |||||
| 427 | # spent 33.2ms (320µs+32.9) within MooseX::Types::create_arged_type_constraint which was called 6 times, avg 5.53ms/call:
# 6 times (320µs+32.9ms) by __TYPE__::ArrayRef or __TYPE__::HashRef at line 392, avg 5.53ms/call | ||||
| 428 | 24 | 298µs | my ($class, $name, @args) = @_; | ||
| 429 | 6 | 1.50ms | my $type_constraint = Moose::Util::TypeConstraints::find_or_create_type_constraint("$name"); # spent 1.50ms making 6 calls to Moose::Util::TypeConstraints::find_or_create_type_constraint, avg 250µs/call | ||
| 430 | 6 | 31.4ms | my $parameterized = $type_constraint->parameterize(@args); # spent 31.4ms making 6 calls to Moose::Meta::TypeConstraint::Parameterizable::parameterize, avg 5.23ms/call | ||
| 431 | # It's obnoxious to have to parameterize before looking for the TC, but the | ||||
| 432 | # alternative is to hard-code the assumption that the name is | ||||
| 433 | # "$name[$args[0]]", which would be worse. | ||||
| 434 | # This breaks MXMS, unfortunately, which relies on things like Tuple[...] | ||||
| 435 | # creating new type objects each time. | ||||
| 436 | # if (my $existing = | ||||
| 437 | # Moose::Util::TypeConstraints::find_type_constraint($parameterized->name)) { | ||||
| 438 | # return $existing; | ||||
| 439 | # } | ||||
| 440 | # Moose::Util::TypeConstraints::register_type_constraint($parameterized); | ||||
| 441 | return $parameterized; | ||||
| 442 | } | ||||
| 443 | |||||
| 444 | =head2 create_base_type_constraint ($name) | ||||
| 445 | |||||
| - - | |||||
| 450 | # spent 10.5ms (1.58+8.91) within MooseX::Types::create_base_type_constraint which was called 68 times, avg 154µs/call:
# 68 times (1.58ms+8.91ms) by __TYPE__::Any or __TYPE__::ArrayRef or __TYPE__::Bool or __TYPE__::ClassName or __TYPE__::HashRef or __TYPE__::Int or __TYPE__::Markdent::Types::Internal::BlockParserClass or __TYPE__::Markdent::Types::Internal::EventObject or __TYPE__::Markdent::Types::Internal::HandlerObject or __TYPE__::Markdent::Types::Internal::HeaderLevel or __TYPE__::Markdent::Types::Internal::NonEmptyArrayRef or __TYPE__::Markdent::Types::Internal::OutputStream or __TYPE__::Markdent::Types::Internal::PosInt or __TYPE__::Markdent::Types::Internal::SpanParserClass or __TYPE__::Markdent::Types::Internal::TableCellAlignment or __TYPE__::Object or __TYPE__::RegexpRef or __TYPE__::Str at line 386, avg 154µs/call | ||||
| 451 | 136 | 1.74ms | my ($class, $name) = @_; | ||
| 452 | 68 | 8.91ms | return find_type_constraint($name); # spent 8.91ms making 68 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 131µs/call | ||
| 453 | } | ||||
| 454 | |||||
| 455 | =head2 create_type_decorator ($type_constraint) | ||||
| 456 | |||||
| - - | |||||
| 462 | # spent 8.01ms (1.79+6.22) within MooseX::Types::create_type_decorator which was called 68 times, avg 118µs/call:
# 68 times (1.79ms+6.22ms) by __TYPE__::Any or __TYPE__::ArrayRef or __TYPE__::Bool or __TYPE__::ClassName or __TYPE__::HashRef or __TYPE__::Int or __TYPE__::Markdent::Types::Internal::BlockParserClass or __TYPE__::Markdent::Types::Internal::EventObject or __TYPE__::Markdent::Types::Internal::HandlerObject or __TYPE__::Markdent::Types::Internal::HeaderLevel or __TYPE__::Markdent::Types::Internal::NonEmptyArrayRef or __TYPE__::Markdent::Types::Internal::OutputStream or __TYPE__::Markdent::Types::Internal::PosInt or __TYPE__::Markdent::Types::Internal::SpanParserClass or __TYPE__::Markdent::Types::Internal::TableCellAlignment or __TYPE__::Object or __TYPE__::RegexpRef or __TYPE__::Str at line 406, avg 118µs/call | ||||
| 463 | 136 | 1.78ms | my ($class, $type_constraint) = @_; | ||
| 464 | 68 | 6.22ms | return MooseX::Types::TypeDecorator->new($type_constraint); # spent 6.22ms making 68 calls to MooseX::Types::TypeDecorator::new, avg 91µs/call | ||
| 465 | } | ||||
| 466 | |||||
| 467 | =head2 coercion_export_generator | ||||
| 468 | |||||
| - - | |||||
| 473 | # spent 249µs within MooseX::Types::coercion_export_generator which was called 9 times, avg 28µs/call:
# 9 times (249µs+0s) by MooseX::Types::Base::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/MooseX/Types/Base.pm:86] at line 86 of MooseX/Types/Base.pm, avg 28µs/call | ||||
| 474 | 18 | 301µs | my ($class, $type, $full, $undef_msg) = @_; | ||
| 475 | return sub { | ||||
| 476 | my ($value) = @_; | ||||
| 477 | |||||
| 478 | # we need a type object | ||||
| 479 | my $tobj = find_type_constraint($full) or croak $undef_msg; | ||||
| 480 | my $return = $tobj->coerce($value); | ||||
| 481 | |||||
| 482 | # non-successful coercion returns false | ||||
| 483 | return unless $tobj->check($return); | ||||
| 484 | |||||
| 485 | return $return; | ||||
| 486 | } | ||||
| 487 | } | ||||
| 488 | |||||
| 489 | =head2 check_export_generator | ||||
| 490 | |||||
| - - | |||||
| 495 | # spent 1.50ms within MooseX::Types::check_export_generator which was called 69 times, avg 22µs/call:
# 69 times (1.50ms+0s) by MooseX::Types::Base::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/MooseX/Types/Base.pm:78] at line 78 of MooseX/Types/Base.pm, avg 22µs/call | ||||
| 496 | 138 | 1.84ms | my ($class, $type, $full, $undef_msg) = @_; | ||
| 497 | return sub { | ||||
| 498 | my ($value) = @_; | ||||
| 499 | |||||
| 500 | # we need a type object | ||||
| 501 | my $tobj = find_type_constraint($full) or croak $undef_msg; | ||||
| 502 | |||||
| 503 | return $tobj->check($value); | ||||
| 504 | } | ||||
| 505 | } | ||||
| 506 | |||||
| 507 | =head1 CAVEATS | ||||
| 508 | |||||
| - - | |||||
| 611 | 1 | 56µs | 1 | 30.5ms | 1; # spent 30.5ms making 1 call to B::Hooks::EndOfScope::__ANON__[B/Hooks/EndOfScope.pm:26] |
# spent 31µs within MooseX::Types::CORE:match which was called 9 times, avg 3µs/call:
# 9 times (31µs+0s) by MooseX::Types::import at line 350, avg 3µs/call |