Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/5.18.2/version.pm |
Statements | Executed 68 statements in 773µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
289 | 3 | 3 | 2.20ms | 2.83ms | (<=> (xsub) | version::
295 | 4 | 4 | 994µs | 994µs | (bool (xsub) | version::
142 | 1 | 1 | 732µs | 732µs | parse (xsub) | version::
146 | 5 | 5 | 649µs | 649µs | new (xsub) | version::
6 | 6 | 1 | 82µs | 82µs | CORE:regcomp (opcode) | version::
4 | 4 | 4 | 65µs | 65µs | import | version::
1 | 1 | 1 | 14µs | 14µs | BEGIN@4 | version::
12 | 12 | 1 | 11µs | 11µs | CORE:qr (opcode) | version::
1 | 1 | 1 | 8µs | 18µs | BEGIN@119 | version::
1 | 1 | 1 | 8µs | 86µs | BEGIN@7 | version::
1 | 1 | 1 | 7µs | 11µs | __ANON__[:151] | version::
1 | 1 | 1 | 7µs | 18µs | BEGIN@5 | version::
1 | 1 | 1 | 4µs | 4µs | (cmp (xsub) | version::
1 | 1 | 1 | 4µs | 4µs | qv (xsub) | version::
0 | 0 | 0 | 0s | 0s | __ANON__[:145] | version::
0 | 0 | 0 | 0s | 0s | is_lax | version::
0 | 0 | 0 | 0s | 0s | is_strict | version::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | #!perl -w | ||||
2 | package version; | ||||
3 | |||||
4 | 2 | 42µs | 1 | 14µs | # spent 14µs within version::BEGIN@4 which was called:
# once (14µs+0s) by Perl::Critic::Policy::Variables::RequireLexicalLoopIterators::BEGIN@14 at line 4 # spent 14µs making 1 call to version::BEGIN@4 |
5 | 2 | 22µs | 2 | 28µs | # spent 18µs (7+11) within version::BEGIN@5 which was called:
# once (7µs+11µs) by Perl::Critic::Policy::Variables::RequireLexicalLoopIterators::BEGIN@14 at line 5 # spent 18µs making 1 call to version::BEGIN@5
# spent 11µs making 1 call to strict::import |
6 | |||||
7 | 2 | 189µs | 2 | 165µs | # spent 86µs (8+79) within version::BEGIN@7 which was called:
# once (8µs+79µs) by Perl::Critic::Policy::Variables::RequireLexicalLoopIterators::BEGIN@14 at line 7 # spent 86µs making 1 call to version::BEGIN@7
# spent 79µs making 1 call to vars::import |
8 | |||||
9 | 1 | 300ns | $VERSION = 0.9902; | ||
10 | |||||
11 | 1 | 300ns | $CLASS = 'version'; | ||
12 | |||||
13 | #--------------------------------------------------------------------------# | ||||
14 | # Version regexp components | ||||
15 | #--------------------------------------------------------------------------# | ||||
16 | |||||
17 | # Fraction part of a decimal version number. This is a common part of | ||||
18 | # both strict and lax decimal versions | ||||
19 | |||||
20 | 1 | 8µs | 1 | 2µs | my $FRACTION_PART = qr/\.[0-9]+/; # spent 2µs making 1 call to version::CORE:qr |
21 | |||||
22 | # First part of either decimal or dotted-decimal strict version number. | ||||
23 | # Unsigned integer with no leading zeroes (except for zero itself) to | ||||
24 | # avoid confusion with octal. | ||||
25 | |||||
26 | 1 | 4µs | 1 | 900ns | my $STRICT_INTEGER_PART = qr/0|[1-9][0-9]*/; # spent 900ns making 1 call to version::CORE:qr |
27 | |||||
28 | # First part of either decimal or dotted-decimal lax version number. | ||||
29 | # Unsigned integer, but allowing leading zeros. Always interpreted | ||||
30 | # as decimal. However, some forms of the resulting syntax give odd | ||||
31 | # results if used as ordinary Perl expressions, due to how perl treats | ||||
32 | # octals. E.g. | ||||
33 | # version->new("010" ) == 10 | ||||
34 | # version->new( 010 ) == 8 | ||||
35 | # version->new( 010.2) == 82 # "8" . "2" | ||||
36 | |||||
37 | 1 | 3µs | 1 | 700ns | my $LAX_INTEGER_PART = qr/[0-9]+/; # spent 700ns making 1 call to version::CORE:qr |
38 | |||||
39 | # Second and subsequent part of a strict dotted-decimal version number. | ||||
40 | # Leading zeroes are permitted, and the number is always decimal. | ||||
41 | # Limited to three digits to avoid overflow when converting to decimal | ||||
42 | # form and also avoid problematic style with excessive leading zeroes. | ||||
43 | |||||
44 | 1 | 3µs | 1 | 700ns | my $STRICT_DOTTED_DECIMAL_PART = qr/\.[0-9]{1,3}/; # spent 700ns making 1 call to version::CORE:qr |
45 | |||||
46 | # Second and subsequent part of a lax dotted-decimal version number. | ||||
47 | # Leading zeroes are permitted, and the number is always decimal. No | ||||
48 | # limit on the numerical value or number of digits, so there is the | ||||
49 | # possibility of overflow when converting to decimal form. | ||||
50 | |||||
51 | 1 | 3µs | 1 | 700ns | my $LAX_DOTTED_DECIMAL_PART = qr/\.[0-9]+/; # spent 700ns making 1 call to version::CORE:qr |
52 | |||||
53 | # Alpha suffix part of lax version number syntax. Acts like a | ||||
54 | # dotted-decimal part. | ||||
55 | |||||
56 | 1 | 3µs | 1 | 700ns | my $LAX_ALPHA_PART = qr/_[0-9]+/; # spent 700ns making 1 call to version::CORE:qr |
57 | |||||
58 | #--------------------------------------------------------------------------# | ||||
59 | # Strict version regexp definitions | ||||
60 | #--------------------------------------------------------------------------# | ||||
61 | |||||
62 | # Strict decimal version number. | ||||
63 | |||||
64 | 1 | 20µs | 2 | 12µs | my $STRICT_DECIMAL_VERSION = # spent 12µs making 1 call to version::CORE:regcomp
# spent 900ns making 1 call to version::CORE:qr |
65 | qr/ $STRICT_INTEGER_PART $FRACTION_PART? /x; | ||||
66 | |||||
67 | # Strict dotted-decimal version number. Must have both leading "v" and | ||||
68 | # at least three parts, to avoid confusion with decimal syntax. | ||||
69 | |||||
70 | 1 | 19µs | 2 | 14µs | my $STRICT_DOTTED_DECIMAL_VERSION = # spent 13µs making 1 call to version::CORE:regcomp
# spent 900ns making 1 call to version::CORE:qr |
71 | qr/ v $STRICT_INTEGER_PART $STRICT_DOTTED_DECIMAL_PART{2,} /x; | ||||
72 | |||||
73 | # Complete strict version number syntax -- should generally be used | ||||
74 | # anchored: qr/ \A $STRICT \z /x | ||||
75 | |||||
76 | 1 | 19µs | 2 | 13µs | $STRICT = # spent 12µs making 1 call to version::CORE:regcomp
# spent 1µs making 1 call to version::CORE:qr |
77 | qr/ $STRICT_DECIMAL_VERSION | $STRICT_DOTTED_DECIMAL_VERSION /x; | ||||
78 | |||||
79 | #--------------------------------------------------------------------------# | ||||
80 | # Lax version regexp definitions | ||||
81 | #--------------------------------------------------------------------------# | ||||
82 | |||||
83 | # Lax decimal version number. Just like the strict one except for | ||||
84 | # allowing an alpha suffix or allowing a leading or trailing | ||||
85 | # decimal-point | ||||
86 | |||||
87 | 1 | 20µs | 2 | 14µs | my $LAX_DECIMAL_VERSION = # spent 14µs making 1 call to version::CORE:regcomp
# spent 900ns making 1 call to version::CORE:qr |
88 | qr/ $LAX_INTEGER_PART (?: \. | $FRACTION_PART $LAX_ALPHA_PART? )? | ||||
89 | | | ||||
90 | $FRACTION_PART $LAX_ALPHA_PART? | ||||
91 | /x; | ||||
92 | |||||
93 | # Lax dotted-decimal version number. Distinguished by having either | ||||
94 | # leading "v" or at least three non-alpha parts. Alpha part is only | ||||
95 | # permitted if there are at least two non-alpha parts. Strangely | ||||
96 | # enough, without the leading "v", Perl takes .1.2 to mean v0.1.2, | ||||
97 | # so when there is no "v", the leading part is optional | ||||
98 | |||||
99 | 1 | 21µs | 2 | 13µs | my $LAX_DOTTED_DECIMAL_VERSION = # spent 12µs making 1 call to version::CORE:regcomp
# spent 1µs making 1 call to version::CORE:qr |
100 | qr/ | ||||
101 | v $LAX_INTEGER_PART (?: $LAX_DOTTED_DECIMAL_PART+ $LAX_ALPHA_PART? )? | ||||
102 | | | ||||
103 | $LAX_INTEGER_PART? $LAX_DOTTED_DECIMAL_PART{2,} $LAX_ALPHA_PART? | ||||
104 | /x; | ||||
105 | |||||
106 | # Complete lax version number syntax -- should generally be used | ||||
107 | # anchored: qr/ \A $LAX \z /x | ||||
108 | # | ||||
109 | # The string 'undef' is a special case to make for easier handling | ||||
110 | # of return values from ExtUtils::MM->parse_version | ||||
111 | |||||
112 | 1 | 29µs | 2 | 21µs | $LAX = # spent 20µs making 1 call to version::CORE:regcomp
# spent 800ns making 1 call to version::CORE:qr |
113 | qr/ undef | $LAX_DECIMAL_VERSION | $LAX_DOTTED_DECIMAL_VERSION /x; | ||||
114 | |||||
115 | #--------------------------------------------------------------------------# | ||||
116 | |||||
117 | # Preloaded methods go here. | ||||
118 | # spent 65µs within version::import which was called 4 times, avg 16µs/call:
# once (18µs+0s) by Perl::Critic::Policy::InputOutput::ProhibitTwoArgOpen::BEGIN@16 at line 16 of Perl/Critic/Policy/InputOutput/ProhibitTwoArgOpen.pm
# once (17µs+0s) by Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict::BEGIN@14 at line 14 of Perl/Critic/Policy/TestingAndDebugging/RequireUseStrict.pm
# once (16µs+0s) by Perl::Critic::Document::BEGIN@18 at line 18 of Perl/Critic/Document.pm
# once (13µs+0s) by Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::BEGIN@16 at line 16 of Perl/Critic/Policy/InputOutput/RequireEncodingWithUTF8Layer.pm | ||||
119 | 2 | 269µs | 2 | 29µs | # spent 18µs (8+10) within version::BEGIN@119 which was called:
# once (8µs+10µs) by Perl::Critic::Policy::Variables::RequireLexicalLoopIterators::BEGIN@14 at line 119 # spent 18µs making 1 call to version::BEGIN@119
# spent 10µs making 1 call to strict::unimport |
120 | 4 | 4µs | my ($class) = shift; | ||
121 | |||||
122 | # Set up any derived class | ||||
123 | 4 | 2µs | unless ($class eq 'version') { | ||
124 | local $^W; | ||||
125 | *{$class.'::declare'} = \&version::declare; | ||||
126 | *{$class.'::qv'} = \&version::qv; | ||||
127 | } | ||||
128 | |||||
129 | 4 | 1µs | my %args; | ||
130 | 4 | 2µs | if (@_) { # any remaining terms are arguments | ||
131 | map { $args{$_} = 1 } @_ | ||||
132 | } | ||||
133 | else { # no parameters at all on use line | ||||
134 | 4 | 7µs | %args = | ||
135 | ( | ||||
136 | qv => 1, | ||||
137 | 'UNIVERSAL::VERSION' => 1, | ||||
138 | ); | ||||
139 | } | ||||
140 | |||||
141 | 4 | 3µs | my $callpkg = caller(); | ||
142 | |||||
143 | 4 | 2µs | if (exists($args{declare})) { | ||
144 | *{$callpkg.'::declare'} = | ||||
145 | sub {return $class->declare(shift) } | ||||
146 | unless defined(&{$callpkg.'::declare'}); | ||||
147 | } | ||||
148 | |||||
149 | 4 | 27µs | if (exists($args{qv})) { | ||
150 | 1 | 12µs | 1 | 4µs | *{$callpkg.'::qv'} = # spent 4µs making 1 call to version::qv |
151 | # spent 11µs (7+4) within version::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/5.18.2/version.pm:151] which was called:
# once (7µs+4µs) by Module::Pluggable::Object::_require at line 28 of Perl/Critic/Policy/TestingAndDebugging/RequireUseStrict.pm | ||||
152 | unless defined(&{$callpkg.'::qv'}); | ||||
153 | } | ||||
154 | |||||
155 | 4 | 2µs | if (exists($args{'VERSION'})) { | ||
156 | *{$callpkg.'::VERSION'} = \&version::_VERSION; | ||||
157 | } | ||||
158 | |||||
159 | 4 | 2µs | if (exists($args{'is_strict'})) { | ||
160 | *{$callpkg.'::is_strict'} = \&version::is_strict | ||||
161 | unless defined(&{$callpkg.'::is_strict'}); | ||||
162 | } | ||||
163 | |||||
164 | 4 | 18µs | if (exists($args{'is_lax'})) { | ||
165 | *{$callpkg.'::is_lax'} = \&version::is_lax | ||||
166 | unless defined(&{$callpkg.'::is_lax'}); | ||||
167 | } | ||||
168 | } | ||||
169 | |||||
170 | sub is_strict { defined $_[0] && $_[0] =~ qr/ \A $STRICT \z /x } | ||||
171 | sub is_lax { defined $_[0] && $_[0] =~ qr/ \A $LAX \z /x } | ||||
172 | |||||
173 | 1 | 17µs | 1; | ||
# spent 2.83ms (2.20+620µs) within version::(<=> which was called 289 times, avg 10µs/call:
# 142 times (1.16ms+307µs) by Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Policy/TestingAndDebugging/RequireUseStrict.pm:116] at line 112 of Perl/Critic/Policy/TestingAndDebugging/RequireUseStrict.pm, avg 10µs/call
# 142 times (1.01ms+303µs) by Perl::Critic::Policy::Variables::RequireLexicalLoopIterators::prepare_to_scan_document at line 42 of Perl/Critic/Policy/Variables/RequireLexicalLoopIterators.pm, avg 9µs/call
# 5 times (35µs+10µs) by Perl::Critic::Policy::InputOutput::ProhibitTwoArgOpen::violates at line 48 of Perl/Critic/Policy/InputOutput/ProhibitTwoArgOpen.pm, avg 9µs/call | |||||
# spent 994µs within version::(bool which was called 295 times, avg 3µs/call:
# 147 times (590µs+0s) by Perl::Critic::Document::highest_explicit_perl_version at line 386 of Perl/Critic/Document.pm, avg 4µs/call
# 142 times (385µs+0s) by Perl::Critic::Policy::Variables::RequireLexicalLoopIterators::prepare_to_scan_document at line 42 of Perl/Critic/Policy/Variables/RequireLexicalLoopIterators.pm, avg 3µs/call
# 5 times (13µs+0s) by Perl::Critic::Policy::InputOutput::ProhibitTwoArgOpen::violates at line 48 of Perl/Critic/Policy/InputOutput/ProhibitTwoArgOpen.pm, avg 3µs/call
# once (7µs+0s) by Errno::BEGIN@8 at line 59 of Config.pm | |||||
# spent 4µs within version::(cmp which was called:
# once (4µs+0s) by Errno::BEGIN@8 at line 62 of Config.pm | |||||
# spent 11µs within version::CORE:qr which was called 12 times, avg 908ns/call:
# once (2µs+0s) by Perl::Critic::Policy::Variables::RequireLexicalLoopIterators::BEGIN@14 at line 20
# once (1µs+0s) by Perl::Critic::Policy::Variables::RequireLexicalLoopIterators::BEGIN@14 at line 99
# once (1µs+0s) by Perl::Critic::Policy::Variables::RequireLexicalLoopIterators::BEGIN@14 at line 76
# once (900ns+0s) by Perl::Critic::Policy::Variables::RequireLexicalLoopIterators::BEGIN@14 at line 26
# once (900ns+0s) by Perl::Critic::Policy::Variables::RequireLexicalLoopIterators::BEGIN@14 at line 70
# once (900ns+0s) by Perl::Critic::Policy::Variables::RequireLexicalLoopIterators::BEGIN@14 at line 64
# once (900ns+0s) by Perl::Critic::Policy::Variables::RequireLexicalLoopIterators::BEGIN@14 at line 87
# once (800ns+0s) by Perl::Critic::Policy::Variables::RequireLexicalLoopIterators::BEGIN@14 at line 112
# once (700ns+0s) by Perl::Critic::Policy::Variables::RequireLexicalLoopIterators::BEGIN@14 at line 51
# once (700ns+0s) by Perl::Critic::Policy::Variables::RequireLexicalLoopIterators::BEGIN@14 at line 37
# once (700ns+0s) by Perl::Critic::Policy::Variables::RequireLexicalLoopIterators::BEGIN@14 at line 56
# once (700ns+0s) by Perl::Critic::Policy::Variables::RequireLexicalLoopIterators::BEGIN@14 at line 44 | |||||
# spent 82µs within version::CORE:regcomp which was called 6 times, avg 14µs/call:
# once (20µs+0s) by Perl::Critic::Policy::Variables::RequireLexicalLoopIterators::BEGIN@14 at line 112
# once (14µs+0s) by Perl::Critic::Policy::Variables::RequireLexicalLoopIterators::BEGIN@14 at line 87
# once (13µs+0s) by Perl::Critic::Policy::Variables::RequireLexicalLoopIterators::BEGIN@14 at line 70
# once (12µs+0s) by Perl::Critic::Policy::Variables::RequireLexicalLoopIterators::BEGIN@14 at line 76
# once (12µs+0s) by Perl::Critic::Policy::Variables::RequireLexicalLoopIterators::BEGIN@14 at line 99
# once (12µs+0s) by Perl::Critic::Policy::Variables::RequireLexicalLoopIterators::BEGIN@14 at line 64 | |||||
# spent 649µs within version::new which was called 146 times, avg 4µs/call:
# 142 times (625µs+0s) by Perl::Critic::Document::highest_explicit_perl_version at line 375 of Perl/Critic/Document.pm, avg 4µs/call
# once (6µs+0s) by Module::Pluggable::Object::_require at line 30 of Perl/Critic/Policy/InputOutput/ProhibitTwoArgOpen.pm
# once (6µs+0s) by Module::Pluggable::Object::_require at line 28 of Perl/Critic/Policy/TestingAndDebugging/RequireUseWarnings.pm
# once (6µs+0s) by Module::Pluggable::Object::_require at line 26 of Perl/Critic/Policy/Variables/RequireLexicalLoopIterators.pm
# once (6µs+0s) by Module::Pluggable::Object::_require at line 27 of Perl/Critic/Policy/BuiltinFunctions/ProhibitLvalueSubstr.pm | |||||
# spent 732µs within version::parse which was called 142 times, avg 5µs/call:
# 142 times (732µs+0s) by Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Policy/TestingAndDebugging/RequireUseStrict.pm:116] at line 110 of Perl/Critic/Policy/TestingAndDebugging/RequireUseStrict.pm, avg 5µs/call | |||||
# spent 4µs within version::qv which was called:
# once (4µs+0s) by version::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/5.18.2/version.pm:151] at line 150 |