| Filename | /Users/ap13/perl5/lib/perl5/darwin-2level/Class/MOP/Method/Constructor.pm |
| Statements | Executed 1042 statements in 5.49ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 46 | 2 | 2 | 2.39ms | 169ms | Class::MOP::Method::Constructor::_generate_constructor_method_inline |
| 30 | 1 | 1 | 707µs | 57.1ms | Class::MOP::Method::Constructor::new |
| 30 | 1 | 1 | 538µs | 538µs | Class::MOP::Method::Constructor::_new |
| 46 | 1 | 1 | 336µs | 21.5ms | Class::MOP::Method::Constructor::_eval_environment |
| 30 | 1 | 1 | 248µs | 55.7ms | Class::MOP::Method::Constructor::_initialize_body |
| 1 | 1 | 1 | 24µs | 52µs | Class::MOP::Method::Constructor::BEGIN@4 |
| 1 | 1 | 1 | 14µs | 65µs | Class::MOP::Method::Constructor::BEGIN@8 |
| 1 | 1 | 1 | 14µs | 24µs | Class::MOP::Method::Constructor::BEGIN@5 |
| 1 | 1 | 1 | 13µs | 68µs | Class::MOP::Method::Constructor::BEGIN@7 |
| 1 | 1 | 1 | 12µs | 986µs | Class::MOP::Method::Constructor::BEGIN@10 |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Method::Constructor::__ANON__[:108] |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Method::Constructor::__ANON__[:115] |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Method::Constructor::__ANON__[:90] |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Method::Constructor::_generate_constructor_method |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Class::MOP::Method::Constructor; | ||||
| 2 | 1 | 1µs | our $VERSION = '2.1403'; | ||
| 3 | |||||
| 4 | 2 | 40µs | 2 | 79µs | # spent 52µs (24+27) within Class::MOP::Method::Constructor::BEGIN@4 which was called:
# once (24µs+27µs) by Class::MOP::Class::BEGIN@10 at line 4 # spent 52µs making 1 call to Class::MOP::Method::Constructor::BEGIN@4
# spent 27µs making 1 call to strict::import |
| 5 | 2 | 42µs | 2 | 34µs | # spent 24µs (14+10) within Class::MOP::Method::Constructor::BEGIN@5 which was called:
# once (14µs+10µs) by Class::MOP::Class::BEGIN@10 at line 5 # spent 24µs making 1 call to Class::MOP::Method::Constructor::BEGIN@5
# spent 10µs making 1 call to warnings::import |
| 6 | |||||
| 7 | 2 | 40µs | 2 | 122µs | # spent 68µs (13+54) within Class::MOP::Method::Constructor::BEGIN@7 which was called:
# once (13µs+54µs) by Class::MOP::Class::BEGIN@10 at line 7 # spent 68µs making 1 call to Class::MOP::Method::Constructor::BEGIN@7
# spent 54µs making 1 call to Exporter::import |
| 8 | 2 | 43µs | 2 | 116µs | # spent 65µs (14+51) within Class::MOP::Method::Constructor::BEGIN@8 which was called:
# once (14µs+51µs) by Class::MOP::Class::BEGIN@10 at line 8 # spent 65µs making 1 call to Class::MOP::Method::Constructor::BEGIN@8
# spent 51µs making 1 call to Exporter::import |
| 9 | |||||
| 10 | 2 | 760µs | 2 | 1.96ms | # spent 986µs (12+974) within Class::MOP::Method::Constructor::BEGIN@10 which was called:
# once (12µs+974µs) by Class::MOP::Class::BEGIN@10 at line 10 # spent 986µs making 1 call to Class::MOP::Method::Constructor::BEGIN@10
# spent 974µs making 1 call to parent::import |
| 11 | |||||
| 12 | # spent 57.1ms (707µs+56.4) within Class::MOP::Method::Constructor::new which was called 30 times, avg 1.90ms/call:
# 30 times (707µs+56.4ms) by Class::MOP::Class::_inline_constructor at line 1453 of Class/MOP/Class.pm, avg 1.90ms/call | ||||
| 13 | 30 | 17µs | my $class = shift; | ||
| 14 | 30 | 92µs | my %options = @_; | ||
| 15 | |||||
| 16 | 30 | 247µs | 60 | 69µs | (blessed $options{metaclass} && $options{metaclass}->isa('Class::MOP::Class')) # spent 36µs making 30 calls to Scalar::Util::blessed, avg 1µs/call
# spent 34µs making 30 calls to UNIVERSAL::isa, avg 1µs/call |
| 17 | || $class->_throw_exception( MustSupplyAMetaclass => params => \%options, | ||||
| 18 | class => $class | ||||
| 19 | ) | ||||
| 20 | if $options{is_inline}; | ||||
| 21 | |||||
| 22 | 30 | 20µs | ($options{package_name} && $options{name}) | ||
| 23 | || $class->_throw_exception( MustSupplyPackageNameAndName => params => \%options, | ||||
| 24 | class => $class | ||||
| 25 | ); | ||||
| 26 | |||||
| 27 | 30 | 97µs | 30 | 538µs | my $self = $class->_new(\%options); # spent 538µs making 30 calls to Class::MOP::Method::Constructor::_new, avg 18µs/call |
| 28 | |||||
| 29 | # we don't want this creating | ||||
| 30 | # a cycle in the code, if not | ||||
| 31 | # needed | ||||
| 32 | 30 | 102µs | 30 | 33µs | weaken($self->{'associated_metaclass'}); # spent 33µs making 30 calls to Scalar::Util::weaken, avg 1µs/call |
| 33 | |||||
| 34 | 30 | 49µs | 30 | 55.7ms | $self->_initialize_body; # spent 55.7ms making 30 calls to Class::MOP::Method::Constructor::_initialize_body, avg 1.86ms/call |
| 35 | |||||
| 36 | 30 | 117µs | return $self; | ||
| 37 | } | ||||
| 38 | |||||
| 39 | # spent 538µs within Class::MOP::Method::Constructor::_new which was called 30 times, avg 18µs/call:
# 30 times (538µs+0s) by Class::MOP::Method::Constructor::new at line 27, avg 18µs/call | ||||
| 40 | 30 | 15µs | my $class = shift; | ||
| 41 | |||||
| 42 | 30 | 11µs | return Class::MOP::Class->initialize($class)->new_object(@_) | ||
| 43 | if $class ne __PACKAGE__; | ||||
| 44 | |||||
| 45 | 30 | 20µs | my $params = @_ == 1 ? $_[0] : {@_}; | ||
| 46 | |||||
| 47 | 30 | 524µs | return bless { | ||
| 48 | # inherited from Class::MOP::Method | ||||
| 49 | body => $params->{body}, | ||||
| 50 | # associated_metaclass => $params->{associated_metaclass}, # overridden | ||||
| 51 | package_name => $params->{package_name}, | ||||
| 52 | name => $params->{name}, | ||||
| 53 | original_method => $params->{original_method}, | ||||
| 54 | |||||
| 55 | # inherited from Class::MOP::Generated | ||||
| 56 | is_inline => $params->{is_inline} || 0, | ||||
| 57 | definition_context => $params->{definition_context}, | ||||
| 58 | |||||
| 59 | # inherited from Class::MOP::Inlined | ||||
| 60 | _expected_method_class => $params->{_expected_method_class}, | ||||
| 61 | |||||
| 62 | # defined in this subclass | ||||
| 63 | options => $params->{options} || {}, | ||||
| 64 | associated_metaclass => $params->{metaclass}, | ||||
| 65 | }, $class; | ||||
| 66 | } | ||||
| 67 | |||||
| 68 | ## accessors | ||||
| 69 | |||||
| 70 | 46 | 157µs | sub options { (shift)->{'options'} } | ||
| 71 | 90 | 231µs | sub associated_metaclass { (shift)->{'associated_metaclass'} } | ||
| 72 | |||||
| 73 | ## method | ||||
| 74 | |||||
| 75 | # spent 55.7ms (248µs+55.5) within Class::MOP::Method::Constructor::_initialize_body which was called 30 times, avg 1.86ms/call:
# 30 times (248µs+55.5ms) by Class::MOP::Method::Constructor::new at line 34, avg 1.86ms/call | ||||
| 76 | 30 | 9µs | my $self = shift; | ||
| 77 | 30 | 9µs | my $method_name = '_generate_constructor_method'; | ||
| 78 | |||||
| 79 | 30 | 89µs | 30 | 21µs | $method_name .= '_inline' if $self->is_inline; # spent 21µs making 30 calls to Class::MOP::Method::Generated::is_inline, avg 703ns/call |
| 80 | |||||
| 81 | 30 | 144µs | 30 | 55.5ms | $self->{'body'} = $self->$method_name; # spent 55.5ms making 30 calls to Class::MOP::Method::Constructor::_generate_constructor_method_inline, avg 1.85ms/call |
| 82 | } | ||||
| 83 | |||||
| 84 | # spent 21.5ms (336µs+21.2) within Class::MOP::Method::Constructor::_eval_environment which was called 46 times, avg 467µs/call:
# 46 times (336µs+21.2ms) by Class::MOP::Method::Generated::_compile_code at line 52 of Class/MOP/Method/Generated.pm, avg 467µs/call | ||||
| 85 | 46 | 21µs | my $self = shift; | ||
| 86 | 46 | 234µs | 92 | 21.2ms | return $self->associated_metaclass->_eval_environment; # spent 14.9ms making 16 calls to Moose::Meta::Class::_eval_environment, avg 931µs/call
# spent 6.18ms making 30 calls to Class::MOP::Class::_eval_environment, avg 206µs/call
# spent 41µs making 30 calls to Class::MOP::Method::Constructor::associated_metaclass, avg 1µs/call
# spent 38µs making 16 calls to Class::MOP::Method::associated_metaclass, avg 2µs/call |
| 87 | } | ||||
| 88 | |||||
| 89 | sub _generate_constructor_method { | ||||
| 90 | return sub { Class::MOP::Class->initialize(shift)->new_object(@_) } | ||||
| 91 | } | ||||
| 92 | |||||
| 93 | # spent 169ms (2.39+166) within Class::MOP::Method::Constructor::_generate_constructor_method_inline which was called 46 times, avg 3.67ms/call:
# 30 times (1.20ms+54.3ms) by Class::MOP::Method::Constructor::_initialize_body at line 81, avg 1.85ms/call
# 16 times (1.19ms+112ms) by Moose::Meta::Method::Constructor::_initialize_body at line 54 of Moose/Meta/Method/Constructor.pm, avg 7.09ms/call | ||||
| 94 | 46 | 18µs | my $self = shift; | ||
| 95 | |||||
| 96 | 46 | 76µs | 46 | 75µs | my $meta = $self->associated_metaclass; # spent 39µs making 16 calls to Class::MOP::Method::associated_metaclass, avg 2µs/call
# spent 36µs making 30 calls to Class::MOP::Method::Constructor::associated_metaclass, avg 1µs/call |
| 97 | |||||
| 98 | 46 | 623µs | 46 | 100ms | my @source = ( # spent 100ms making 46 calls to Class::MOP::Class::_inline_new_object, avg 2.18ms/call |
| 99 | 'sub {', | ||||
| 100 | $meta->_inline_new_object, | ||||
| 101 | '}', | ||||
| 102 | ); | ||||
| 103 | |||||
| 104 | 46 | 110µs | 46 | 103µs | warn join("\n", @source) if $self->options->{debug}; # spent 103µs making 46 calls to Class::MOP::Method::Constructor::options, avg 2µs/call |
| 105 | |||||
| 106 | my $code = try { | ||||
| 107 | 46 | 187µs | 46 | 64.3ms | $self->_compile_code(\@source); # spent 64.3ms making 46 calls to Class::MOP::Method::Generated::_compile_code, avg 1.40ms/call |
| 108 | } | ||||
| 109 | catch { | ||||
| 110 | my $source = join("\n", @source); | ||||
| 111 | $self->_throw_exception( CouldNotEvalConstructor => constructor_method => $self, | ||||
| 112 | source => $source, | ||||
| 113 | error => $_ | ||||
| 114 | ); | ||||
| 115 | 46 | 639µs | 92 | 66.2ms | }; # spent 65.9ms making 46 calls to Try::Tiny::try, avg 1.43ms/call
# spent 226µs making 46 calls to Try::Tiny::catch, avg 5µs/call |
| 116 | |||||
| 117 | 46 | 703µs | return $code; | ||
| 118 | } | ||||
| 119 | |||||
| 120 | 1 | 5µs | 1; | ||
| 121 | |||||
| 122 | # ABSTRACT: Method Meta Object for constructors | ||||
| 123 | |||||
| 124 | __END__ |