| Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Class/MOP/Module.pm |
| Statements | Executed 49 statements in 493µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 2 | 1 | 1 | 91µs | 2.22ms | Class::MOP::Module::create |
| 2 | 1 | 1 | 20µs | 22µs | Class::MOP::Module::_instantiate_module |
| 1 | 1 | 1 | 10µs | 5.87ms | Class::MOP::Module::BEGIN@16 |
| 1 | 1 | 1 | 10µs | 10µs | Class::MOP::Module::BEGIN@3 |
| 1 | 1 | 1 | 6µs | 9µs | Class::MOP::Module::BEGIN@10 |
| 1 | 1 | 1 | 6µs | 14µs | Class::MOP::Module::BEGIN@11 |
| 1 | 1 | 1 | 6µs | 27µs | Class::MOP::Module::BEGIN@13 |
| 1 | 1 | 1 | 6µs | 28µs | Class::MOP::Module::BEGIN@14 |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Module::_anon_cache_key |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Module::_anon_package_prefix |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Module::_new |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Module::identifier |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | |||||
| 2 | package Class::MOP::Module; | ||||
| 3 | # spent 10µs within Class::MOP::Module::BEGIN@3 which was called:
# once (10µs+0s) by base::import at line 5 | ||||
| 4 | 1 | 5µs | $Class::MOP::Module::AUTHORITY = 'cpan:STEVAN'; | ||
| 5 | 1 | 23µs | 1 | 10µs | } # spent 10µs making 1 call to Class::MOP::Module::BEGIN@3 |
| 6 | { | ||||
| 7 | 2 | 1µs | $Class::MOP::Module::VERSION = '2.0602'; | ||
| 8 | } | ||||
| 9 | |||||
| 10 | 3 | 16µs | 2 | 11µs | # spent 9µs (6+2) within Class::MOP::Module::BEGIN@10 which was called:
# once (6µs+2µs) by base::import at line 10 # spent 9µs making 1 call to Class::MOP::Module::BEGIN@10
# spent 2µs making 1 call to strict::import |
| 11 | 3 | 17µs | 2 | 22µs | # spent 14µs (6+8) within Class::MOP::Module::BEGIN@11 which was called:
# once (6µs+8µs) by base::import at line 11 # spent 14µs making 1 call to Class::MOP::Module::BEGIN@11
# spent 8µs making 1 call to warnings::import |
| 12 | |||||
| 13 | 3 | 17µs | 2 | 49µs | # spent 27µs (6+22) within Class::MOP::Module::BEGIN@13 which was called:
# once (6µs+22µs) by base::import at line 13 # spent 27µs making 1 call to Class::MOP::Module::BEGIN@13
# spent 22µs making 1 call to Exporter::import |
| 14 | 3 | 17µs | 2 | 50µs | # spent 28µs (6+22) within Class::MOP::Module::BEGIN@14 which was called:
# once (6µs+22µs) by base::import at line 14 # spent 28µs making 1 call to Class::MOP::Module::BEGIN@14
# spent 22µs making 1 call to Exporter::import |
| 15 | |||||
| 16 | 3 | 284µs | 2 | 5.87ms | # spent 5.87ms (10µs+5.86) within Class::MOP::Module::BEGIN@16 which was called:
# once (10µs+5.86ms) by base::import at line 16 # spent 5.87ms making 1 call to Class::MOP::Module::BEGIN@16
# spent 5.86ms making 1 call to base::import, recursion: max depth 1, sum of overlapping time 5.86ms |
| 17 | |||||
| 18 | sub _new { | ||||
| 19 | my $class = shift; | ||||
| 20 | return Class::MOP::Class->initialize($class)->new_object(@_) | ||||
| 21 | if $class ne __PACKAGE__; | ||||
| 22 | |||||
| 23 | my $params = @_ == 1 ? $_[0] : {@_}; | ||||
| 24 | return bless { | ||||
| 25 | # Need to quote package to avoid a problem with PPI mis-parsing this | ||||
| 26 | # as a package statement. | ||||
| 27 | |||||
| 28 | # from Class::MOP::Package | ||||
| 29 | 'package' => $params->{package}, | ||||
| 30 | namespace => \undef, | ||||
| 31 | |||||
| 32 | # attributes | ||||
| 33 | version => \undef, | ||||
| 34 | authority => \undef | ||||
| 35 | } => $class; | ||||
| 36 | } | ||||
| 37 | |||||
| 38 | sub version { | ||||
| 39 | my $self = shift; | ||||
| 40 | ${$self->get_or_add_package_symbol('$VERSION')}; | ||||
| 41 | } | ||||
| 42 | |||||
| 43 | sub authority { | ||||
| 44 | my $self = shift; | ||||
| 45 | ${$self->get_or_add_package_symbol('$AUTHORITY')}; | ||||
| 46 | } | ||||
| 47 | |||||
| 48 | sub identifier { | ||||
| 49 | my $self = shift; | ||||
| 50 | join '-' => ( | ||||
| 51 | $self->name, | ||||
| 52 | ($self->version || ()), | ||||
| 53 | ($self->authority || ()), | ||||
| 54 | ); | ||||
| 55 | } | ||||
| 56 | |||||
| 57 | # spent 2.22ms (91µs+2.12) within Class::MOP::Module::create which was called 2 times, avg 1.11ms/call:
# 2 times (91µs+2.12ms) by Class::MOP::Class::create at line 446 of Class/MOP/Class.pm, avg 1.11ms/call | ||||
| 58 | 2 | 2µs | my $class = shift; | ||
| 59 | 2 | 6µs | my @args = @_; | ||
| 60 | |||||
| 61 | 2 | 4µs | unshift @args, 'package' if @args % 2 == 1; | ||
| 62 | 2 | 4µs | my %options = @args; | ||
| 63 | |||||
| 64 | 2 | 4µs | my $package = delete $options{package}; | ||
| 65 | 2 | 2µs | my $version = delete $options{version}; | ||
| 66 | 2 | 1µs | my $authority = delete $options{authority}; | ||
| 67 | |||||
| 68 | 2 | 30µs | 2 | 2.10ms | my $meta = $class->SUPER::create($package => %options); # spent 2.10ms making 2 calls to Class::MOP::Package::create, avg 1.05ms/call |
| 69 | |||||
| 70 | 2 | 21µs | 2 | 22µs | $meta->_instantiate_module($version, $authority); # spent 22µs making 2 calls to Class::MOP::Module::_instantiate_module, avg 11µs/call |
| 71 | |||||
| 72 | 2 | 12µs | return $meta; | ||
| 73 | } | ||||
| 74 | |||||
| 75 | sub _anon_package_prefix { 'Class::MOP::Module::__ANON__::SERIAL::' } | ||||
| 76 | sub _anon_cache_key { confess "Modules are not cacheable" } | ||||
| 77 | |||||
| 78 | |||||
| 79 | # spent 22µs (20+2) within Class::MOP::Module::_instantiate_module which was called 2 times, avg 11µs/call:
# 2 times (20µs+2µs) by Class::MOP::Module::create at line 70, avg 11µs/call | ||||
| 80 | 2 | 2µs | my($self, $version, $authority) = @_; | ||
| 81 | 2 | 12µs | 2 | 2µs | my $package_name = $self->name; # spent 2µs making 2 calls to Class::MOP::Package::name, avg 1µs/call |
| 82 | |||||
| 83 | 2 | 1µs | $self->add_package_symbol('$VERSION' => $version) | ||
| 84 | if defined $version; | ||||
| 85 | 2 | 800ns | $self->add_package_symbol('$AUTHORITY' => $authority) | ||
| 86 | if defined $authority; | ||||
| 87 | |||||
| 88 | 2 | 9µs | return; | ||
| 89 | } | ||||
| 90 | |||||
| 91 | 1 | 3µs | 1; | ||
| 92 | |||||
| 93 | # ABSTRACT: Module Meta Object | ||||
| 94 | |||||
| - - | |||||
| 97 | =pod | ||||
| 98 | |||||
| 99 | =head1 NAME | ||||
| 100 | |||||
| 101 | Class::MOP::Module - Module Meta Object | ||||
| 102 | |||||
| 103 | =head1 VERSION | ||||
| 104 | |||||
| 105 | version 2.0602 | ||||
| 106 | |||||
| 107 | =head1 DESCRIPTION | ||||
| 108 | |||||
| 109 | A module is essentially a L<Class::MOP::Package> with metadata, in our | ||||
| 110 | case the version and authority. | ||||
| 111 | |||||
| 112 | =head1 INHERITANCE | ||||
| 113 | |||||
| 114 | B<Class::MOP::Module> is a subclass of L<Class::MOP::Package>. | ||||
| 115 | |||||
| 116 | =head1 METHODS | ||||
| 117 | |||||
| 118 | =over 4 | ||||
| 119 | |||||
| 120 | =item B<< Class::MOP::Module->create($package, %options) >> | ||||
| 121 | |||||
| 122 | Overrides C<create> from L<Class::MOP::Package> to provide these additional | ||||
| 123 | options: | ||||
| 124 | |||||
| 125 | =over 4 | ||||
| 126 | |||||
| 127 | =item C<version> | ||||
| 128 | |||||
| 129 | A version number, to be installed in the C<$VERSION> package global variable. | ||||
| 130 | |||||
| 131 | =item C<authority> | ||||
| 132 | |||||
| 133 | An authority, to be installed in the C<$AUTHORITY> package global variable. | ||||
| 134 | |||||
| 135 | =back | ||||
| 136 | |||||
| 137 | =item B<< $metamodule->version >> | ||||
| 138 | |||||
| 139 | This is a read-only attribute which returns the C<$VERSION> of the | ||||
| 140 | package, if one exists. | ||||
| 141 | |||||
| 142 | =item B<< $metamodule->authority >> | ||||
| 143 | |||||
| 144 | This is a read-only attribute which returns the C<$AUTHORITY> of the | ||||
| 145 | package, if one exists. | ||||
| 146 | |||||
| 147 | =item B<< $metamodule->identifier >> | ||||
| 148 | |||||
| 149 | This constructs a string which combines the name, version and | ||||
| 150 | authority. | ||||
| 151 | |||||
| 152 | =item B<< Class::MOP::Module->meta >> | ||||
| 153 | |||||
| 154 | This will return a L<Class::MOP::Class> instance for this class. | ||||
| 155 | |||||
| 156 | =back | ||||
| 157 | |||||
| 158 | =head1 AUTHOR | ||||
| 159 | |||||
| 160 | Moose is maintained by the Moose Cabal, along with the help of many contributors. See L<Moose/CABAL> and L<Moose/CONTRIBUTORS> for details. | ||||
| 161 | |||||
| 162 | =head1 COPYRIGHT AND LICENSE | ||||
| 163 | |||||
| 164 | This software is copyright (c) 2012 by Infinity Interactive, Inc.. | ||||
| 165 | |||||
| 166 | This is free software; you can redistribute it and/or modify it under | ||||
| 167 | the same terms as the Perl 5 programming language system itself. | ||||
| 168 | |||||
| 169 | =cut | ||||
| 170 | |||||
| 171 | |||||
| 172 | __END__ |