| 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.6ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 7.40ms | 1.28s | MooseX::Types::BEGIN@2 |
| 1 | 1 | 1 | 5.40ms | 78.0ms | MooseX::Types::BEGIN@12 |
| 1 | 1 | 1 | 4.47ms | 11.4ms | MooseX::Types::BEGIN@11 |
| 69 | 1 | 1 | 2.49ms | 3.56ms | MooseX::Types::type_export_generator |
| 1 | 1 | 1 | 2.22ms | 9.69ms | MooseX::Types::BEGIN@15 |
| 1 | 1 | 1 | 1.88ms | 2.71ms | MooseX::Types::BEGIN@14 |
| 68 | 1 | 1 | 1.72ms | 7.97ms | MooseX::Types::create_type_decorator |
| 69 | 1 | 1 | 1.59ms | 1.59ms | MooseX::Types::check_export_generator |
| 68 | 1 | 1 | 1.59ms | 10.8ms | MooseX::Types::create_base_type_constraint |
| 2 | 2 | 2 | 886µs | 50.8ms | MooseX::Types::import |
| 6 | 1 | 1 | 319µs | 33.5ms | MooseX::Types::create_arged_type_constraint |
| 9 | 1 | 1 | 168µs | 168µs | MooseX::Types::coercion_export_generator |
| 1 | 1 | 1 | 144µs | 144µs | MooseX::Types::BEGIN@22 |
| 1 | 1 | 1 | 57µs | 127µs | MooseX::Types::BEGIN@339 |
| 1 | 1 | 1 | 45µs | 9.92ms | MooseX::Types::BEGIN@10 |
| 1 | 1 | 1 | 45µs | 3.21ms | MooseX::Types::BEGIN@20 |
| 1 | 1 | 1 | 44µs | 200µs | MooseX::Types::BEGIN@17 |
| 1 | 1 | 1 | 43µs | 426µs | MooseX::Types::BEGIN@16 |
| 1 | 1 | 1 | 41µs | 204µs | MooseX::Types::BEGIN@13 |
| 1 | 1 | 1 | 37µs | 182µs | MooseX::Types::BEGIN@18 |
| 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 | 451µs | 2 | 1.30s | # spent 1.28s (7.40ms+1.27) within MooseX::Types::BEGIN@2 which was called:
# once (7.40ms+1.27s) by Markdent::Types::Internal::BEGIN@11 at line 2 # spent 1.28s making 1 call to MooseX::Types::BEGIN@2
# spent 23.8ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:456] |
| 3 | |||||
| 4 | =head1 NAME | ||||
| 5 | |||||
| - - | |||||
| 10 | 3 | 152µs | 2 | 19.8ms | # spent 9.92ms (45µs+9.88) within MooseX::Types::BEGIN@10 which was called:
# once (45µs+9.88ms) by Markdent::Types::Internal::BEGIN@11 at line 10 # spent 9.92ms making 1 call to MooseX::Types::BEGIN@10
# spent 9.88ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:456] |
| 11 | 3 | 756µs | 1 | 11.4ms | # spent 11.4ms (4.47+6.97) within MooseX::Types::BEGIN@11 which was called:
# once (4.47ms+6.97ms) by Markdent::Types::Internal::BEGIN@11 at line 11 # spent 11.4ms making 1 call to MooseX::Types::BEGIN@11 |
| 12 | 3 | 641µs | 1 | 78.0ms | # spent 78.0ms (5.40+72.6) within MooseX::Types::BEGIN@12 which was called:
# once (5.40ms+72.6ms) by Markdent::Types::Internal::BEGIN@11 at line 12 # spent 78.0ms making 1 call to MooseX::Types::BEGIN@12 |
| 13 | 3 | 107µs | 2 | 367µs | # spent 204µs (41+163) within MooseX::Types::BEGIN@13 which was called:
# once (41µs+163µs) by Markdent::Types::Internal::BEGIN@11 at line 13 # spent 204µs making 1 call to MooseX::Types::BEGIN@13
# spent 163µs making 1 call to Exporter::import |
| 14 | 3 | 693µs | 1 | 2.71ms | # spent 2.71ms (1.88+827µs) within MooseX::Types::BEGIN@14 which was called:
# once (1.88ms+827µs) by Markdent::Types::Internal::BEGIN@11 at line 14 # spent 2.71ms making 1 call to MooseX::Types::BEGIN@14 |
| 15 | 3 | 668µs | 1 | 9.69ms | # spent 9.69ms (2.22+7.48) within MooseX::Types::BEGIN@15 which was called:
# once (2.22ms+7.48ms) by Markdent::Types::Internal::BEGIN@11 at line 15 # spent 9.69ms making 1 call to MooseX::Types::BEGIN@15 |
| 16 | 3 | 127µs | 2 | 808µs | # spent 426µs (43+382) within MooseX::Types::BEGIN@16 which was called:
# once (43µs+382µs) by Markdent::Types::Internal::BEGIN@11 at line 16 # spent 426µs making 1 call to MooseX::Types::BEGIN@16
# spent 382µs making 1 call to Carp::Clan::import |
| 17 | 3 | 112µs | 2 | 356µs | # spent 200µs (44+156) within MooseX::Types::BEGIN@17 which was called:
# once (44µs+156µs) by Markdent::Types::Internal::BEGIN@11 at line 17 # spent 200µs making 1 call to MooseX::Types::BEGIN@17
# spent 156µs making 1 call to Exporter::import |
| 18 | 3 | 126µs | 2 | 326µs | # spent 182µs (37+144) within MooseX::Types::BEGIN@18 which was called:
# once (37µs+144µs) by Markdent::Types::Internal::BEGIN@11 at line 18 # spent 182µs making 1 call to MooseX::Types::BEGIN@18
# spent 144µs making 1 call to Exporter::import |
| 19 | |||||
| 20 | 3 | 135µs | 2 | 6.38ms | # spent 3.21ms (45µs+3.17) within MooseX::Types::BEGIN@20 which was called:
# once (45µs+3.17ms) by Markdent::Types::Internal::BEGIN@11 at line 20 # spent 3.21ms making 1 call to MooseX::Types::BEGIN@20
# spent 3.17ms making 1 call to namespace::clean::import |
| 21 | |||||
| 22 | 3 | 575µs | 1 | 144µs | # spent 144µs within MooseX::Types::BEGIN@22 which was called:
# once (144µs+0s) by Markdent::Types::Internal::BEGIN@11 at line 22 # spent 144µ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 50.8ms (886µs+50.0) within MooseX::Types::import which was called 2 times, avg 25.4ms/call:
# once (705µs+34.7ms) by Markdent::Types::Internal::BEGIN@11 at line 11 of Markdent/Types/Internal.pm
# once (181µs+15.3ms) by MooseX::Types::Moose::BEGIN@13 at line 13 of MooseX/Types/Moose.pm | ||||
| 331 | 51 | 847µs | my ($class, %args) = @_; | ||
| 332 | my $callee = caller; | ||||
| 333 | |||||
| 334 | # everyone should want this | ||||
| 335 | 2 | 26µs | strict->import; # spent 26µs making 2 calls to strict::import, avg 13µ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.36ms | 2 | 196µs | # spent 127µs (57+69) within MooseX::Types::BEGIN@339 which was called:
# once (57µs+69µs) by Markdent::Types::Internal::BEGIN@11 at line 339 # spent 127µs making 1 call to MooseX::Types::BEGIN@339
# spent 70µs making 1 call to strict::unimport |
| 340 | unshift @{ $callee . '::ISA' }, 'MooseX::Types::Base'; | ||||
| 341 | } | ||||
| 342 | |||||
| 343 | # generate predeclared type helpers | ||||
| 344 | 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 | 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 | 422µs | $callee->add_type($type); # spent 422µs making 9 calls to MooseX::Types::Base::add_type, avg 47µs/call | ||
| 355 | push @to_export, $type; | ||||
| 356 | } | ||||
| 357 | |||||
| 358 | 1 | 18.6ms | $callee->import({ -full => 1, -into => $callee }, @to_export); # spent 18.6ms 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.18ms/call | ||
| 363 | |||||
| 364 | # override some with versions that check for syntax errors | ||||
| 365 | 2 | 14.2ms | MooseX::Types::CheckedUtilExports->import({ into => $callee }); # spent 14.2ms making 2 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:456], avg 7.08ms/call | ||
| 366 | |||||
| 367 | 1; | ||||
| 368 | } | ||||
| 369 | |||||
| 370 | =head2 type_export_generator | ||||
| 371 | |||||
| - - | |||||
| 379 | # spent 3.56ms (2.49+1.07) within MooseX::Types::type_export_generator which was called 69 times, avg 52µs/call:
# 69 times (2.49ms+1.07ms) 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 52µs/call | ||||
| 380 | 138 | 3.75ms | 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 | 409 | 4.07ms | 68 | 10.8ms | my $type_constraint = $class->create_base_type_constraint($name); # spent 10.8ms making 68 calls to MooseX::Types::create_base_type_constraint, avg 160µs/call |
| 387 | |||||
| 388 | 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.6ms | if(reftype $params eq 'ARRAY') { # spent 33.5ms making 6 calls to MooseX::Types::create_arged_type_constraint, avg 5.59ms/call
# spent 43µ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 | 262µs | $type_constraint = defined($type_constraint) ? $type_constraint # spent 262µs making 9 calls to MooseX::Types::UndefinedType::new, avg 29µs/call | ||
| 404 | : MooseX::Types::UndefinedType->new($name); | ||||
| 405 | |||||
| 406 | 68 | 7.97ms | my $type_decorator = $class->create_type_decorator($type_constraint); # spent 7.97ms making 68 calls to MooseX::Types::create_type_decorator, avg 117µ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 | if(@_) { | ||||
| 413 | return ($type_decorator, @_); | ||||
| 414 | } else { | ||||
| 415 | return $type_decorator; | ||||
| 416 | } | ||||
| 417 | 69 | 1.07ms | }; # spent 1.07ms making 69 calls to Sub::Name::subname, avg 15µs/call | ||
| 418 | } | ||||
| 419 | |||||
| 420 | =head2 create_arged_type_constraint ($name, @args) | ||||
| 421 | |||||
| - - | |||||
| 427 | # spent 33.5ms (319µs+33.2) within MooseX::Types::create_arged_type_constraint which was called 6 times, avg 5.59ms/call:
# 6 times (319µs+33.2ms) by __TYPE__::ArrayRef or __TYPE__::HashRef at line 392, avg 5.59ms/call | ||||
| 428 | 24 | 300µs | my ($class, $name, @args) = @_; | ||
| 429 | 6 | 1.58ms | my $type_constraint = Moose::Util::TypeConstraints::find_or_create_type_constraint("$name"); # spent 1.58ms making 6 calls to Moose::Util::TypeConstraints::find_or_create_type_constraint, avg 264µs/call | ||
| 430 | 6 | 31.6ms | my $parameterized = $type_constraint->parameterize(@args); # spent 31.6ms making 6 calls to Moose::Meta::TypeConstraint::Parameterizable::parameterize, avg 5.27ms/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.8ms (1.59+9.26) within MooseX::Types::create_base_type_constraint which was called 68 times, avg 160µs/call:
# 68 times (1.59ms+9.26ms) 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 160µs/call | ||||
| 451 | 136 | 1.76ms | my ($class, $name) = @_; | ||
| 452 | 68 | 9.26ms | return find_type_constraint($name); # spent 9.26ms making 68 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 136µs/call | ||
| 453 | } | ||||
| 454 | |||||
| 455 | =head2 create_type_decorator ($type_constraint) | ||||
| 456 | |||||
| - - | |||||
| 462 | # spent 7.97ms (1.72+6.25) within MooseX::Types::create_type_decorator which was called 68 times, avg 117µs/call:
# 68 times (1.72ms+6.25ms) 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 117µs/call | ||||
| 463 | 136 | 1.76ms | my ($class, $type_constraint) = @_; | ||
| 464 | 68 | 6.25ms | return MooseX::Types::TypeDecorator->new($type_constraint); # spent 6.25ms making 68 calls to MooseX::Types::TypeDecorator::new, avg 92µs/call | ||
| 465 | } | ||||
| 466 | |||||
| 467 | =head2 coercion_export_generator | ||||
| 468 | |||||
| - - | |||||
| 473 | # spent 168µs within MooseX::Types::coercion_export_generator which was called 9 times, avg 19µs/call:
# 9 times (168µ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 19µs/call | ||||
| 474 | 18 | 214µ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.59ms within MooseX::Types::check_export_generator which was called 69 times, avg 23µs/call:
# 69 times (1.59ms+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 23µs/call | ||||
| 496 | 138 | 1.91ms | 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 | 12.0ms | 1; # spent 12.0ms 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 |