← Index
NYTProf Performance Profile   « block view • line view • sub view »
For -e
  Run on Wed Nov 17 22:00:36 2010
Reported on Wed Nov 17 22:10:03 2010

Filename/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/MooseX/Types.pm
StatementsExecuted 1092 statements in 21.6ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1117.40ms1.28sMooseX::Types::::BEGIN@2MooseX::Types::BEGIN@2
1115.40ms78.0msMooseX::Types::::BEGIN@12MooseX::Types::BEGIN@12
1114.47ms11.4msMooseX::Types::::BEGIN@11MooseX::Types::BEGIN@11
69112.49ms3.56msMooseX::Types::::type_export_generatorMooseX::Types::type_export_generator
1112.22ms9.69msMooseX::Types::::BEGIN@15MooseX::Types::BEGIN@15
1111.88ms2.71msMooseX::Types::::BEGIN@14MooseX::Types::BEGIN@14
68111.72ms7.97msMooseX::Types::::create_type_decoratorMooseX::Types::create_type_decorator
69111.59ms1.59msMooseX::Types::::check_export_generatorMooseX::Types::check_export_generator
68111.59ms10.8msMooseX::Types::::create_base_type_constraintMooseX::Types::create_base_type_constraint
222886µs50.8msMooseX::Types::::importMooseX::Types::import
611319µs33.5msMooseX::Types::::create_arged_type_constraintMooseX::Types::create_arged_type_constraint
911168µs168µsMooseX::Types::::coercion_export_generatorMooseX::Types::coercion_export_generator
111144µs144µsMooseX::Types::::BEGIN@22MooseX::Types::BEGIN@22
11157µs127µsMooseX::Types::::BEGIN@339MooseX::Types::BEGIN@339
11145µs9.92msMooseX::Types::::BEGIN@10MooseX::Types::BEGIN@10
11145µs3.21msMooseX::Types::::BEGIN@20MooseX::Types::BEGIN@20
11144µs200µsMooseX::Types::::BEGIN@17MooseX::Types::BEGIN@17
11143µs426µsMooseX::Types::::BEGIN@16MooseX::Types::BEGIN@16
11141µs204µsMooseX::Types::::BEGIN@13MooseX::Types::BEGIN@13
11137µs182µsMooseX::Types::::BEGIN@18MooseX::Types::BEGIN@18
91131µs31µsMooseX::Types::::CORE:matchMooseX::Types::CORE:match (opcode)
0000s0sMooseX::Types::::__ANON__[:417]MooseX::Types::__ANON__[:417]
0000s0sMooseX::Types::::__ANON__[:486]MooseX::Types::__ANON__[:486]
0000s0sMooseX::Types::::__ANON__[:504]MooseX::Types::__ANON__[:504]
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;
23451µs21.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
use Moose;
# 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
- -
103152µs219.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
use Moose::Util::TypeConstraints;
# 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]
113756µs111.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
use MooseX::Types::TypeDecorator;
# spent 11.4ms making 1 call to MooseX::Types::BEGIN@11
123641µs178.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
use MooseX::Types::Base ();
# spent 78.0ms making 1 call to MooseX::Types::BEGIN@12
133107µs2367µ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
use MooseX::Types::Util qw( filter_tags );
# spent 204µs making 1 call to MooseX::Types::BEGIN@13 # spent 163µs making 1 call to Exporter::import
143693µs12.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
use MooseX::Types::UndefinedType;
# spent 2.71ms making 1 call to MooseX::Types::BEGIN@14
153668µs19.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
use MooseX::Types::CheckedUtilExports ();
# spent 9.69ms making 1 call to MooseX::Types::BEGIN@15
163127µs2808µ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
use Carp::Clan qw( ^MooseX::Types );
# spent 426µs making 1 call to MooseX::Types::BEGIN@16 # spent 382µs making 1 call to Carp::Clan::import
173112µs2356µ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
use Sub::Name;
# spent 200µs making 1 call to MooseX::Types::BEGIN@17 # spent 156µs making 1 call to Exporter::import
183126µs2326µ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
use Scalar::Util 'reftype';
# spent 182µs making 1 call to MooseX::Types::BEGIN@18 # spent 144µs making 1 call to Exporter::import
19
203135µs26.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
use namespace::clean -except => [qw( meta )];
# spent 3.21ms making 1 call to MooseX::Types::BEGIN@20 # spent 3.17ms making 1 call to namespace::clean::import
21
223575µs1144µ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
use 5.008;
# spent 144µs making 1 call to MooseX::Types::BEGIN@22
2314µsour $VERSION = '0.23';
2414µsmy $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
sub import {
33151847µs my ($class, %args) = @_;
332 my $callee = caller;
333
334 # everyone should want this
335226µs strict->import;
# spent 26µs making 2 calls to strict::import, avg 13µs/call
3362136µs warnings->import;
# spent 136µs making 2 calls to warnings::import, avg 68µs/call
337
338 # inject base class into new library
33932.36ms2196µ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
{ no strict 'refs';
# 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 } || [] }) {
3451198µ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
350931µ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
3549422µ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
358118.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
362216.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
365214.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
sub type_export_generator {
3801383.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 {
3864094.07ms6810.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.
3921233.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
4039262µ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
406687.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 }
417691.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
sub create_arged_type_constraint {
42824300µs my ($class, $name, @args) = @_;
42961.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
430631.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
sub create_base_type_constraint {
4511361.76ms my ($class, $name) = @_;
452689.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
sub create_type_decorator {
4631361.76ms my ($class, $type_constraint) = @_;
464686.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
sub coercion_export_generator {
47418214µ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
sub check_export_generator {
4961381.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
- -
611156µs112.0ms1;
 
# 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
sub MooseX::Types::CORE:match; # opcode