← Index
NYTProf Performance Profile   « line view »
For /home/ss5/perl5/perlbrew/perls/perl-5.22.0/bin/benchmarkanything-storage
  Run on Mon Jan 29 16:55:34 2018
Reported on Mon Jan 29 16:57:07 2018

Filename/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/5.22.0/x86_64-linux/re.pm
StatementsExecuted 49 statements in 1.00ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
21117µs17µsre::::bitsre::bits
22210µs27µsre::::importre::import
1119µs11µsre::::BEGIN@4re::BEGIN@4
1116µs12µsre::::BEGIN@5re::BEGIN@5
0000s0sre::::_load_unloadre::_load_unload
0000s0sre::::setcolorre::setcolor
0000s0sre::::unimportre::unimport
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package re;
2
3# pragma for controlling the regexp engine
4217µs214µs
# spent 11µs (9+2) within re::BEGIN@4 which was called: # once (9µs+2µs) by Moose::Util::TypeConstraints::BEGIN@621 at line 4
use strict;
# spent 11µs making 1 call to re::BEGIN@4 # spent 2µs making 1 call to strict::import
52772µs218µs
# spent 12µs (6+6) within re::BEGIN@5 which was called: # once (6µs+6µs) by Moose::Util::TypeConstraints::BEGIN@621 at line 5
use warnings;
# spent 12µs making 1 call to re::BEGIN@5 # spent 6µs making 1 call to warnings::import
6
71300nsour $VERSION = "0.32";
815µsour @ISA = qw(Exporter);
91600nsour @EXPORT_OK = ('regmust',
10 qw(is_regexp regexp_pattern
11 regname regnames regnames_count));
1215µsour %EXPORT_OK = map { $_ => 1 } @EXPORT_OK;
13
1411µsmy %bitmask = (
15 taint => 0x00100000, # HINT_RE_TAINT
16 eval => 0x00200000, # HINT_RE_EVAL
17);
18
191200nsmy $flags_hint = 0x02000000; # HINT_RE_FLAGS
2010smy $PMMOD_SHIFT = 0;
2114µsmy %reflags = (
22 m => 1 << ($PMMOD_SHIFT + 0),
23 s => 1 << ($PMMOD_SHIFT + 1),
24 i => 1 << ($PMMOD_SHIFT + 2),
25 x => 1 << ($PMMOD_SHIFT + 3),
26 n => 1 << ($PMMOD_SHIFT + 5),
27 p => 1 << ($PMMOD_SHIFT + 6),
28 strict => 1 << ($PMMOD_SHIFT + 10),
29# special cases:
30 d => 0,
31 l => 1,
32 u => 2,
33 a => 3,
34 aa => 4,
35);
36
37sub setcolor {
38 eval { # Ignore errors
39 require Term::Cap;
40
41 my $terminal = Tgetent Term::Cap ({OSPEED => 9600}); # Avoid warning.
42 my $props = $ENV{PERL_RE_TC} || 'md,me,so,se,us,ue';
43 my @props = split /,/, $props;
44 my $colors = join "\t", map {$terminal->Tputs($_,1)} @props;
45
46 $colors =~ s/\0//g;
47 $ENV{PERL_RE_COLORS} = $colors;
48 };
49 if ($@) {
50 $ENV{PERL_RE_COLORS} ||= qq'\t\t> <\t> <\t\t';
51 }
52
53}
54
5514µsmy %flags = (
56 COMPILE => 0x0000FF,
57 PARSE => 0x000001,
58 OPTIMISE => 0x000002,
59 TRIEC => 0x000004,
60 DUMP => 0x000008,
61 FLAGS => 0x000010,
62 TEST => 0x000020,
63
64 EXECUTE => 0x00FF00,
65 INTUIT => 0x000100,
66 MATCH => 0x000200,
67 TRIEE => 0x000400,
68
69 EXTRA => 0xFF0000,
70 TRIEM => 0x010000,
71 OFFSETS => 0x020000,
72 OFFSETSDBG => 0x040000,
73 STATE => 0x080000,
74 OPTIMISEM => 0x100000,
75 STACK => 0x280000,
76 BUFFERS => 0x400000,
77 GPOS => 0x800000,
78);
791900ns$flags{ALL} = -1 & ~($flags{OFFSETS}|$flags{OFFSETSDBG}|$flags{BUFFERS});
801300ns$flags{All} = $flags{all} = $flags{DUMP} | $flags{EXECUTE};
811200ns$flags{Extra} = $flags{EXECUTE} | $flags{COMPILE} | $flags{GPOS};
821300ns$flags{More} = $flags{MORE} = $flags{All} | $flags{TRIEC} | $flags{TRIEM} | $flags{STATE};
831200ns$flags{State} = $flags{DUMP} | $flags{EXECUTE} | $flags{STATE};
841200ns$flags{TRIE} = $flags{DUMP} | $flags{EXECUTE} | $flags{TRIEC};
85
8612µsif (defined &DynaLoader::boot_DynaLoader) {
871500ns require XSLoader;
881151µs1146µs XSLoader::load();
# spent 146µs making 1 call to XSLoader::load
89}
90# else we're miniperl
91# We need to work for miniperl, because the XS toolchain uses Text::Wrap, which
92# uses re 'taint'.
93
94sub _load_unload {
95 my ($on)= @_;
96 if ($on) {
97 # We call install() every time, as if we didn't, we wouldn't
98 # "see" any changes to the color environment var since
99 # the last time it was called.
100
101 # install() returns an integer, which if casted properly
102 # in C resolves to a structure containing the regexp
103 # hooks. Setting it to a random integer will guarantee
104 # segfaults.
105 $^H{regcomp} = install();
106 } else {
107 delete $^H{regcomp};
108 }
109}
110
111
# spent 17µs within re::bits which was called 2 times, avg 8µs/call: # 2 times (17µs+0s) by re::import at line 275, avg 8µs/call
sub bits {
1122600ns my $on = shift;
1132500ns my $bits = 0;
11421µs my $turning_all_off = ! @_ && ! $on;
1152300ns my %seen; # Has flag already been seen?
1162500ns if ($turning_all_off) {
117
118 # Pretend were called with certain parameters, which are best dealt
119 # with that way.
120 push @_, keys %bitmask; # taint and eval
121 push @_, 'strict';
122 }
123
124 # Process each subpragma parameter
125 ARG:
12624µs foreach my $idx (0..$#_){
12722µs my $s=$_[$idx];
12824µs if ($s eq 'Debug' or $s eq 'Debugcolor') {
129 setcolor() if $s =~/color/i;
130 ${^RE_DEBUG_FLAGS} = 0 unless defined ${^RE_DEBUG_FLAGS};
131 for my $idx ($idx+1..$#_) {
132 if ($flags{$_[$idx]}) {
133 if ($on) {
134 ${^RE_DEBUG_FLAGS} |= $flags{$_[$idx]};
135 } else {
136 ${^RE_DEBUG_FLAGS} &= ~ $flags{$_[$idx]};
137 }
138 } else {
139 require Carp;
140 Carp::carp("Unknown \"re\" Debug flag '$_[$idx]', possible flags: ",
141 join(", ",sort keys %flags ) );
142 }
143 }
144 _load_unload($on ? 1 : ${^RE_DEBUG_FLAGS});
145 last;
146 } elsif ($s eq 'debug' or $s eq 'debugcolor') {
147 setcolor() if $s =~/color/i;
148 _load_unload($on);
149 last;
150 } elsif (exists $bitmask{$s}) {
151 $bits |= $bitmask{$s};
152 } elsif ($EXPORT_OK{$s}) {
153 require Exporter;
154 re->export_to_level(2, 're', $s);
155 } elsif ($s eq 'strict') {
156 if ($on) {
157 $^H{reflags} |= $reflags{$s};
158 warnings::warnif('experimental::re_strict',
159 "\"use re 'strict'\" is experimental");
160
161 # Turn on warnings if not already done.
162 if (! warnings::enabled('regexp')) {
163 require warnings;
164 warnings->import('regexp');
165 $^H{re_strict} = 1;
166 }
167 }
168 else {
169 $^H{reflags} &= ~$reflags{$s} if $^H{reflags};
170
171 # Turn off warnings if we turned them on.
172 warnings->unimport('regexp') if $^H{re_strict};
173 }
174 if ($^H{reflags}) {
175 $^H |= $flags_hint;
176 }
177 else {
178 $^H &= ~$flags_hint;
179 }
180 } elsif ($s =~ s/^\///) {
181 my $reflags = $^H{reflags} || 0;
182 my $seen_charset;
183 while ($s =~ m/( . )/gx) {
184 local $_ = $1;
185 if (/[adul]/) {
186 # The 'a' may be repeated; hide this from the rest of the
187 # code by counting and getting rid of all of them, then
188 # changing to 'aa' if there is a repeat.
189 if ($_ eq 'a') {
190 my $sav_pos = pos $s;
191 my $a_count = $s =~ s/a//g;
192 pos $s = $sav_pos - 1; # -1 because got rid of the 'a'
193 if ($a_count > 2) {
194 require Carp;
195 Carp::carp(
196 qq 'The "a" flag may only appear a maximum of twice'
197 );
198 }
199 elsif ($a_count == 2) {
200 $_ = 'aa';
201 }
202 }
203 if ($on) {
204 if ($seen_charset) {
205 require Carp;
206 if ($seen_charset ne $_) {
207 Carp::carp(
208 qq 'The "$seen_charset" and "$_" flags '
209 .qq 'are exclusive'
210 );
211 }
212 else {
213 Carp::carp(
214 qq 'The "$seen_charset" flag may not appear '
215 .qq 'twice'
216 );
217 }
218 }
219 $^H{reflags_charset} = $reflags{$_};
220 $seen_charset = $_;
221 }
222 else {
223 delete $^H{reflags_charset}
224 if defined $^H{reflags_charset}
225 && $^H{reflags_charset} == $reflags{$_};
226 }
227 } elsif (exists $reflags{$_}) {
228 $seen{$_}++;
229 $on
230 ? $reflags |= $reflags{$_}
231 : ($reflags &= ~$reflags{$_});
232 } else {
233 require Carp;
234 Carp::carp(
235 qq'Unknown regular expression flag "$_"'
236 );
237 next ARG;
238 }
239 }
240 ($^H{reflags} = $reflags or defined $^H{reflags_charset})
241 ? $^H |= $flags_hint
242 : ($^H &= ~$flags_hint);
243 } else {
244 require Carp;
245 Carp::carp("Unknown \"re\" subpragma '$s' (known ones are: ",
246 join(', ', map {qq('$_')} 'debug', 'debugcolor', sort keys %bitmask),
247 ")");
248 }
249 }
2502700ns if (exists $seen{'x'} && $seen{'x'} > 1
251 && (warnings::enabled("deprecated")
252 || warnings::enabled("regexp")))
253 {
254 my $message = "Having more than one /x regexp modifier is deprecated";
255 if (warnings::enabled("deprecated")) {
256 warnings::warn("deprecated", $message);
257 }
258 else {
259 warnings::warn("regexp", $message);
260 }
261 }
262
2632400ns if ($turning_all_off) {
264 _load_unload(0);
265 $^H{reflags} = 0;
266 $^H{reflags_charset} = 0;
267 $^H &= ~$flags_hint;
268 }
269
27026µs $bits;
271}
272
273
# spent 27µs (10+17) within re::import which was called 2 times, avg 13µs/call: # once (5µs+11µs) by B::Deparse::BEGIN@4589 at line 4589 of B/Deparse.pm # once (5µs+6µs) by Moose::Util::TypeConstraints::BEGIN@621 at line 621 of Moose/Util/TypeConstraints.pm
sub import {
2742500ns shift;
27528µs217µs $^H |= bits(1, @_);
# spent 17µs making 2 calls to re::bits, avg 8µs/call
276}
277
278sub unimport {
279 shift;
280 $^H &= ~ bits(0, @_);
281}
282
283111µs1;
284
285__END__