| Filename | /home/doy/coding/src/Class-MOP/blib/lib//Class/MOP/Method/Constructor.pm |
| Statements | Executed 2691 statements in 63.2ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 73 | 1 | 1 | 18.4ms | 26.8ms | Class::MOP::Method::Constructor::CORE:sort (opcode) |
| 73 | 2 | 2 | 14.2ms | 759ms | Class::MOP::Method::Constructor::_generate_constructor_method_inline |
| 31 | 1 | 1 | 5.38ms | 40.7ms | Class::MOP::Method::Constructor::_eval_environment |
| 73 | 2 | 2 | 3.64ms | 57.5ms | Class::MOP::Method::Constructor::_attributes |
| 31 | 1 | 1 | 3.41ms | 312ms | Class::MOP::Method::Constructor::new |
| 31 | 1 | 1 | 2.37ms | 2.37ms | Class::MOP::Method::Constructor::_new |
| 73 | 1 | 1 | 1.83ms | 243ms | Class::MOP::Method::Constructor::__ANON__[:122] |
| 31 | 1 | 1 | 1.52ms | 306ms | Class::MOP::Method::Constructor::_initialize_body |
| 1 | 1 | 1 | 73µs | 280µs | Class::MOP::Method::Constructor::BEGIN@9 |
| 1 | 1 | 1 | 69µs | 89µs | Class::MOP::Method::Constructor::BEGIN@4 |
| 1 | 1 | 1 | 59µs | 128µs | Class::MOP::Method::Constructor::BEGIN@5 |
| 1 | 1 | 1 | 44µs | 3.53ms | Class::MOP::Method::Constructor::BEGIN@15 |
| 1 | 1 | 1 | 40µs | 199µs | Class::MOP::Method::Constructor::BEGIN@8 |
| 1 | 1 | 1 | 40µs | 217µs | Class::MOP::Method::Constructor::BEGIN@7 |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Method::Constructor::__ANON__[:104] |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Method::Constructor::__ANON__[:126] |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Method::Constructor::_generate_constructor_method |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | |||||
| 2 | package Class::MOP::Method::Constructor; | ||||
| 3 | |||||
| 4 | 3 | 102µs | 2 | 108µs | # spent 89µs (69+20) within Class::MOP::Method::Constructor::BEGIN@4 which was called:
# once (69µs+20µs) by Class::MOP::Class::BEGIN@10 at line 4 # spent 89µs making 1 call to Class::MOP::Method::Constructor::BEGIN@4
# spent 20µs making 1 call to strict::import |
| 5 | 3 | 111µs | 2 | 196µs | # spent 128µs (59+68) within Class::MOP::Method::Constructor::BEGIN@5 which was called:
# once (59µs+68µs) by Class::MOP::Class::BEGIN@10 at line 5 # spent 128µs making 1 call to Class::MOP::Method::Constructor::BEGIN@5
# spent 68µs making 1 call to warnings::import |
| 6 | |||||
| 7 | 3 | 117µs | 2 | 393µs | # spent 217µs (40+177) within Class::MOP::Method::Constructor::BEGIN@7 which was called:
# once (40µs+177µs) by Class::MOP::Class::BEGIN@10 at line 7 # spent 217µs making 1 call to Class::MOP::Method::Constructor::BEGIN@7
# spent 177µs making 1 call to Exporter::import |
| 8 | 3 | 99µs | 2 | 358µs | # spent 199µs (40+159) within Class::MOP::Method::Constructor::BEGIN@8 which was called:
# once (40µs+159µs) by Class::MOP::Class::BEGIN@10 at line 8 # spent 199µs making 1 call to Class::MOP::Method::Constructor::BEGIN@8
# spent 159µs making 1 call to Exporter::import |
| 9 | 3 | 227µs | 2 | 486µs | # spent 280µs (73+207) within Class::MOP::Method::Constructor::BEGIN@9 which was called:
# once (73µs+207µs) by Class::MOP::Class::BEGIN@10 at line 9 # spent 280µs making 1 call to Class::MOP::Method::Constructor::BEGIN@9
# spent 207µs making 1 call to Exporter::import |
| 10 | |||||
| 11 | 1 | 5µs | our $VERSION = '1.11'; | ||
| 12 | 1 | 61µs | $VERSION = eval $VERSION; # spent 11µs executing statements in string eval | ||
| 13 | 1 | 4µs | our $AUTHORITY = 'cpan:STEVAN'; | ||
| 14 | |||||
| 15 | 3 | 2.03ms | 2 | 3.53ms | # spent 3.53ms (44µs+3.49) within Class::MOP::Method::Constructor::BEGIN@15 which was called:
# once (44µs+3.49ms) by Class::MOP::Class::BEGIN@10 at line 15 # spent 3.53ms making 1 call to Class::MOP::Method::Constructor::BEGIN@15
# spent 3.49ms making 1 call to base::import, recursion: max depth 1, sum of overlapping time 3.49ms |
| 16 | |||||
| 17 | # spent 312ms (3.41+309) within Class::MOP::Method::Constructor::new which was called 31 times, avg 10.1ms/call:
# 31 times (3.41ms+309ms) by Class::MOP::Class::_inline_constructor at line 1471 of Class/MOP/Class.pm, avg 10.1ms/call | ||||
| 18 | 248 | 3.97ms | my $class = shift; | ||
| 19 | my %options = @_; | ||||
| 20 | |||||
| 21 | 62 | 455µs | (blessed $options{metaclass} && $options{metaclass}->isa('Class::MOP::Class')) # spent 229µs making 31 calls to Scalar::Util::blessed, avg 7µs/call
# spent 226µs making 31 calls to UNIVERSAL::isa, avg 7µs/call | ||
| 22 | || confess "You must pass a metaclass instance if you want to inline" | ||||
| 23 | if $options{is_inline}; | ||||
| 24 | |||||
| 25 | ($options{package_name} && $options{name}) | ||||
| 26 | || confess "You must supply the package_name and name parameters $Class::MOP::Method::UPGRADE_ERROR_TEXT"; | ||||
| 27 | |||||
| 28 | 31 | 2.37ms | my $self = $class->_new(\%options); # spent 2.37ms making 31 calls to Class::MOP::Method::Constructor::_new, avg 76µs/call | ||
| 29 | |||||
| 30 | # we don't want this creating | ||||
| 31 | # a cycle in the code, if not | ||||
| 32 | # needed | ||||
| 33 | 31 | 246µs | weaken($self->{'associated_metaclass'}); # spent 246µs making 31 calls to Scalar::Util::weaken, avg 8µs/call | ||
| 34 | |||||
| 35 | 31 | 306ms | $self->_initialize_body; # spent 306ms making 31 calls to Class::MOP::Method::Constructor::_initialize_body, avg 9.86ms/call | ||
| 36 | |||||
| 37 | return $self; | ||||
| 38 | } | ||||
| 39 | |||||
| 40 | # spent 2.37ms within Class::MOP::Method::Constructor::_new which was called 31 times, avg 76µs/call:
# 31 times (2.37ms+0s) by Class::MOP::Method::Constructor::new at line 28, avg 76µs/call | ||||
| 41 | 124 | 2.53ms | my $class = shift; | ||
| 42 | |||||
| 43 | return Class::MOP::Class->initialize($class)->new_object(@_) | ||||
| 44 | if $class ne __PACKAGE__; | ||||
| 45 | |||||
| 46 | my $params = @_ == 1 ? $_[0] : {@_}; | ||||
| 47 | |||||
| 48 | return bless { | ||||
| 49 | # inherited from Class::MOP::Method | ||||
| 50 | body => $params->{body}, | ||||
| 51 | # associated_metaclass => $params->{associated_metaclass}, # overriden | ||||
| 52 | package_name => $params->{package_name}, | ||||
| 53 | name => $params->{name}, | ||||
| 54 | original_method => $params->{original_method}, | ||||
| 55 | |||||
| 56 | # inherited from Class::MOP::Generated | ||||
| 57 | is_inline => $params->{is_inline} || 0, | ||||
| 58 | definition_context => $params->{definition_context}, | ||||
| 59 | |||||
| 60 | # inherited from Class::MOP::Inlined | ||||
| 61 | _expected_method_class => $params->{_expected_method_class}, | ||||
| 62 | |||||
| 63 | # defined in this subclass | ||||
| 64 | options => $params->{options} || {}, | ||||
| 65 | associated_metaclass => $params->{metaclass}, | ||||
| 66 | }, $class; | ||||
| 67 | } | ||||
| 68 | |||||
| 69 | ## accessors | ||||
| 70 | |||||
| 71 | 73 | 1.32ms | sub options { (shift)->{'options'} } | ||
| 72 | 93 | 1.28ms | sub associated_metaclass { (shift)->{'associated_metaclass'} } | ||
| 73 | |||||
| 74 | ## cached values ... | ||||
| 75 | |||||
| 76 | # spent 57.5ms (3.64+53.9) within Class::MOP::Method::Constructor::_attributes which was called 73 times, avg 788µs/call:
# 42 times (2.10ms+23.6ms) by Moose::Meta::Method::Constructor::_eval_environment at line 58 of Moose/Meta/Method/Constructor.pm, avg 613µs/call
# 31 times (1.54ms+30.3ms) by Class::MOP::Method::Constructor::_eval_environment at line 97, avg 1.03ms/call | ||||
| 77 | 1136 | 30.3ms | my $self = shift; | ||
| 78 | 1980 | 8.37ms | $self->{'attributes'} ||= [ # spent 8.37ms making 1980 calls to Class::MOP::Mixin::AttributeCore::name, avg 4µs/call | ||
| 79 | 219 | 53.9ms | sort { $a->name cmp $b->name } # spent 26.8ms making 73 calls to Class::MOP::Method::Constructor::CORE:sort, avg 367µs/call
# spent 26.4ms making 73 calls to Class::MOP::Class::get_all_attributes, avg 361µs/call
# spent 451µs making 42 calls to Class::MOP::Method::associated_metaclass, avg 11µs/call
# spent 285µs making 31 calls to Class::MOP::Method::Constructor::associated_metaclass, avg 9µs/call | ||
| 80 | $self->associated_metaclass->get_all_attributes | ||||
| 81 | ] | ||||
| 82 | } | ||||
| 83 | |||||
| 84 | ## method | ||||
| 85 | |||||
| 86 | # spent 306ms (1.52+304) within Class::MOP::Method::Constructor::_initialize_body which was called 31 times, avg 9.86ms/call:
# 31 times (1.52ms+304ms) by Class::MOP::Method::Constructor::new at line 35, avg 9.86ms/call | ||||
| 87 | 124 | 1.67ms | my $self = shift; | ||
| 88 | my $method_name = '_generate_constructor_method'; | ||||
| 89 | |||||
| 90 | 31 | 195µs | $method_name .= '_inline' if $self->is_inline; # spent 195µs making 31 calls to Class::MOP::Method::Generated::is_inline, avg 6µs/call | ||
| 91 | |||||
| 92 | 31 | 304ms | $self->{'body'} = $self->$method_name; # spent 304ms making 31 calls to Class::MOP::Method::Constructor::_generate_constructor_method_inline, avg 9.81ms/call | ||
| 93 | } | ||||
| 94 | |||||
| 95 | # spent 40.7ms (5.38+35.3) within Class::MOP::Method::Constructor::_eval_environment which was called 31 times, avg 1.31ms/call:
# 31 times (5.38ms+35.3ms) by Class::MOP::Method::Generated::_compile_code at line 47 of Class/MOP/Method/Generated.pm, avg 1.31ms/call | ||||
| 96 | 93 | 1.83ms | my $self = shift; | ||
| 97 | 267 | 2.62ms | 298 | 35.3ms | my $defaults = [map { $_->default } @{ $self->_attributes }]; # spent 31.8ms making 31 calls to Class::MOP::Method::Constructor::_attributes, avg 1.03ms/call
# spent 3.53ms making 267 calls to Class::MOP::Mixin::AttributeCore::default, avg 13µs/call |
| 98 | return { | ||||
| 99 | '$defaults' => \$defaults, | ||||
| 100 | }; | ||||
| 101 | } | ||||
| 102 | |||||
| 103 | sub _generate_constructor_method { | ||||
| 104 | return sub { Class::MOP::Class->initialize(shift)->new_object(@_) } | ||||
| 105 | } | ||||
| 106 | |||||
| 107 | # spent 759ms (14.2+745) within Class::MOP::Method::Constructor::_generate_constructor_method_inline which was called 73 times, avg 10.4ms/call:
# 42 times (8.52ms+446ms) by Moose::Meta::Method::Constructor::_initialize_body at line 52 of Moose/Meta/Method/Constructor.pm, avg 10.8ms/call
# 31 times (5.68ms+298ms) by Class::MOP::Method::Constructor::_initialize_body at line 92, avg 9.81ms/call | ||||
| 108 | 438 | 13.2ms | my $self = shift; | ||
| 109 | |||||
| 110 | 73 | 741µs | my $meta = $self->associated_metaclass; # spent 446µs making 42 calls to Class::MOP::Method::associated_metaclass, avg 11µs/call
# spent 295µs making 31 calls to Class::MOP::Method::Constructor::associated_metaclass, avg 10µs/call | ||
| 111 | |||||
| 112 | 73 | 491ms | my @source = ( # spent 491ms making 73 calls to Class::MOP::Class::_inline_new_object, avg 6.73ms/call | ||
| 113 | 'sub {', | ||||
| 114 | $meta->_inline_new_object, | ||||
| 115 | '}', | ||||
| 116 | ); | ||||
| 117 | |||||
| 118 | 73 | 984µs | warn join("\n", @source) if $self->options->{debug}; # spent 984µs making 73 calls to Class::MOP::Method::Constructor::options, avg 13µs/call | ||
| 119 | |||||
| 120 | # spent 243ms (1.83+241) within Class::MOP::Method::Constructor::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP/Method/Constructor.pm:122] which was called 73 times, avg 3.33ms/call:
# 73 times (1.83ms+241ms) by Try::Tiny::try at line 71 of Try/Tiny.pm, avg 3.33ms/call | ||||
| 121 | 73 | 1.70ms | 73 | 241ms | $self->_compile_code(\@source); # spent 241ms making 73 calls to Class::MOP::Method::Generated::_compile_code, avg 3.30ms/call |
| 122 | } | ||||
| 123 | catch { | ||||
| 124 | my $source = join("\n", @source); | ||||
| 125 | confess "Could not eval the constructor :\n\n$source\n\nbecause :\n\n$_"; | ||||
| 126 | 146 | 123ms | }; # spent 250ms making 73 calls to Try::Tiny::try, avg 3.43ms/call, recursion: max depth 2, sum of overlapping time 129ms
# spent 1.67ms making 73 calls to Try::Tiny::catch, avg 23µs/call | ||
| 127 | |||||
| 128 | return $code; | ||||
| 129 | } | ||||
| 130 | |||||
| 131 | 1 | 11µs | 1; | ||
| 132 | |||||
| 133 | __END__ | ||||
# spent 26.8ms (18.4+8.37) within Class::MOP::Method::Constructor::CORE:sort which was called 73 times, avg 367µs/call:
# 73 times (18.4ms+8.37ms) by Class::MOP::Method::Constructor::_attributes at line 79, avg 367µs/call |