| Filename | /home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Object.pm |
| Statements | Executed 111 statements in 5.79ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 797µs | 947µs | Moose::Object::BEGIN@13 |
| 42 | 1 | 1 | 782µs | 1.04ms | Moose::Object::BUILDALL |
| 6 | 1 | 1 | 363µs | 8.05ms | Moose::Object::does |
| 1 | 1 | 1 | 245µs | 252µs | Moose::Object::BEGIN@109 |
| 1 | 1 | 1 | 90µs | 14.9ms | Moose::Object::BEGIN@14 |
| 1 | 1 | 1 | 75µs | 94µs | Moose::Object::BEGIN@4 |
| 1 | 1 | 1 | 58µs | 127µs | Moose::Object::BEGIN@101 |
| 1 | 1 | 1 | 47µs | 124µs | Moose::Object::BEGIN@83 |
| 1 | 1 | 1 | 39µs | 122µs | Moose::Object::BEGIN@5 |
| 1 | 1 | 1 | 21µs | 21µs | Moose::Object::BEGIN@10 |
| 1 | 1 | 1 | 20µs | 20µs | Moose::Object::BEGIN@11 |
| 1 | 1 | 1 | 19µs | 19µs | Moose::Object::BEGIN@7 |
| 1 | 1 | 1 | 18µs | 18µs | Moose::Object::BEGIN@8 |
| 1 | 1 | 1 | 18µs | 18µs | Moose::Object::BEGIN@9 |
| 0 | 0 | 0 | 0s | 0s | Moose::Object::BUILDARGS |
| 0 | 0 | 0 | 0s | 0s | Moose::Object::DEMOLISHALL |
| 0 | 0 | 0 | 0s | 0s | Moose::Object::DESTROY |
| 0 | 0 | 0 | 0s | 0s | Moose::Object::__ANON__[:103] |
| 0 | 0 | 0 | 0s | 0s | Moose::Object::__ANON__[:97] |
| 0 | 0 | 0 | 0s | 0s | Moose::Object::dump |
| 0 | 0 | 0 | 0s | 0s | Moose::Object::new |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | |||||
| 2 | package Moose::Object; | ||||
| 3 | |||||
| 4 | 3 | 100µs | 2 | 112µs | # spent 94µs (75+18) within Moose::Object::BEGIN@4 which was called:
# once (75µs+18µs) by Moose::BEGIN@25 at line 4 # spent 94µs making 1 call to Moose::Object::BEGIN@4
# spent 18µs making 1 call to strict::import |
| 5 | 3 | 95µs | 2 | 206µs | # spent 122µs (39+83) within Moose::Object::BEGIN@5 which was called:
# once (39µs+83µs) by Moose::BEGIN@25 at line 5 # spent 122µs making 1 call to Moose::Object::BEGIN@5
# spent 83µs making 1 call to warnings::import |
| 6 | |||||
| 7 | 3 | 76µs | 1 | 19µs | # spent 19µs within Moose::Object::BEGIN@7 which was called:
# once (19µs+0s) by Moose::BEGIN@25 at line 7 # spent 19µs making 1 call to Moose::Object::BEGIN@7 |
| 8 | 3 | 75µs | 1 | 18µs | # spent 18µs within Moose::Object::BEGIN@8 which was called:
# once (18µs+0s) by Moose::BEGIN@25 at line 8 # spent 18µs making 1 call to Moose::Object::BEGIN@8 |
| 9 | 3 | 87µs | 1 | 18µs | # spent 18µs within Moose::Object::BEGIN@9 which was called:
# once (18µs+0s) by Moose::BEGIN@25 at line 9 # spent 18µs making 1 call to Moose::Object::BEGIN@9 |
| 10 | 3 | 85µs | 1 | 21µs | # spent 21µs within Moose::Object::BEGIN@10 which was called:
# once (21µs+0s) by Moose::BEGIN@25 at line 10 # spent 21µs making 1 call to Moose::Object::BEGIN@10 |
| 11 | 3 | 124µs | 1 | 20µs | # spent 20µs within Moose::Object::BEGIN@11 which was called:
# once (20µs+0s) by Moose::BEGIN@25 at line 11 # spent 20µs making 1 call to Moose::Object::BEGIN@11 |
| 12 | |||||
| 13 | 3 | 873µs | 2 | 969µs | # spent 947µs (797+151) within Moose::Object::BEGIN@13 which was called:
# once (797µs+151µs) by Moose::BEGIN@25 at line 13 # spent 947µs making 1 call to Moose::Object::BEGIN@13
# spent 21µs making 1 call to if::import |
| 14 | 3 | 1.38ms | 2 | 14.9ms | # spent 14.9ms (90µs+14.8) within Moose::Object::BEGIN@14 which was called:
# once (90µs+14.8ms) by Moose::BEGIN@25 at line 14 # spent 14.9ms making 1 call to Moose::Object::BEGIN@14
# spent 16µs making 1 call to if::import |
| 15 | |||||
| 16 | 1 | 4µs | our $VERSION = '1.19'; | ||
| 17 | 1 | 82µs | $VERSION = eval $VERSION; # spent 9µs executing statements in string eval | ||
| 18 | 1 | 3µs | our $AUTHORITY = 'cpan:STEVAN'; | ||
| 19 | |||||
| 20 | sub new { | ||||
| 21 | my $class = shift; | ||||
| 22 | my $real_class = Scalar::Util::blessed($class) || $class; | ||||
| 23 | |||||
| 24 | my $params = $real_class->BUILDARGS(@_); | ||||
| 25 | |||||
| 26 | return Class::MOP::Class->initialize($real_class)->new_object($params); | ||||
| 27 | } | ||||
| 28 | |||||
| 29 | sub BUILDARGS { | ||||
| 30 | my $class = shift; | ||||
| 31 | if ( scalar @_ == 1 ) { | ||||
| 32 | unless ( defined $_[0] && ref $_[0] eq 'HASH' ) { | ||||
| 33 | Class::MOP::class_of($class)->throw_error( | ||||
| 34 | "Single parameters to new() must be a HASH ref", | ||||
| 35 | data => $_[0] ); | ||||
| 36 | } | ||||
| 37 | return { %{ $_[0] } }; | ||||
| 38 | } | ||||
| 39 | elsif ( @_ % 2 ) { | ||||
| 40 | Carp::carp( | ||||
| 41 | "The new() method for $class expects a hash reference or a key/value list." | ||||
| 42 | . " You passed an odd number of arguments" ); | ||||
| 43 | return { @_, undef }; | ||||
| 44 | } | ||||
| 45 | else { | ||||
| 46 | return {@_}; | ||||
| 47 | } | ||||
| 48 | } | ||||
| 49 | |||||
| 50 | # spent 1.04ms (782µs+254µs) within Moose::Object::BUILDALL which was called 42 times, avg 25µs/call:
# 42 times (782µs+254µs) by Moose::Meta::Class::new_object at line 278 of Moose/Meta/Class.pm, avg 25µs/call | ||||
| 51 | # NOTE: we ask Perl if we even | ||||
| 52 | # need to do this first, to avoid | ||||
| 53 | # extra meta level calls | ||||
| 54 | 42 | 1.05ms | 42 | 253µs | return unless $_[0]->can('BUILD'); # spent 253µs making 42 calls to UNIVERSAL::can, avg 6µs/call |
| 55 | my ($self, $params) = @_; | ||||
| 56 | foreach my $method (reverse Class::MOP::class_of($self)->find_all_methods_by_name('BUILD')) { | ||||
| 57 | $method->{code}->execute($self, $params); | ||||
| 58 | } | ||||
| 59 | } | ||||
| 60 | |||||
| 61 | sub DEMOLISHALL { | ||||
| 62 | my $self = shift; | ||||
| 63 | my ($in_global_destruction) = @_; | ||||
| 64 | |||||
| 65 | # NOTE: we ask Perl if we even | ||||
| 66 | # need to do this first, to avoid | ||||
| 67 | # extra meta level calls | ||||
| 68 | return unless $self->can('DEMOLISH'); | ||||
| 69 | |||||
| 70 | my @isa; | ||||
| 71 | if ( my $meta = Class::MOP::class_of($self ) ) { | ||||
| 72 | @isa = $meta->linearized_isa; | ||||
| 73 | } else { | ||||
| 74 | # We cannot count on being able to retrieve a previously made | ||||
| 75 | # metaclass, _or_ being able to make a new one during global | ||||
| 76 | # destruction. However, we should still be able to use mro at | ||||
| 77 | # that time (at least tests suggest so ;) | ||||
| 78 | my $class_name = ref $self; | ||||
| 79 | @isa = @{ mro::get_linear_isa($class_name) } | ||||
| 80 | } | ||||
| 81 | |||||
| 82 | foreach my $class (@isa) { | ||||
| 83 | 3 | 453µs | 2 | 200µs | # spent 124µs (47+77) within Moose::Object::BEGIN@83 which was called:
# once (47µs+77µs) by Moose::BEGIN@25 at line 83 # spent 124µs making 1 call to Moose::Object::BEGIN@83
# spent 77µs making 1 call to strict::unimport |
| 84 | my $demolish = *{"${class}::DEMOLISH"}{CODE}; | ||||
| 85 | $self->$demolish($in_global_destruction) | ||||
| 86 | if defined $demolish; | ||||
| 87 | } | ||||
| 88 | } | ||||
| 89 | |||||
| 90 | sub DESTROY { | ||||
| 91 | my $self = shift; | ||||
| 92 | |||||
| 93 | local $?; | ||||
| 94 | |||||
| 95 | Try::Tiny::try { | ||||
| 96 | $self->DEMOLISHALL(Devel::GlobalDestruction::in_global_destruction); | ||||
| 97 | } | ||||
| 98 | Try::Tiny::catch { | ||||
| 99 | # Without this, Perl will warn "\t(in cleanup)$@" because of some | ||||
| 100 | # bizarre fucked-up logic deep in the internals. | ||||
| 101 | 3 | 292µs | 2 | 195µs | # spent 127µs (58+69) within Moose::Object::BEGIN@101 which was called:
# once (58µs+69µs) by Moose::BEGIN@25 at line 101 # spent 127µs making 1 call to Moose::Object::BEGIN@101
# spent 69µs making 1 call to warnings::unimport |
| 102 | die $_; | ||||
| 103 | }; | ||||
| 104 | |||||
| 105 | return; | ||||
| 106 | } | ||||
| 107 | |||||
| 108 | # support for UNIVERSAL::DOES ... | ||||
| 109 | # spent 252µs (245+8) within Moose::Object::BEGIN@109 which was called:
# once (245µs+8µs) by Moose::BEGIN@25 at line 116 | ||||
| 110 | 2 | 255µs | 1 | 8µs | my $does = UNIVERSAL->can("DOES") ? "SUPER::DOES" : "isa"; # spent 8µs making 1 call to UNIVERSAL::can |
| 111 | eval 'sub DOES { | ||||
| 112 | my ( $self, $class_or_role_name ) = @_; | ||||
| 113 | return $self->'.$does.'($class_or_role_name) | ||||
| 114 | || $self->does($class_or_role_name); | ||||
| 115 | }'; | ||||
| 116 | 1 | 377µs | 1 | 252µs | } # spent 252µs making 1 call to Moose::Object::BEGIN@109 |
| 117 | |||||
| 118 | # new does() methods will be created | ||||
| 119 | # as appropiate see Moose::Meta::Role | ||||
| 120 | # spent 8.05ms (363µs+7.69) within Moose::Object::does which was called 6 times, avg 1.34ms/call:
# 6 times (363µs+7.69ms) by Moose::Meta::Attribute::does at line 42 of Moose/Meta/Attribute.pm, avg 1.34ms/call | ||||
| 121 | 30 | 365µs | my ($self, $role_name) = @_; | ||
| 122 | 6 | 202µs | my $meta = Class::MOP::class_of($self); # spent 202µs making 6 calls to Class::MOP::class_of, avg 34µs/call | ||
| 123 | (defined $role_name) | ||||
| 124 | || $meta->throw_error("You must supply a role name to does()"); | ||||
| 125 | 12 | 7.48ms | return 1 if $meta->can('does_role') && $meta->does_role($role_name); # spent 7.44ms making 6 calls to Moose::Meta::Class::does_role, avg 1.24ms/call
# spent 45µs making 6 calls to UNIVERSAL::can, avg 8µs/call | ||
| 126 | return 0; | ||||
| 127 | } | ||||
| 128 | |||||
| 129 | sub dump { | ||||
| 130 | my $self = shift; | ||||
| 131 | require Data::Dumper; | ||||
| 132 | local $Data::Dumper::Maxdepth = shift if @_; | ||||
| 133 | Data::Dumper::Dumper $self; | ||||
| 134 | } | ||||
| 135 | |||||
| 136 | 1 | 13µs | 1; | ||
| 137 | |||||
| 138 | __END__ |