← Index
NYTProf Performance Profile   « block view • line view • sub view »
For -e
  Run on Wed Nov 17 21:45:08 2010
Reported on Wed Nov 17 22:11:07 2010

Filename/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Meta/TypeConstraint/Enum.pm
StatementsExecuted 33 statements in 2.53ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111207µs1.55msMoose::Meta::TypeConstraint::Enum::::newMoose::Meta::TypeConstraint::Enum::new
11172µs90µsMoose::Meta::TypeConstraint::Enum::::BEGIN@3Moose::Meta::TypeConstraint::Enum::BEGIN@3
11165µs134µsMoose::Meta::TypeConstraint::Enum::::BEGIN@4Moose::Meta::TypeConstraint::Enum::BEGIN@4
11153µs65µsMoose::Meta::TypeConstraint::Enum::::constraintMoose::Meta::TypeConstraint::Enum::constraint
11140µs362µsMoose::Meta::TypeConstraint::Enum::::BEGIN@13Moose::Meta::TypeConstraint::Enum::BEGIN@13
11136µs3.06msMoose::Meta::TypeConstraint::Enum::::BEGIN@5Moose::Meta::TypeConstraint::Enum::BEGIN@5
11124µs24µsMoose::Meta::TypeConstraint::Enum::::BEGIN@7Moose::Meta::TypeConstraint::Enum::BEGIN@7
0000s0sMoose::Meta::TypeConstraint::Enum::::__ANON__[:75]Moose::Meta::TypeConstraint::Enum::__ANON__[:75]
0000s0sMoose::Meta::TypeConstraint::Enum::::__ANON__[:83]Moose::Meta::TypeConstraint::Enum::__ANON__[:83]
0000s0sMoose::Meta::TypeConstraint::Enum::::_compile_hand_optimized_type_constraintMoose::Meta::TypeConstraint::Enum::_compile_hand_optimized_type_constraint
0000s0sMoose::Meta::TypeConstraint::Enum::::create_child_typeMoose::Meta::TypeConstraint::Enum::create_child_type
0000s0sMoose::Meta::TypeConstraint::Enum::::equalsMoose::Meta::TypeConstraint::Enum::equals
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::Enum;
2
33100µs2108µs
# spent 90µs (72+18) within Moose::Meta::TypeConstraint::Enum::BEGIN@3 which was called: # once (72µs+18µs) by Moose::Util::TypeConstraints::BEGIN@35 at line 3
use strict;
# spent 90µs making 1 call to Moose::Meta::TypeConstraint::Enum::BEGIN@3 # spent 18µs making 1 call to strict::import
4399µs2202µs
# spent 134µs (65+68) within Moose::Meta::TypeConstraint::Enum::BEGIN@4 which was called: # once (65µs+68µs) by Moose::Util::TypeConstraints::BEGIN@35 at line 4
use warnings;
# spent 134µs making 1 call to Moose::Meta::TypeConstraint::Enum::BEGIN@4 # spent 68µs making 1 call to warnings::import
53145µs26.09ms
# spent 3.06ms (36µs+3.03) within Moose::Meta::TypeConstraint::Enum::BEGIN@5 which was called: # once (36µs+3.03ms) by Moose::Util::TypeConstraints::BEGIN@35 at line 5
use metaclass;
# spent 3.06ms making 1 call to Moose::Meta::TypeConstraint::Enum::BEGIN@5 # spent 3.03ms making 1 call to metaclass::import
6
73245µs124µs
# spent 24µs within Moose::Meta::TypeConstraint::Enum::BEGIN@7 which was called: # once (24µs+0s) by Moose::Util::TypeConstraints::BEGIN@35 at line 7
use Moose::Util::TypeConstraints ();
# spent 24µs making 1 call to Moose::Meta::TypeConstraint::Enum::BEGIN@7
8
916µsour $VERSION = '1.19';
10162µs$VERSION = eval $VERSION;
# spent 12µs executing statements in string eval
1114µsour $AUTHORITY = 'cpan:STEVAN';
12
1331.55ms2685µs
# spent 362µs (40+323) within Moose::Meta::TypeConstraint::Enum::BEGIN@13 which was called: # once (40µs+323µs) by Moose::Util::TypeConstraints::BEGIN@35 at line 13
use base 'Moose::Meta::TypeConstraint';
# spent 362µs making 1 call to Moose::Meta::TypeConstraint::Enum::BEGIN@13 # spent 323µs making 1 call to base::import
14
15127µs22.22ms__PACKAGE__->meta->add_attribute('values' => (
# spent 2.11ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 116µs making 1 call to Moose::Meta::TypeConstraint::Enum::meta
16 accessor => 'values',
17));
18
19
# spent 1.55ms (207µs+1.35) within Moose::Meta::TypeConstraint::Enum::new which was called: # once (207µs+1.35ms) by Moose::Util::TypeConstraints::create_enum_type_constraint at line 460 of Moose/Util/TypeConstraints.pm
sub new {
207172µs my ( $class, %args ) = @_;
21
221126µs $args{parent} = Moose::Util::TypeConstraints::find_type_constraint('Str');
23
24 if ( scalar @{ $args{values} } < 2 ) {
25 require Moose;
26 Moose->throw_error("You must have at least two values to enumerate through");
27 }
28
29 for (@{ $args{values} }) {
30314µs if (!defined($_)) {
31 require Moose;
32 Moose->throw_error("Enum values must be strings, not undef");
33 }
34 elsif (ref($_)) {
35 require Moose;
36 Moose->throw_error("Enum values must be strings, not '$_'");
37 }
38 }
39
401413µs my $self = $class->_new(\%args);
# spent 413µs making 1 call to Moose::Meta::TypeConstraint::Enum::_new
41
422808µs $self->compile_type_constraint()
43 unless $self->_has_compiled_type_constraint;
44
45 return $self;
46}
47
48sub equals {
49 my ( $self, $type_or_name ) = @_;
50
51 my $other = Moose::Util::TypeConstraints::find_type_constraint($type_or_name);
52
53 return unless $other->isa(__PACKAGE__);
54
55 my @self_values = sort @{ $self->values };
56 my @other_values = sort @{ $other->values };
57
58 return unless @self_values == @other_values;
59
60 while ( @self_values ) {
61 my $value = shift @self_values;
62 my $other_value = shift @other_values;
63
64 return unless $value eq $other_value;
65 }
66
67 return 1;
68}
69
70
# spent 65µs (53+12) within Moose::Meta::TypeConstraint::Enum::constraint which was called: # once (53µs+12µs) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 213 of Moose/Meta/TypeConstraint.pm
sub constraint {
71376µs my $self = shift;
72
73112µs my %values = map { $_ => undef } @{ $self->values };
# spent 12µs making 1 call to Moose::Meta::TypeConstraint::Enum::values
74
75 return sub { exists $values{$_[0]} };
76}
77
78sub _compile_hand_optimized_type_constraint {
79 my $self = shift;
80
81 my %values = map { $_ => undef } @{ $self->values };
82
83 sub { defined($_[0]) && !ref($_[0]) && exists $values{$_[0]} };
84}
85
86sub create_child_type {
87 my ($self, @args) = @_;
88 return Moose::Meta::TypeConstraint->new(@args, parent => $self);
89}
90
91127µs1;
92
93__END__