| Filename | /Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/MooseX/Storage.pm |
| Statements | Executed 44 statements in 644µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 402µs | 690µs | MooseX::Storage::BEGIN@13 |
| 1 | 1 | 1 | 228µs | 14.2ms | MooseX::Storage::BEGIN@12 |
| 3 | 3 | 1 | 47µs | 27.7ms | MooseX::Storage::_expand_role |
| 1 | 1 | 1 | 20µs | 269µs | MooseX::Storage::import |
| 1 | 1 | 1 | 18µs | 27.7ms | MooseX::Storage::_injected_storage_role_generator |
| 2 | 1 | 1 | 11µs | 67µs | MooseX::Storage::_rewrite_role_name |
| 1 | 1 | 1 | 7µs | 7µs | MooseX::Storage::BEGIN@7 |
| 1 | 1 | 1 | 7µs | 5.53ms | MooseX::Storage::BEGIN@10 |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package MooseX::Storage; | ||||
| 2 | { | ||||
| 3 | 2 | 800ns | $MooseX::Storage::VERSION = '0.39'; | ||
| 4 | } | ||||
| 5 | # git description: v0.38-TRIAL-2-g769dd9c | ||||
| 6 | |||||
| 7 | # spent 7µs within MooseX::Storage::BEGIN@7 which was called:
# once (7µs+0s) by Atom::BEGIN@6 at line 9 | ||||
| 8 | 1 | 4µs | $MooseX::Storage::AUTHORITY = 'cpan:STEVAN'; | ||
| 9 | 1 | 18µs | 1 | 7µs | } # spent 7µs making 1 call to MooseX::Storage::BEGIN@7 |
| 10 | 2 | 31µs | 2 | 11.1ms | # spent 5.53ms (7µs+5.53) within MooseX::Storage::BEGIN@10 which was called:
# once (7µs+5.53ms) by Atom::BEGIN@6 at line 10 # spent 5.53ms making 1 call to MooseX::Storage::BEGIN@10
# spent 5.53ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:519] |
| 11 | |||||
| 12 | 2 | 124µs | 1 | 14.2ms | # spent 14.2ms (228µs+14.0) within MooseX::Storage::BEGIN@12 which was called:
# once (228µs+14.0ms) by Atom::BEGIN@6 at line 12 # spent 14.2ms making 1 call to MooseX::Storage::BEGIN@12 |
| 13 | 2 | 386µs | 1 | 690µs | # spent 690µs (402+288) within MooseX::Storage::BEGIN@13 which was called:
# once (402µs+288µs) by Atom::BEGIN@6 at line 13 # spent 690µs making 1 call to MooseX::Storage::BEGIN@13 |
| 14 | |||||
| 15 | # spent 269µs (20+249) within MooseX::Storage::import which was called:
# once (20µs+249µs) by Atom::BEGIN@6 at line 6 of lib/HackaMol/Atom.pm | ||||
| 16 | 1 | 500ns | my $pkg = caller(); | ||
| 17 | |||||
| 18 | 1 | 200ns | return if $pkg eq 'main'; | ||
| 19 | |||||
| 20 | 1 | 7µs | 1 | 1µs | ($pkg->can('meta')) # spent 1µs making 1 call to UNIVERSAL::can |
| 21 | || confess "This package can only be used in Moose based classes"; | ||||
| 22 | |||||
| 23 | 1 | 6µs | 4 | 248µs | $pkg->meta->add_method('Storage' => __PACKAGE__->meta->find_method_by_name('_injected_storage_role_generator')); # spent 147µs making 1 call to Class::MOP::Class::find_method_by_name
# spent 80µs making 1 call to Class::MOP::Mixin::HasMethods::add_method
# spent 12µs making 1 call to Atom::meta
# spent 9µs making 1 call to MooseX::Storage::meta |
| 24 | } | ||||
| 25 | |||||
| 26 | 1 | 100ns | my %HORRIBLE_GC_AVOIDANCE_HACK; | ||
| 27 | |||||
| 28 | # spent 67µs (11+55) within MooseX::Storage::_rewrite_role_name which was called 2 times, avg 33µs/call:
# 2 times (11µs+55µs) by MooseX::Storage::_expand_role at line 57, avg 33µs/call | ||||
| 29 | 2 | 600ns | my ($self, $base, $string) = @_; | ||
| 30 | |||||
| 31 | 2 | 10µs | 2 | 55µs | my $role_name = scalar String::RewritePrefix->rewrite( # spent 55µs making 2 calls to String::RewritePrefix::rewrite, avg 28µs/call |
| 32 | { | ||||
| 33 | '' => "MooseX::Storage::$base\::", | ||||
| 34 | '=' => '', | ||||
| 35 | }, | ||||
| 36 | $string, | ||||
| 37 | ); | ||||
| 38 | } | ||||
| 39 | |||||
| 40 | # spent 27.7ms (47µs+27.6) within MooseX::Storage::_expand_role which was called 3 times, avg 9.22ms/call:
# once (26µs+22.8ms) by MooseX::Storage::_injected_storage_role_generator at line 79
# once (19µs+4.79ms) by MooseX::Storage::_injected_storage_role_generator at line 98
# once (2µs+0s) by MooseX::Storage::_injected_storage_role_generator at line 85 | ||||
| 41 | 3 | 1µs | my ($self, $base, $value) = @_; | ||
| 42 | |||||
| 43 | 3 | 3µs | return unless defined $value; | ||
| 44 | |||||
| 45 | 2 | 300ns | if (ref $value) { | ||
| 46 | confess "too many args in arrayref role declaration" if @$value > 2; | ||||
| 47 | my ($class, $param) = @$value; | ||||
| 48 | |||||
| 49 | $class = $self->_rewrite_role_name($base => $class); | ||||
| 50 | Class::MOP::load_class($class); | ||||
| 51 | |||||
| 52 | my $role = $class->meta->generate_role(parameters => $param); | ||||
| 53 | |||||
| 54 | $HORRIBLE_GC_AVOIDANCE_HACK{ $role->name } = $role; | ||||
| 55 | return $role->name; | ||||
| 56 | } else { | ||||
| 57 | 2 | 12µs | 2 | 67µs | my $class = $self->_rewrite_role_name($base, $value); # spent 67µs making 2 calls to MooseX::Storage::_rewrite_role_name, avg 33µs/call |
| 58 | 2 | 2µs | 2 | 4µs | Class::MOP::load_class($class); # spent 4µs making 2 calls to Class::MOP::load_class, avg 2µs/call |
| 59 | |||||
| 60 | 2 | 1µs | my $role = $class; | ||
| 61 | |||||
| 62 | 2 | 12µs | 4 | 25µs | if ($class->meta->isa( # spent 12µs making 1 call to MooseX::Storage::Basic::meta
# spent 11µs making 1 call to MooseX::Storage::IO::StorableFile::meta
# spent 2µs making 2 calls to UNIVERSAL::isa, avg 1µs/call |
| 63 | 'MooseX::Role::Parameterized::Meta::Role::Parameterizable' | ||||
| 64 | )) { | ||||
| 65 | $role = $class->meta->generate_role(parameters => undef); | ||||
| 66 | $HORRIBLE_GC_AVOIDANCE_HACK{ $role->name } = $role; | ||||
| 67 | return $role->name; | ||||
| 68 | } | ||||
| 69 | |||||
| 70 | 2 | 6µs | return $class; | ||
| 71 | } | ||||
| 72 | } | ||||
| 73 | |||||
| 74 | # spent 27.7ms (18µs+27.7) within MooseX::Storage::_injected_storage_role_generator which was called:
# once (18µs+27.7ms) by main::BEGIN@5 at line 7 of lib/HackaMol/Atom.pm | ||||
| 75 | 1 | 1µs | my %params = @_; | ||
| 76 | |||||
| 77 | 1 | 600ns | $params{base} = '=MooseX::Storage::Basic' unless defined $params{base}; | ||
| 78 | |||||
| 79 | 1 | 2µs | 1 | 22.8ms | my @roles = __PACKAGE__->_expand_role(Base => $params{base}); # spent 22.8ms making 1 call to MooseX::Storage::_expand_role |
| 80 | |||||
| 81 | # NOTE: | ||||
| 82 | # you don't have to have a format | ||||
| 83 | # role, this just means you dont | ||||
| 84 | # get anything other than pack/unpack | ||||
| 85 | 1 | 2µs | 1 | 2µs | push @roles, __PACKAGE__->_expand_role(Format => $params{format}); # spent 2µs making 1 call to MooseX::Storage::_expand_role |
| 86 | |||||
| 87 | # NOTE: | ||||
| 88 | # many IO roles don't make sense unless | ||||
| 89 | # you have also have a format role chosen | ||||
| 90 | # too, the exception being StorableFile | ||||
| 91 | # | ||||
| 92 | # NOTE: | ||||
| 93 | # we dont need this code anymore, cause | ||||
| 94 | # the role composition will catch it for | ||||
| 95 | # us. This allows the StorableFile to work | ||||
| 96 | #(exists $params{'format'}) | ||||
| 97 | # || confess "You must specify a format role in order to use an IO role"; | ||||
| 98 | 1 | 1µs | 1 | 4.81ms | push @roles, __PACKAGE__->_expand_role(IO => $params{io}); # spent 4.81ms making 1 call to MooseX::Storage::_expand_role |
| 99 | |||||
| 100 | # Note: | ||||
| 101 | # These traits alter the behaviour of the engine, the user can | ||||
| 102 | # specify these per role-usage | ||||
| 103 | 1 | 2µs | for my $trait ( @{ $params{'traits'} ||= [] } ) { | ||
| 104 | push @roles, __PACKAGE__->_expand_role(Traits => $trait); | ||||
| 105 | } | ||||
| 106 | |||||
| 107 | 1 | 4µs | return @roles; | ||
| 108 | } | ||||
| 109 | |||||
| 110 | 1 | 3µs | 1; | ||
| 111 | |||||
| 112 | __END__ |