File | /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Class/MOP/Module.pm |
Statements Executed | 57 |
Statement Execution Time | 483µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
5 | 1 | 1 | 85µs | 139µs | _instantiate_module | Class::MOP::Module::
1 | 1 | 1 | 14µs | 17µs | BEGIN@4 | Class::MOP::Module::
1 | 1 | 1 | 10µs | 23µs | BEGIN@5 | Class::MOP::Module::
1 | 1 | 1 | 8µs | 1.57ms | BEGIN@14 | Class::MOP::Module::
1 | 1 | 1 | 7µs | 19µs | BEGIN@64 | Class::MOP::Module::
1 | 1 | 1 | 7µs | 28µs | BEGIN@8 | Class::MOP::Module::
1 | 1 | 1 | 6µs | 31µs | BEGIN@7 | Class::MOP::Module::
0 | 0 | 0 | 0s | 0s | _new | Class::MOP::Module::
0 | 0 | 0 | 0s | 0s | authority | Class::MOP::Module::
0 | 0 | 0 | 0s | 0s | create | Class::MOP::Module::
0 | 0 | 0 | 0s | 0s | identifier | Class::MOP::Module::
0 | 0 | 0 | 0s | 0s | version | Class::MOP::Module::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | |||||
2 | package Class::MOP::Module; | ||||
3 | |||||
4 | 3 | 26µs | 2 | 20µs | # spent 17µs (14+3) within Class::MOP::Module::BEGIN@4 which was called
# once (14µs+3µs) by base::import at line 4 # spent 17µs making 1 call to Class::MOP::Module::BEGIN@4
# spent 3µs making 1 call to strict::import |
5 | 3 | 21µs | 2 | 36µs | # spent 23µs (10+13) within Class::MOP::Module::BEGIN@5 which was called
# once (10µs+13µs) by base::import at line 5 # spent 23µs making 1 call to Class::MOP::Module::BEGIN@5
# spent 13µs making 1 call to warnings::import |
6 | |||||
7 | 3 | 21µs | 2 | 55µs | # spent 31µs (6+24) within Class::MOP::Module::BEGIN@7 which was called
# once (6µs+24µs) by base::import at line 7 # spent 31µs making 1 call to Class::MOP::Module::BEGIN@7
# spent 24µs making 1 call to Exporter::import |
8 | 3 | 47µs | 2 | 50µs | # spent 28µs (7+22) within Class::MOP::Module::BEGIN@8 which was called
# once (7µs+22µs) by base::import at line 8 # spent 28µs making 1 call to Class::MOP::Module::BEGIN@8
# spent 22µs making 1 call to Exporter::import |
9 | |||||
10 | 1 | 700ns | our $VERSION = '0.98'; | ||
11 | 1 | 14µs | $VERSION = eval $VERSION; | ||
12 | 1 | 300ns | our $AUTHORITY = 'cpan:STEVAN'; | ||
13 | |||||
14 | 3 | 200µs | 2 | 1.57ms | # spent 1.57ms (8µs+1.56) within Class::MOP::Module::BEGIN@14 which was called
# once (8µs+1.56ms) by base::import at line 14 # spent 1.57ms making 1 call to Class::MOP::Module::BEGIN@14
# spent 1.56ms making 1 call to base::import, recursion: max depth 1, time 1.56ms |
15 | |||||
16 | sub _new { | ||||
17 | my $class = shift; | ||||
18 | return Class::MOP::Class->initialize($class)->new_object(@_) | ||||
19 | if $class ne __PACKAGE__; | ||||
20 | |||||
21 | my $params = @_ == 1 ? $_[0] : {@_}; | ||||
22 | return bless { | ||||
23 | |||||
24 | # from Class::MOP::Package | ||||
25 | package => $params->{package}, | ||||
26 | namespace => \undef, | ||||
27 | |||||
28 | # attributes | ||||
29 | version => \undef, | ||||
30 | authority => \undef | ||||
31 | } => $class; | ||||
32 | } | ||||
33 | |||||
34 | sub version { | ||||
35 | my $self = shift; | ||||
36 | ${$self->get_package_symbol({ sigil => '$', type => 'SCALAR', name => 'VERSION' })}; | ||||
37 | } | ||||
38 | |||||
39 | sub authority { | ||||
40 | my $self = shift; | ||||
41 | ${$self->get_package_symbol({ sigil => '$', type => 'SCALAR', name => 'AUTHORITY' })}; | ||||
42 | } | ||||
43 | |||||
44 | sub identifier { | ||||
45 | my $self = shift; | ||||
46 | join '-' => ( | ||||
47 | $self->name, | ||||
48 | ($self->version || ()), | ||||
49 | ($self->authority || ()), | ||||
50 | ); | ||||
51 | } | ||||
52 | |||||
53 | sub create { | ||||
54 | confess "The Class::MOP::Module->create method has been made a private object method.\n"; | ||||
55 | } | ||||
56 | |||||
57 | # spent 139µs (85+54) within Class::MOP::Module::_instantiate_module which was called 5 times, avg 28µs/call:
# 5 times (85µs+54µs) by Class::MOP::Class::create at line 300 of Class/MOP/Class.pm, avg 28µs/call | ||||
58 | 5 | 11µs | my($self, $version, $authority) = @_; | ||
59 | 5 | 20µs | 5 | 2µs | my $package_name = $self->name; # spent 2µs making 5 calls to Class::MOP::Package::name, avg 480ns/call |
60 | |||||
61 | 5 | 8µs | 5 | 52µs | Class::MOP::_is_valid_class_name($package_name) # spent 52µs making 5 calls to Class::MOP::_is_valid_class_name, avg 10µs/call |
62 | || confess "creation of $package_name failed: invalid package name"; | ||||
63 | |||||
64 | 3 | 67µs | 2 | 31µs | # spent 19µs (7+12) within Class::MOP::Module::BEGIN@64 which was called
# once (7µs+12µs) by base::import at line 64 # spent 19µs making 1 call to Class::MOP::Module::BEGIN@64
# spent 12µs making 1 call to strict::unimport |
65 | 5 | 27µs | scalar %{ $package_name . '::' }; # touch the stash | ||
66 | 5 | 2µs | ${ $package_name . '::VERSION' } = $version if defined $version; | ||
67 | 5 | 2µs | ${ $package_name . '::AUTHORITY' } = $authority if defined $authority; | ||
68 | |||||
69 | 5 | 12µs | return; | ||
70 | } | ||||
71 | |||||
72 | 1 | 4µs | 1; | ||
73 | |||||
74 | __END__ | ||||
75 | |||||
76 | =pod | ||||
77 | |||||
78 | =head1 NAME | ||||
79 | |||||
80 | Class::MOP::Module - Module Meta Object | ||||
81 | |||||
82 | =head1 DESCRIPTION | ||||
83 | |||||
84 | A module is essentially a L<Class::MOP::Package> with metadata, in our | ||||
85 | case the version and authority. | ||||
86 | |||||
87 | =head1 INHERITANCE | ||||
88 | |||||
89 | B<Class::MOP::Module> is a subclass of L<Class::MOP::Package>. | ||||
90 | |||||
91 | =head1 METHODS | ||||
92 | |||||
93 | =over 4 | ||||
94 | |||||
95 | =item B<< $metamodule->version >> | ||||
96 | |||||
97 | This is a read-only attribute which returns the C<$VERSION> of the | ||||
98 | package, if one exists. | ||||
99 | |||||
100 | =item B<< $metamodule->authority >> | ||||
101 | |||||
102 | This is a read-only attribute which returns the C<$AUTHORITY> of the | ||||
103 | package, if one exists. | ||||
104 | |||||
105 | =item B<< $metamodule->identifier >> | ||||
106 | |||||
107 | This constructs a string which combines the name, version and | ||||
108 | authority. | ||||
109 | |||||
110 | =item B<< Class::MOP::Module->meta >> | ||||
111 | |||||
112 | This will return a L<Class::MOP::Class> instance for this class. | ||||
113 | |||||
114 | =back | ||||
115 | |||||
116 | =head1 AUTHORS | ||||
117 | |||||
118 | Stevan Little E<lt>stevan@iinteractive.comE<gt> | ||||
119 | |||||
120 | =head1 COPYRIGHT AND LICENSE | ||||
121 | |||||
122 | Copyright 2006-2010 by Infinity Interactive, Inc. | ||||
123 | |||||
124 | L<http://www.iinteractive.com> | ||||
125 | |||||
126 | This library is free software; you can redistribute it and/or modify | ||||
127 | it under the same terms as Perl itself. | ||||
128 | |||||
129 | =cut |