← 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:45:26 2015

Filename/Users/ap13/perl5/lib/perl5/darwin-2level/Moose/Meta/TypeConstraint/DuckType.pm
StatementsExecuted 23 statements in 729µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11120µs62µsMoose::Meta::TypeConstraint::DuckType::::BEGIN@10Moose::Meta::TypeConstraint::DuckType::BEGIN@10
11114µs28µsMoose::Meta::TypeConstraint::DuckType::::BEGIN@4Moose::Meta::TypeConstraint::DuckType::BEGIN@4
11113µs28µsMoose::Meta::TypeConstraint::DuckType::::BEGIN@8Moose::Meta::TypeConstraint::DuckType::BEGIN@8
11113µs37µsMoose::Meta::TypeConstraint::DuckType::::BEGIN@15Moose::Meta::TypeConstraint::DuckType::BEGIN@15
1119µs34µsMoose::Meta::TypeConstraint::DuckType::::BEGIN@9Moose::Meta::TypeConstraint::DuckType::BEGIN@9
1118µs164µsMoose::Meta::TypeConstraint::DuckType::::BEGIN@11Moose::Meta::TypeConstraint::DuckType::BEGIN@11
1118µs12µsMoose::Meta::TypeConstraint::DuckType::::BEGIN@5Moose::Meta::TypeConstraint::DuckType::BEGIN@5
1117µs477µsMoose::Meta::TypeConstraint::DuckType::::BEGIN@6Moose::Meta::TypeConstraint::DuckType::BEGIN@6
1114µs4µsMoose::Meta::TypeConstraint::DuckType::::BEGIN@13Moose::Meta::TypeConstraint::DuckType::BEGIN@13
0000s0sMoose::Meta::TypeConstraint::DuckType::::__ANON__[:34]Moose::Meta::TypeConstraint::DuckType::__ANON__[:34]
0000s0sMoose::Meta::TypeConstraint::DuckType::::__ANON__[:45]Moose::Meta::TypeConstraint::DuckType::__ANON__[:45]
0000s0sMoose::Meta::TypeConstraint::DuckType::::__ANON__[:46]Moose::Meta::TypeConstraint::DuckType::__ANON__[:46]
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;
21700nsour $VERSION = '2.1403';
3
4224µs243µs
# spent 28µs (14+14) within Moose::Meta::TypeConstraint::DuckType::BEGIN@4 which was called: # once (14µs+14µs) by Moose::Util::TypeConstraints::BEGIN@31 at line 4
use strict;
# spent 28µs making 1 call to Moose::Meta::TypeConstraint::DuckType::BEGIN@4 # spent 14µs making 1 call to strict::import
5221µs216µs
# spent 12µs (8+4) within Moose::Meta::TypeConstraint::DuckType::BEGIN@5 which was called: # once (8µs+4µs) by Moose::Util::TypeConstraints::BEGIN@31 at line 5
use warnings;
# spent 12µs making 1 call to Moose::Meta::TypeConstraint::DuckType::BEGIN@5 # spent 4µs making 1 call to warnings::import
6225µs2947µs
# spent 477µs (7+470) within Moose::Meta::TypeConstraint::DuckType::BEGIN@6 which was called: # once (7µs+470µs) by Moose::Util::TypeConstraints::BEGIN@31 at line 6
use metaclass;
# spent 477µs making 1 call to Moose::Meta::TypeConstraint::DuckType::BEGIN@6 # spent 470µs making 1 call to metaclass::import
7
8224µs243µs
# spent 28µs (13+15) within Moose::Meta::TypeConstraint::DuckType::BEGIN@8 which was called: # once (13µs+15µs) by Moose::Util::TypeConstraints::BEGIN@31 at line 8
use B;
# spent 28µs making 1 call to Moose::Meta::TypeConstraint::DuckType::BEGIN@8 # spent 15µs making 1 call to Exporter::import
9234µs259µs
# spent 34µs (9+25) within Moose::Meta::TypeConstraint::DuckType::BEGIN@9 which was called: # once (9µs+25µs) by Moose::Util::TypeConstraints::BEGIN@31 at line 9
use Scalar::Util 'blessed';
# spent 34µs making 1 call to Moose::Meta::TypeConstraint::DuckType::BEGIN@9 # spent 25µs making 1 call to Exporter::import
10347µs386µs
# spent 62µs (20+43) within Moose::Meta::TypeConstraint::DuckType::BEGIN@10 which was called: # once (20µs+43µs) by Moose::Util::TypeConstraints::BEGIN@31 at line 10
use List::Util 1.33 qw(all);
# spent 62µs making 1 call to Moose::Meta::TypeConstraint::DuckType::BEGIN@10 # spent 14µs making 1 call to UNIVERSAL::VERSION # spent 10µs making 1 call to List::Util::import
11235µs2321µs
# spent 164µs (8+156) within Moose::Meta::TypeConstraint::DuckType::BEGIN@11 which was called: # once (8µs+156µs) by Moose::Util::TypeConstraints::BEGIN@31 at line 11
use Moose::Util 'english_list';
# spent 164µs making 1 call to Moose::Meta::TypeConstraint::DuckType::BEGIN@11 # spent 156µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337]
12
13227µs14µs
# spent 4µs within Moose::Meta::TypeConstraint::DuckType::BEGIN@13 which was called: # once (4µs+0s) by Moose::Util::TypeConstraints::BEGIN@31 at line 13
use Moose::Util::TypeConstraints ();
14
152476µs262µs
# spent 37µs (13+25) within Moose::Meta::TypeConstraint::DuckType::BEGIN@15 which was called: # once (13µs+25µs) by Moose::Util::TypeConstraints::BEGIN@31 at line 15
use parent 'Moose::Meta::TypeConstraint';
# spent 37µs making 1 call to Moose::Meta::TypeConstraint::DuckType::BEGIN@15 # spent 25µs making 1 call to parent::import
16
1716µs3366µs__PACKAGE__->meta->add_attribute('methods' => (
# spent 343µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 17µs making 1 call to Moose::Meta::TypeConstraint::DuckType::meta # spent 6µs making 1 call to Class::MOP::_definition_context
18 accessor => 'methods',
19 Class::MOP::_definition_context(),
20));
21
22my $inliner = sub {
23 my $self = shift;
24 my $val = shift;
25
26 return $self->parent->_inline_check($val)
27 . ' && do {' . "\n"
28 . 'my $val = ' . $val . ';' . "\n"
29 . '&List::Util::all(' . "\n"
30 . 'sub { $val->can($_) },' . "\n"
31 . join(', ', map { B::perlstring($_) } @{ $self->methods })
32 . ');' . "\n"
33 . '}';
3412µs};
35
36sub new {
37 my ( $class, %args ) = @_;
38
39 $args{parent}
40 = Moose::Util::TypeConstraints::find_type_constraint('Object');
41
42 my @methods = @{ $args{methods} };
43 $args{constraint} = sub {
44 my $val = $_[0];
45 return all { $val->can($_) } @methods;
46 };
47
48 $args{inlined} = $inliner;
49
50 my $self = $class->SUPER::new(\%args);
51
52 $self->compile_type_constraint()
53 unless $self->_has_compiled_type_constraint;
54
55 return $self;
56}
57
58sub equals {
59 my ( $self, $type_or_name ) = @_;
60
61 my $other = Moose::Util::TypeConstraints::find_type_constraint($type_or_name);
62
63 return unless $other->isa(__PACKAGE__);
64
65 my @self_methods = sort @{ $self->methods };
66 my @other_methods = sort @{ $other->methods };
67
68 return unless @self_methods == @other_methods;
69
70 while ( @self_methods ) {
71 my $method = shift @self_methods;
72 my $other_method = shift @other_methods;
73
74 return unless $method eq $other_method;
75 }
76
77 return 1;
78}
79
80sub create_child_type {
81 my ($self, @args) = @_;
82 return Moose::Meta::TypeConstraint->new(@args, parent => $self);
83}
84
85sub get_message {
86 my $self = shift;
87 my ($value) = @_;
88
89 if ($self->has_message) {
90 return $self->SUPER::get_message(@_);
91 }
92
93 return $self->SUPER::get_message($value) unless blessed($value);
94
95 my @methods = grep { !$value->can($_) } @{ $self->methods };
96 my $class = blessed $value;
97 $class ||= $value;
98
99 return $class
100 . " is missing methods "
101 . english_list(map { "'$_'" } @methods);
102}
103
10416µs1;
105
106# ABSTRACT: Type constraint for duck typing
107
108__END__