← Index
NYTProf Performance Profile   « block view • line view • sub view »
For bin/pan_genome_post_analysis
  Run on Fri Mar 27 11:43:32 2015
Reported on Fri Mar 27 11:46:03 2015

Filename/Users/ap13/perl5/lib/perl5/darwin-2level/Moose/Meta/TypeConstraint/Class.pm
StatementsExecuted 443 statements in 2.05ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
8311733µs1.14msMoose::Meta::TypeConstraint::Class::::__ANON__[:25]Moose::Meta::TypeConstraint::Class::__ANON__[:25]
2211600µs13.9msMoose::Meta::TypeConstraint::Class::::newMoose::Meta::TypeConstraint::Class::new
11121µs43µsMoose::Meta::TypeConstraint::Class::::BEGIN@8Moose::Meta::TypeConstraint::Class::BEGIN@8
11115µs32µsMoose::Meta::TypeConstraint::Class::::BEGIN@4Moose::Meta::TypeConstraint::Class::BEGIN@4
1119µs15µsMoose::Meta::TypeConstraint::Class::::BEGIN@5Moose::Meta::TypeConstraint::Class::BEGIN@5
1117µs33µsMoose::Meta::TypeConstraint::Class::::BEGIN@12Moose::Meta::TypeConstraint::Class::BEGIN@12
1117µs508µsMoose::Meta::TypeConstraint::Class::::BEGIN@6Moose::Meta::TypeConstraint::Class::BEGIN@6
1113µs3µsMoose::Meta::TypeConstraint::Class::::BEGIN@10Moose::Meta::TypeConstraint::Class::BEGIN@10
1113µs3µsMoose::Meta::TypeConstraint::Class::::BEGIN@9Moose::Meta::TypeConstraint::Class::BEGIN@9
0000s0sMoose::Meta::TypeConstraint::Class::::__ANON__[:34]Moose::Meta::TypeConstraint::Class::__ANON__[:34]
0000s0sMoose::Meta::TypeConstraint::Class::::create_child_typeMoose::Meta::TypeConstraint::Class::create_child_type
0000s0sMoose::Meta::TypeConstraint::Class::::equalsMoose::Meta::TypeConstraint::Class::equals
0000s0sMoose::Meta::TypeConstraint::Class::::get_messageMoose::Meta::TypeConstraint::Class::get_message
0000s0sMoose::Meta::TypeConstraint::Class::::is_a_type_ofMoose::Meta::TypeConstraint::Class::is_a_type_of
0000s0sMoose::Meta::TypeConstraint::Class::::is_subtype_ofMoose::Meta::TypeConstraint::Class::is_subtype_of
0000s0sMoose::Meta::TypeConstraint::Class::::parentsMoose::Meta::TypeConstraint::Class::parents
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Moose::Meta::TypeConstraint::Class;
21800nsour $VERSION = '2.1403';
3
4224µs248µs
# spent 32µs (15+17) within Moose::Meta::TypeConstraint::Class::BEGIN@4 which was called: # once (15µs+17µs) by Moose::Util::TypeConstraints::BEGIN@28 at line 4
use strict;
# spent 32µs making 1 call to Moose::Meta::TypeConstraint::Class::BEGIN@4 # spent 17µs making 1 call to strict::import
5220µs221µs
# spent 15µs (9+6) within Moose::Meta::TypeConstraint::Class::BEGIN@5 which was called: # once (9µs+6µs) by Moose::Util::TypeConstraints::BEGIN@28 at line 5
use warnings;
# spent 15µs making 1 call to Moose::Meta::TypeConstraint::Class::BEGIN@5 # spent 6µs making 1 call to warnings::import
6240µs21.01ms
# spent 508µs (7+501) within Moose::Meta::TypeConstraint::Class::BEGIN@6 which was called: # once (7µs+501µs) by Moose::Util::TypeConstraints::BEGIN@28 at line 6
use metaclass;
# spent 508µs making 1 call to Moose::Meta::TypeConstraint::Class::BEGIN@6 # spent 501µs making 1 call to metaclass::import
7
8226µs265µs
# spent 43µs (21+22) within Moose::Meta::TypeConstraint::Class::BEGIN@8 which was called: # once (21µs+22µs) by Moose::Util::TypeConstraints::BEGIN@28 at line 8
use B;
# spent 43µs making 1 call to Moose::Meta::TypeConstraint::Class::BEGIN@8 # spent 22µs making 1 call to Exporter::import
9224µs13µs
# spent 3µs within Moose::Meta::TypeConstraint::Class::BEGIN@9 which was called: # once (3µs+0s) by Moose::Util::TypeConstraints::BEGIN@28 at line 9
use Scalar::Util ();
# spent 3µs making 1 call to Moose::Meta::TypeConstraint::Class::BEGIN@9
10223µs13µs
# spent 3µs within Moose::Meta::TypeConstraint::Class::BEGIN@10 which was called: # once (3µs+0s) by Moose::Util::TypeConstraints::BEGIN@28 at line 10
use Moose::Util::TypeConstraints ();
# spent 3µs making 1 call to Moose::Meta::TypeConstraint::Class::BEGIN@10
11
122548µs258µs
# spent 33µs (7+25) within Moose::Meta::TypeConstraint::Class::BEGIN@12 which was called: # once (7µs+25µs) by Moose::Util::TypeConstraints::BEGIN@28 at line 12
use parent 'Moose::Meta::TypeConstraint';
# spent 33µs making 1 call to Moose::Meta::TypeConstraint::Class::BEGIN@12 # spent 25µs making 1 call to parent::import
13
1416µs3351µs__PACKAGE__->meta->add_attribute('class' => (
# spent 328µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 17µs making 1 call to Moose::Meta::TypeConstraint::Class::meta # spent 6µs making 1 call to Class::MOP::_definition_context
15 reader => 'class',
16 Class::MOP::_definition_context(),
17));
18
19
# spent 1.14ms (733µs+407µs) within Moose::Meta::TypeConstraint::Class::__ANON__[/Users/ap13/perl5/lib/perl5/darwin-2level/Moose/Meta/TypeConstraint/Class.pm:25] which was called 83 times, avg 14µs/call: # 83 times (733µs+407µs) by Moose::Meta::TypeConstraint::_inline_check at line 195 of Moose/Meta/TypeConstraint.pm, avg 14µs/call
my $inliner = sub {
208324µs my $self = shift;
218324µs my $val = shift;
22
2383781µs166407µs return 'Scalar::Util::blessed(' . $val . ')'
# spent 224µs making 83 calls to B::perlstring, avg 3µs/call # spent 184µs making 83 calls to Moose::Meta::TypeConstraint::Class::class, avg 2µs/call
24 . ' && ' . $val . '->isa(' . B::perlstring($self->class) . ')';
2512µs};
26
27
# spent 13.9ms (600µs+13.3) within Moose::Meta::TypeConstraint::Class::new which was called 22 times, avg 634µs/call: # 22 times (600µs+13.3ms) by Moose::Util::TypeConstraints::create_class_type_constraint at line 176 of Moose/Util/TypeConstraints.pm, avg 634µs/call
sub new {
282245µs my ( $class, %args ) = @_;
29
302237µs22412µs $args{parent}
# spent 412µs making 22 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 19µs/call
31 = Moose::Util::TypeConstraints::find_type_constraint('Object');
32
332214µs my $class_name = $args{class};
342276µs $args{constraint} = sub { $_[0]->isa($class_name) };
35
362216µs $args{inlined} = $inliner;
37
3822177µs228.25ms my $self = $class->SUPER::new( \%args );
# spent 8.25ms making 22 calls to Moose::Meta::TypeConstraint::new, avg 375µs/call
39
402249µs224.68ms $self->compile_type_constraint();
# spent 4.68ms making 22 calls to Moose::Meta::TypeConstraint::compile_type_constraint, avg 213µs/call
41
422289µs return $self;
43}
44
45sub parents {
46 my $self = shift;
47 return (
48 $self->parent,
49 map {
50 # FIXME find_type_constraint might find a TC named after the class but that isn't really it
51 # I did this anyway since it's a convention that preceded TypeConstraint::Class, and it should DWIM
52 # if anybody thinks this problematic please discuss on IRC.
53 # a possible fix is to add by attr indexing to the type registry to find types of a certain property
54 # regardless of their name
55 Moose::Util::TypeConstraints::find_type_constraint($_)
56 ||
57 __PACKAGE__->new( class => $_, name => "__ANON__" )
58 } Class::MOP::class_of($self->class)->superclasses,
59 );
60}
61
62sub equals {
63 my ( $self, $type_or_name ) = @_;
64
65 my $other = Moose::Util::TypeConstraints::find_type_constraint($type_or_name);
66
67 if (!defined($other)) {
68 if (!ref($type_or_name)) {
69 return $self->class eq $type_or_name;
70 }
71 return;
72 }
73
74 return unless $other->isa(__PACKAGE__);
75
76 return $self->class eq $other->class;
77}
78
79sub is_a_type_of {
80 my ($self, $type_or_name) = @_;
81
82 ($self->equals($type_or_name) || $self->is_subtype_of($type_or_name));
83}
84
85sub is_subtype_of {
86 my ($self, $type_or_name_or_class ) = @_;
87
88 my $type = Moose::Util::TypeConstraints::find_type_constraint($type_or_name_or_class);
89
90 if ( not defined $type ) {
91 if ( not ref $type_or_name_or_class ) {
92 # it might be a class
93 my $class = $self->class;
94 return 1 if $class ne $type_or_name_or_class
95 && $class->isa( $type_or_name_or_class );
96 }
97 return;
98 }
99
100 if ( $type->isa(__PACKAGE__) && $type->class ne $self->class) {
101 # if $type_or_name_or_class isn't a class, it might be the TC name of another ::Class type
102 # or it could also just be a type object in this branch
103 return $self->class->isa( $type->class );
104 } else {
105 # the only other thing we are a subtype of is Object
106 $self->SUPER::is_subtype_of($type);
107 }
108}
109
110# This is a bit counter-intuitive, but a child type of a Class type
111# constraint is not itself a Class type constraint (it has no class
112# attribute). This whole create_child_type thing needs some changing
113# though, probably making MMC->new a factory or something.
114sub create_child_type {
115 my ($self, @args) = @_;
116 return Moose::Meta::TypeConstraint->new(@args, parent => $self);
117}
118
119sub get_message {
120 my $self = shift;
121 my ($value) = @_;
122
123 if ($self->has_message) {
124 return $self->SUPER::get_message(@_);
125 }
126
127 $value = (defined $value ? overload::StrVal($value) : 'undef');
128 return "Validation failed for '" . $self->name . "' with value $value (not isa " . $self->class . ")";
129}
130
13117µs1;
132
133# ABSTRACT: Class/TypeConstraint parallel hierarchy
134
135__END__