← 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:13:28 2010

Filename/home/doy/coding/src/Moose/blib/lib//Moose/Meta/TypeConstraint/DuckType.pm
StatementsExecuted 29 statements in 2.79ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11172µs90µsMoose::Meta::TypeConstraint::DuckType::::BEGIN@3Moose::Meta::TypeConstraint::DuckType::BEGIN@3
11141µs203µsMoose::Meta::TypeConstraint::DuckType::::BEGIN@7Moose::Meta::TypeConstraint::DuckType::BEGIN@7
11141µs1.01msMoose::Meta::TypeConstraint::DuckType::::BEGIN@9Moose::Meta::TypeConstraint::DuckType::BEGIN@9
11140µs171µsMoose::Meta::TypeConstraint::DuckType::::BEGIN@8Moose::Meta::TypeConstraint::DuckType::BEGIN@8
11140µs307µsMoose::Meta::TypeConstraint::DuckType::::BEGIN@17Moose::Meta::TypeConstraint::DuckType::BEGIN@17
11139µs106µsMoose::Meta::TypeConstraint::DuckType::::BEGIN@4Moose::Meta::TypeConstraint::DuckType::BEGIN@4
11138µs2.71msMoose::Meta::TypeConstraint::DuckType::::BEGIN@5Moose::Meta::TypeConstraint::DuckType::BEGIN@5
11124µs24µsMoose::Meta::TypeConstraint::DuckType::::BEGIN@11Moose::Meta::TypeConstraint::DuckType::BEGIN@11
0000s0sMoose::Meta::TypeConstraint::DuckType::::__ANON__[:65]Moose::Meta::TypeConstraint::DuckType::__ANON__[:65]
0000s0sMoose::Meta::TypeConstraint::DuckType::::__ANON__[:66]Moose::Meta::TypeConstraint::DuckType::__ANON__[:66]
0000s0sMoose::Meta::TypeConstraint::DuckType::::__ANON__[:79]Moose::Meta::TypeConstraint::DuckType::__ANON__[:79]
0000s0sMoose::Meta::TypeConstraint::DuckType::::__ANON__[:80]Moose::Meta::TypeConstraint::DuckType::__ANON__[:80]
0000s0sMoose::Meta::TypeConstraint::DuckType::::_compile_hand_optimized_type_constraintMoose::Meta::TypeConstraint::DuckType::_compile_hand_optimized_type_constraint
0000s0sMoose::Meta::TypeConstraint::DuckType::::constraintMoose::Meta::TypeConstraint::DuckType::constraint
0000s0sMoose::Meta::TypeConstraint::DuckType::::create_child_typeMoose::Meta::TypeConstraint::DuckType::create_child_type
0000s0sMoose::Meta::TypeConstraint::DuckType::::equalsMoose::Meta::TypeConstraint::DuckType::equals
0000s0sMoose::Meta::TypeConstraint::DuckType::::get_messageMoose::Meta::TypeConstraint::DuckType::get_message
0000s0sMoose::Meta::TypeConstraint::DuckType::::newMoose::Meta::TypeConstraint::DuckType::new
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::DuckType;
2
33107µs2109µs
# spent 90µs (72+18) within Moose::Meta::TypeConstraint::DuckType::BEGIN@3 which was called: # once (72µs+18µs) by Moose::Util::TypeConstraints::BEGIN@36 at line 3
use strict;
# spent 90µs making 1 call to Moose::Meta::TypeConstraint::DuckType::BEGIN@3 # spent 18µs making 1 call to strict::import
4396µs2173µs
# spent 106µs (39+67) within Moose::Meta::TypeConstraint::DuckType::BEGIN@4 which was called: # once (39µs+67µs) by Moose::Util::TypeConstraints::BEGIN@36 at line 4
use warnings;
# spent 106µs making 1 call to Moose::Meta::TypeConstraint::DuckType::BEGIN@4 # spent 67µs making 1 call to warnings::import
53142µs25.39ms
# spent 2.71ms (38µs+2.68) within Moose::Meta::TypeConstraint::DuckType::BEGIN@5 which was called: # once (38µs+2.68ms) by Moose::Util::TypeConstraints::BEGIN@36 at line 5
use metaclass;
# spent 2.71ms making 1 call to Moose::Meta::TypeConstraint::DuckType::BEGIN@5 # spent 2.68ms making 1 call to metaclass::import
6
73115µs2365µs
# spent 203µs (41+162) within Moose::Meta::TypeConstraint::DuckType::BEGIN@7 which was called: # once (41µs+162µs) by Moose::Util::TypeConstraints::BEGIN@36 at line 7
use Scalar::Util 'blessed';
# spent 203µs making 1 call to Moose::Meta::TypeConstraint::DuckType::BEGIN@7 # spent 162µs making 1 call to Exporter::import
83131µs2302µs
# spent 171µs (40+131) within Moose::Meta::TypeConstraint::DuckType::BEGIN@8 which was called: # once (40µs+131µs) by Moose::Util::TypeConstraints::BEGIN@36 at line 8
use List::MoreUtils qw(all);
# spent 171µs making 1 call to Moose::Meta::TypeConstraint::DuckType::BEGIN@8 # spent 131µs making 1 call to Exporter::import
93141µs21.98ms
# spent 1.01ms (41µs+970µs) within Moose::Meta::TypeConstraint::DuckType::BEGIN@9 which was called: # once (41µs+970µs) by Moose::Util::TypeConstraints::BEGIN@36 at line 9
use Moose::Util 'english_list';
# spent 1.01ms making 1 call to Moose::Meta::TypeConstraint::DuckType::BEGIN@9 # spent 970µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756]
10
113209µs124µs
# spent 24µs within Moose::Meta::TypeConstraint::DuckType::BEGIN@11 which was called: # once (24µs+0s) by Moose::Util::TypeConstraints::BEGIN@36 at line 11
use Moose::Util::TypeConstraints ();
12
1316µsour $VERSION = '1.19';
14166µs$VERSION = eval $VERSION;
# spent 12µs executing statements in string eval
1514µsour $AUTHORITY = 'cpan:STEVAN';
16
1731.73ms2573µs
# spent 307µs (40+266) within Moose::Meta::TypeConstraint::DuckType::BEGIN@17 which was called: # once (40µs+266µs) by Moose::Util::TypeConstraints::BEGIN@36 at line 17
use base 'Moose::Meta::TypeConstraint';
# spent 307µs making 1 call to Moose::Meta::TypeConstraint::DuckType::BEGIN@17 # spent 266µs making 1 call to base::import
18
19128µs22.14ms__PACKAGE__->meta->add_attribute('methods' => (
# spent 2.02ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 122µs making 1 call to Moose::Meta::TypeConstraint::DuckType::meta
20 accessor => 'methods',
21));
22
23sub new {
24 my ( $class, %args ) = @_;
25
26 $args{parent} = Moose::Util::TypeConstraints::find_type_constraint('Object');
27
28 my $self = $class->_new(\%args);
29
30 $self->compile_type_constraint()
31 unless $self->_has_compiled_type_constraint;
32
33 return $self;
34}
35
36sub equals {
37 my ( $self, $type_or_name ) = @_;
38
39 my $other = Moose::Util::TypeConstraints::find_type_constraint($type_or_name);
40
41 return unless $other->isa(__PACKAGE__);
42
43 my @self_methods = sort @{ $self->methods };
44 my @other_methods = sort @{ $other->methods };
45
46 return unless @self_methods == @other_methods;
47
48 while ( @self_methods ) {
49 my $method = shift @self_methods;
50 my $other_method = shift @other_methods;
51
52 return unless $method eq $other_method;
53 }
54
55 return 1;
56}
57
58sub constraint {
59 my $self = shift;
60
61 my @methods = @{ $self->methods };
62
63 return sub {
64 my $obj = shift;
65 return all { $obj->can($_) } @methods
66 };
67}
68
69sub _compile_hand_optimized_type_constraint {
70 my $self = shift;
71
72 my @methods = @{ $self->methods };
73
74 sub {
75 my $obj = shift;
76
77 return blessed($obj)
78 && blessed($obj) ne 'Regexp'
79 && all { $obj->can($_) } @methods;
80 };
81}
82
83sub create_child_type {
84 my ($self, @args) = @_;
85 return Moose::Meta::TypeConstraint->new(@args, parent => $self);
86}
87
88sub get_message {
89 my $self = shift;
90 my ($value) = @_;
91
92 if ($self->has_message) {
93 return $self->SUPER::get_message(@_);
94 }
95
96 my @methods = grep { !$value->can($_) } @{ $self->methods };
97 my $class = blessed $value;
98 return $class
99 . " is missing methods "
100 . english_list(map { "'$_'" } @methods);
101}
102
103124µs1;
104
105__END__