| Filename | /home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/MooseX/Clone.pm |
| Statements | Executed 23 statements in 3.90ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 2.83ms | 84.0ms | MooseX::Clone::BEGIN@10 |
| 1 | 1 | 1 | 1.40ms | 37.0ms | MooseX::Clone::BEGIN@13 |
| 1 | 1 | 1 | 1.20ms | 74.4ms | MooseX::Clone::BEGIN@11 |
| 1 | 1 | 1 | 1.19ms | 35.8ms | MooseX::Clone::BEGIN@12 |
| 1 | 1 | 1 | 1.18ms | 11.3ms | MooseX::Clone::BEGIN@8 |
| 1 | 1 | 1 | 70µs | 14.8ms | MooseX::Clone::BEGIN@4 |
| 1 | 1 | 1 | 47µs | 4.11ms | MooseX::Clone::BEGIN@15 |
| 0 | 0 | 0 | 0s | 0s | MooseX::Clone::clone |
| 0 | 0 | 0 | 0s | 0s | MooseX::Clone::clone_attribute |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | #!/usr/bin/perl | ||||
| 2 | |||||
| 3 | package MooseX::Clone; | ||||
| 4 | 3 | 208µs | 2 | 29.6ms | # spent 14.8ms (70µs+14.8) within MooseX::Clone::BEGIN@4 which was called:
# once (70µs+14.8ms) by Class::MOP::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Class/MOP.pm:118] at line 4 # spent 14.8ms making 1 call to MooseX::Clone::BEGIN@4
# spent 14.8ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:456] |
| 5 | |||||
| 6 | 1 | 4µs | our $VERSION = "0.05"; | ||
| 7 | |||||
| 8 | 3 | 507µs | 2 | 11.4ms | # spent 11.3ms (1.18+10.1) within MooseX::Clone::BEGIN@8 which was called:
# once (1.18ms+10.1ms) by Class::MOP::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Class/MOP.pm:118] at line 8 # spent 11.3ms making 1 call to MooseX::Clone::BEGIN@8
# spent 75µs making 1 call to Hash::Util::FieldHash::Compat::import |
| 9 | |||||
| 10 | 3 | 624µs | 1 | 84.0ms | # spent 84.0ms (2.83+81.1) within MooseX::Clone::BEGIN@10 which was called:
# once (2.83ms+81.1ms) by Class::MOP::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Class/MOP.pm:118] at line 10 # spent 84.0ms making 1 call to MooseX::Clone::BEGIN@10 |
| 11 | 3 | 560µs | 1 | 74.4ms | # spent 74.4ms (1.20+73.2) within MooseX::Clone::BEGIN@11 which was called:
# once (1.20ms+73.2ms) by Class::MOP::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Class/MOP.pm:118] at line 11 # spent 74.4ms making 1 call to MooseX::Clone::BEGIN@11 |
| 12 | 3 | 573µs | 1 | 35.8ms | # spent 35.8ms (1.19+34.6) within MooseX::Clone::BEGIN@12 which was called:
# once (1.19ms+34.6ms) by Class::MOP::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Class/MOP.pm:118] at line 12 # spent 35.8ms making 1 call to MooseX::Clone::BEGIN@12 |
| 13 | 3 | 560µs | 1 | 37.0ms | # spent 37.0ms (1.40+35.6) within MooseX::Clone::BEGIN@13 which was called:
# once (1.40ms+35.6ms) by Class::MOP::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Class/MOP.pm:118] at line 13 # spent 37.0ms making 1 call to MooseX::Clone::BEGIN@13 |
| 14 | |||||
| 15 | 3 | 818µs | 2 | 8.17ms | # spent 4.11ms (47µs+4.06) within MooseX::Clone::BEGIN@15 which was called:
# once (47µs+4.06ms) by Class::MOP::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Class/MOP.pm:118] at line 15 # spent 4.11ms making 1 call to MooseX::Clone::BEGIN@15
# spent 4.06ms making 1 call to namespace::clean::import |
| 16 | |||||
| 17 | sub clone { | ||||
| 18 | my ( $self, %params ) = @_; | ||||
| 19 | |||||
| 20 | my $meta = $self->meta; | ||||
| 21 | |||||
| 22 | my @cloning; | ||||
| 23 | |||||
| 24 | idhash my %clone_args; | ||||
| 25 | |||||
| 26 | attr: foreach my $attr ($meta->get_all_attributes()) { | ||||
| 27 | # collect all attrs that can be cloned. | ||||
| 28 | # if they have args in %params then those are passed to the recursive cloning op | ||||
| 29 | if ( $attr->does("MooseX::Clone::Meta::Attribute::Trait::Clone::Base") ) { | ||||
| 30 | push @cloning, $attr; | ||||
| 31 | |||||
| 32 | if ( defined( my $init_arg = $attr->init_arg ) ) { | ||||
| 33 | if ( exists $params{$init_arg} ) { | ||||
| 34 | $clone_args{$attr} = delete $params{$init_arg}; | ||||
| 35 | } | ||||
| 36 | } | ||||
| 37 | } | ||||
| 38 | } | ||||
| 39 | |||||
| 40 | my $clone = $meta->clone_object($self, %params); | ||||
| 41 | |||||
| 42 | foreach my $attr ( @cloning ) { | ||||
| 43 | $clone->clone_attribute( | ||||
| 44 | proto => $self, | ||||
| 45 | attr => $attr, | ||||
| 46 | ( exists $clone_args{$attr} ? ( init_arg => $clone_args{$attr} ) : () ), | ||||
| 47 | ); | ||||
| 48 | } | ||||
| 49 | |||||
| 50 | return $clone; | ||||
| 51 | } | ||||
| 52 | |||||
| 53 | sub clone_attribute { | ||||
| 54 | my ( $self, %args ) = @_; | ||||
| 55 | |||||
| 56 | my ( $proto, $attr ) = @args{qw/proto attr/}; | ||||
| 57 | |||||
| 58 | $attr->clone_value( $self, $proto, %args ); | ||||
| 59 | } | ||||
| 60 | |||||
| 61 | 1 | 12µs | __PACKAGE__ | ||
| 62 | |||||
| 63 | 1 | 35µs | 1 | 13.1ms | __END__ # spent 13.1ms making 1 call to B::Hooks::EndOfScope::__ANON__[B/Hooks/EndOfScope.pm:26] |