← Index
NYTProf Performance Profile   « line view »
For split.pl
  Run on Thu Apr 20 02:05:47 2023
Reported on Thu Apr 20 18:31:10 2023

Filename/usr/lib/x86_64-linux-gnu/perl-base/feature.pm
StatementsExecuted 155 statements in 138µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
31191µs91µsfeature::::__commonfeature::__common
3339µs100µsfeature::::importfeature::import
0000s0sfeature::::croakfeature::croak
0000s0sfeature::::feature_bundlefeature::feature_bundle
0000s0sfeature::::feature_enabledfeature::feature_enabled
0000s0sfeature::::features_enabledfeature::features_enabled
0000s0sfeature::::unimportfeature::unimport
0000s0sfeature::::unknown_featurefeature::unknown_feature
0000s0sfeature::::unknown_feature_bundlefeature::unknown_feature_bundle
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# -*- buffer-read-only: t -*-
2# !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
3# This file is built by regen/feature.pl.
4# Any changes made here will be lost!
5
6package feature;
7
81300nsour $VERSION = '1.72';
9
1017µsour %feature = (
11 fc => 'feature_fc',
12 isa => 'feature_isa',
13 say => 'feature_say',
14 try => 'feature_try',
15 defer => 'feature_defer',
16 state => 'feature_state',
17 switch => 'feature_switch',
18 bitwise => 'feature_bitwise',
19 indirect => 'feature_indirect',
20 evalbytes => 'feature_evalbytes',
21 signatures => 'feature_signatures',
22 current_sub => 'feature___SUB__',
23 refaliasing => 'feature_refaliasing',
24 postderef_qq => 'feature_postderef_qq',
25 unicode_eval => 'feature_unieval',
26 declared_refs => 'feature_myref',
27 unicode_strings => 'feature_unicode',
28 multidimensional => 'feature_multidimensional',
29 bareword_filehandles => 'feature_bareword_filehandles',
30 extra_paired_delimiters => 'feature_more_delims',
31);
32
3315µsour %feature_bundle = (
34 "5.10" => [qw(bareword_filehandles indirect multidimensional say state switch)],
35 "5.11" => [qw(bareword_filehandles indirect multidimensional say state switch unicode_strings)],
36 "5.15" => [qw(bareword_filehandles current_sub evalbytes fc indirect multidimensional say state switch unicode_eval unicode_strings)],
37 "5.23" => [qw(bareword_filehandles current_sub evalbytes fc indirect multidimensional postderef_qq say state switch unicode_eval unicode_strings)],
38 "5.27" => [qw(bareword_filehandles bitwise current_sub evalbytes fc indirect multidimensional postderef_qq say state switch unicode_eval unicode_strings)],
39 "5.35" => [qw(bareword_filehandles bitwise current_sub evalbytes fc isa postderef_qq say signatures state unicode_eval unicode_strings)],
40 "all" => [qw(bareword_filehandles bitwise current_sub declared_refs defer evalbytes extra_paired_delimiters fc indirect isa multidimensional postderef_qq refaliasing say signatures state switch try unicode_eval unicode_strings)],
41 "default" => [qw(bareword_filehandles indirect multidimensional)],
42);
43
441400ns$feature_bundle{"5.12"} = $feature_bundle{"5.11"};
451200ns$feature_bundle{"5.13"} = $feature_bundle{"5.11"};
461200ns$feature_bundle{"5.14"} = $feature_bundle{"5.11"};
471500ns$feature_bundle{"5.16"} = $feature_bundle{"5.15"};
481200ns$feature_bundle{"5.17"} = $feature_bundle{"5.15"};
491100ns$feature_bundle{"5.18"} = $feature_bundle{"5.15"};
501100ns$feature_bundle{"5.19"} = $feature_bundle{"5.15"};
511200ns$feature_bundle{"5.20"} = $feature_bundle{"5.15"};
521100ns$feature_bundle{"5.21"} = $feature_bundle{"5.15"};
531100ns$feature_bundle{"5.22"} = $feature_bundle{"5.15"};
541100ns$feature_bundle{"5.24"} = $feature_bundle{"5.23"};
551100ns$feature_bundle{"5.25"} = $feature_bundle{"5.23"};
561100ns$feature_bundle{"5.26"} = $feature_bundle{"5.23"};
571700ns$feature_bundle{"5.28"} = $feature_bundle{"5.27"};
581100ns$feature_bundle{"5.29"} = $feature_bundle{"5.27"};
591100ns$feature_bundle{"5.30"} = $feature_bundle{"5.27"};
601100ns$feature_bundle{"5.31"} = $feature_bundle{"5.27"};
611100ns$feature_bundle{"5.32"} = $feature_bundle{"5.27"};
621100ns$feature_bundle{"5.33"} = $feature_bundle{"5.27"};
631100ns$feature_bundle{"5.34"} = $feature_bundle{"5.27"};
641200ns$feature_bundle{"5.36"} = $feature_bundle{"5.35"};
651100ns$feature_bundle{"5.9.5"} = $feature_bundle{"5.10"};
661900nsmy %noops = (
67 postderef => 1,
68 lexical_subs => 1,
69);
701600nsmy %removed = (
71 array_base => 1,
72);
73
741100nsour $hint_shift = 26;
751100nsour $hint_mask = 0x3c000000;
761700nsour @hint_bundles = qw( default 5.10 5.11 5.15 5.23 5.27 5.35 );
77
78# This gets set (for now) in $^H as well as in %^H,
79# for runtime speed of the uc/lc/ucfirst/lcfirst functions.
80# See HINT_UNI_8_BIT in perl.h.
811200nsour $hint_uni8bit = 0x00000800;
82
83# TODO:
84# - think about versioned features (use feature switch => 2)
85
86
# spent 100µs (9+91) within feature::import which was called 3 times, avg 34µs/call: # once (3µs+34µs) by Gradescope::Translate::BEGIN@12 at line 12 of /home/hejohns/documentsNoSync/22f/490/gradescope-utils/lib/Gradescope/Translate.pm # once (4µs+29µs) by main::BEGIN@43 at line 43 of /home/hejohns/documentsNoSync/22f/490/gradescope-utils/bin/split.pl # once (2µs+28µs) by Gradescope::Color::BEGIN@12 at line 12 of /home/hejohns/documentsNoSync/22f/490/gradescope-utils/lib/Gradescope/Color.pm
sub import {
873300ns shift;
88
893800ns if (!@_) {
90 croak("No features specified");
91 }
92
9337µs391µs __common(1, @_);
# spent 91µs making 3 calls to feature::__common, avg 30µs/call
94}
95
96sub unimport {
97 shift;
98
99 # A bare C<no feature> should reset to the default bundle
100 if (!@_) {
101 $^H &= ~($hint_uni8bit|$hint_mask);
102 return;
103 }
104
105 __common(0, @_);
106}
107
108
# spent 91µs within feature::__common which was called 3 times, avg 30µs/call: # 3 times (91µs+0s) by feature::import at line 93, avg 30µs/call
sub __common {
1093600ns my $import = shift;
11032µs my $bundle_number = $^H & $hint_mask;
111 my $features = $bundle_number != $hint_mask
11232µs && $feature_bundle{$hint_bundles[$bundle_number >> $hint_shift]};
1133900ns if ($features) {
114 # Features are enabled implicitly via bundle hints.
115 # Delete any keys that may be left over from last time.
116342µs delete @^H{ values(%feature) };
11731µs $^H |= $hint_mask;
11832µs for (@$features) {
1193623µs $^H{$feature{$_}} = 1;
120367µs $^H |= $hint_uni8bit if $_ eq 'unicode_strings';
121 }
122 }
12336µs while (@_) {
1243700ns my $name = shift;
12532µs if (substr($name, 0, 1) eq ":") {
126 my $v = substr($name, 1);
127 if (!exists $feature_bundle{$v}) {
128 $v =~ s/^([0-9]+)\.([0-9]+).[0-9]+$/$1.$2/;
129 if (!exists $feature_bundle{$v}) {
130 unknown_feature_bundle(substr($name, 1));
131 }
132 }
133 unshift @_, @{$feature_bundle{$v}};
134 next;
135 }
1363800ns if (!exists $feature{$name}) {
137 if (exists $noops{$name}) {
138 next;
139 }
140 if (!$import && exists $removed{$name}) {
141 next;
142 }
143 unknown_feature($name);
144 }
14532µs if ($import) {
14632µs $^H{$feature{$name}} = 1;
1473400ns $^H |= $hint_uni8bit if $name eq 'unicode_strings';
148 } else {
149 delete $^H{$feature{$name}};
150 $^H &= ~ $hint_uni8bit if $name eq 'unicode_strings';
151 }
152 }
153}
154
155sub unknown_feature {
156 my $feature = shift;
157 croak(sprintf('Feature "%s" is not supported by Perl %vd',
158 $feature, $^V));
159}
160
161sub unknown_feature_bundle {
162 my $feature = shift;
163 croak(sprintf('Feature bundle "%s" is not supported by Perl %vd',
164 $feature, $^V));
165}
166
167sub croak {
168 require Carp;
169 Carp::croak(@_);
170}
171
172sub features_enabled {
173 my ($depth) = @_;
174
175 $depth //= 1;
176 my @frame = caller($depth+1)
177 or return;
178 my ($hints, $hinthash) = @frame[8, 10];
179
180 my $bundle_number = $hints & $hint_mask;
181 if ($bundle_number != $hint_mask) {
182 return $feature_bundle{$hint_bundles[$bundle_number >> $hint_shift]}->@*;
183 }
184 else {
185 my @features;
186 for my $feature (sort keys %feature) {
187 if ($hinthash->{$feature{$feature}}) {
188 push @features, $feature;
189 }
190 }
191 return @features;
192 }
193}
194
195sub feature_enabled {
196 my ($feature, $depth) = @_;
197
198 $depth //= 1;
199 my @frame = caller($depth+1)
200 or return;
201 my ($hints, $hinthash) = @frame[8, 10];
202
203 my $hint_feature = $feature{$feature}
204 or croak "Unknown feature $feature";
205 my $bundle_number = $hints & $hint_mask;
206 if ($bundle_number != $hint_mask) {
207 my $bundle = $hint_bundles[$bundle_number >> $hint_shift];
208 for my $bundle_feature ($feature_bundle{$bundle}->@*) {
209 return 1 if $bundle_feature eq $feature;
210 }
211 return 0;
212 }
213 else {
214 return $hinthash->{$hint_feature} // 0;
215 }
216}
217
218sub feature_bundle {
219 my $depth = shift;
220
221 $depth //= 1;
222 my @frame = caller($depth+1)
223 or return;
224 my $bundle_number = $frame[8] & $hint_mask;
225 if ($bundle_number != $hint_mask) {
226 return $hint_bundles[$bundle_number >> $hint_shift];
227 }
228 else {
229 return undef;
230 }
231}
232
233117µs1;
234
235# ex: set ro: