← 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/share/perl/5.36/ExtUtils/MakeMaker/Locale.pm
StatementsExecuted 40 statements in 873µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111242µs526µsExtUtils::MakeMaker::Locale::::_initExtUtils::MakeMaker::Locale::_init
11112µs25µsExtUtils::MakeMaker::Locale::::BEGIN@142ExtUtils::MakeMaker::Locale::BEGIN@142
11110µs12µsExtUtils::MakeMaker::Locale::::BEGIN@3ExtUtils::MakeMaker::Locale::BEGIN@3
1116µs10µsExtUtils::MakeMaker::Locale::::BEGIN@141ExtUtils::MakeMaker::Locale::BEGIN@141
1115µs46µsExtUtils::MakeMaker::Locale::::BEGIN@8ExtUtils::MakeMaker::Locale::BEGIN@8
1114µs7µsExtUtils::MakeMaker::Locale::::BEGIN@147ExtUtils::MakeMaker::Locale::BEGIN@147
1114µs23µsExtUtils::MakeMaker::Locale::::BEGIN@4ExtUtils::MakeMaker::Locale::BEGIN@4
2213µs3µsExtUtils::MakeMaker::Locale::::__ANON__[:144]ExtUtils::MakeMaker::Locale::__ANON__[:144]
1113µs3µsExtUtils::MakeMaker::Locale::::BEGIN@15ExtUtils::MakeMaker::Locale::BEGIN@15
1112µs2µsExtUtils::MakeMaker::Locale::::BEGIN@16ExtUtils::MakeMaker::Locale::BEGIN@16
0000s0sExtUtils::MakeMaker::Locale::::__ANON__[:33]ExtUtils::MakeMaker::Locale::__ANON__[:33]
0000s0sExtUtils::MakeMaker::Locale::::__ANON__[:52]ExtUtils::MakeMaker::Locale::__ANON__[:52]
0000s0sExtUtils::MakeMaker::Locale::::__ANON__[:56]ExtUtils::MakeMaker::Locale::__ANON__[:56]
0000s0sExtUtils::MakeMaker::Locale::::__ANON__[:57]ExtUtils::MakeMaker::Locale::__ANON__[:57]
0000s0sExtUtils::MakeMaker::Locale::::__ANON__[:63]ExtUtils::MakeMaker::Locale::__ANON__[:63]
0000s0sExtUtils::MakeMaker::Locale::::__ANON__[:65]ExtUtils::MakeMaker::Locale::__ANON__[:65]
0000s0sExtUtils::MakeMaker::Locale::::__ANON__[:76]ExtUtils::MakeMaker::Locale::__ANON__[:76]
0000s0sExtUtils::MakeMaker::Locale::::_flush_aliasesExtUtils::MakeMaker::Locale::_flush_aliases
0000s0sExtUtils::MakeMaker::Locale::::decode_argvExtUtils::MakeMaker::Locale::decode_argv
0000s0sExtUtils::MakeMaker::Locale::::envExtUtils::MakeMaker::Locale::env
0000s0sExtUtils::MakeMaker::Locale::::reinitExtUtils::MakeMaker::Locale::reinit
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package ExtUtils::MakeMaker::Locale;
2
3220µs213µs
# spent 12µs (10+2) within ExtUtils::MakeMaker::Locale::BEGIN@3 which was called: # once (10µs+2µs) by IPC::Cmd::can_run at line 3
use strict;
# spent 12µs making 1 call to ExtUtils::MakeMaker::Locale::BEGIN@3 # spent 2µs making 1 call to strict::import
4230µs242µs
# spent 23µs (4+19) within ExtUtils::MakeMaker::Locale::BEGIN@4 which was called: # once (4µs+19µs) by IPC::Cmd::can_run at line 4
use warnings;
# spent 23µs making 1 call to ExtUtils::MakeMaker::Locale::BEGIN@4 # spent 19µs making 1 call to warnings::import
51300nsour $VERSION = "7.64";
61900ns$VERSION =~ tr/_//d;
7
8229µs286µs
# spent 46µs (5+40) within ExtUtils::MakeMaker::Locale::BEGIN@8 which was called: # once (5µs+40µs) by IPC::Cmd::can_run at line 8
use base 'Exporter';
# spent 46µs making 1 call to ExtUtils::MakeMaker::Locale::BEGIN@8 # spent 40µs making 1 call to base::import
91900nsour @EXPORT_OK = qw(
10 decode_argv env
11 $ENCODING_LOCALE $ENCODING_LOCALE_FS
12 $ENCODING_CONSOLE_IN $ENCODING_CONSOLE_OUT
13);
14
15215µs13µs
# spent 3µs within ExtUtils::MakeMaker::Locale::BEGIN@15 which was called: # once (3µs+0s) by IPC::Cmd::can_run at line 15
use Encode ();
# spent 3µs making 1 call to ExtUtils::MakeMaker::Locale::BEGIN@15
162428µs12µs
# spent 2µs within ExtUtils::MakeMaker::Locale::BEGIN@16 which was called: # once (2µs+0s) by IPC::Cmd::can_run at line 16
use Encode::Alias ();
# spent 2µs making 1 call to ExtUtils::MakeMaker::Locale::BEGIN@16
17
18our $ENCODING_LOCALE;
19our $ENCODING_LOCALE_FS;
20our $ENCODING_CONSOLE_IN;
21our $ENCODING_CONSOLE_OUT;
22
23sub DEBUG () { 0 }
24
25
# spent 526µs (242+284) within ExtUtils::MakeMaker::Locale::_init which was called: # once (242µs+284µs) by IPC::Cmd::can_run at line 139
sub _init {
261800ns if ($^O eq "MSWin32") {
27 unless ($ENCODING_LOCALE) {
28 # Try to obtain what the Windows ANSI code page is
29 eval {
30 unless (defined &GetConsoleCP) {
31 require Win32;
32 # manually "import" it since Win32->import refuses
33 *GetConsoleCP = sub { &Win32::GetConsoleCP } if defined &Win32::GetConsoleCP;
34 }
35 unless (defined &GetConsoleCP) {
36 require Win32::API;
37 Win32::API->Import('kernel32', 'int GetConsoleCP()');
38 }
39 if (defined &GetConsoleCP) {
40 my $cp = GetConsoleCP();
41 $ENCODING_LOCALE = "cp$cp" if $cp;
42 }
43 };
44 }
45
46 unless ($ENCODING_CONSOLE_IN) {
47 # only test one since set together
48 unless (defined &GetInputCP) {
49 eval {
50 require Win32;
51 eval {
52 local $SIG{__WARN__} = sub {} if ( "$]" < 5.014 ); # suppress deprecation warning for inherited AUTOLOAD of Win32::GetConsoleCP()
53 Win32::GetConsoleCP();
54 };
55 # manually "import" it since Win32->import refuses
56 *GetInputCP = sub { &Win32::GetConsoleCP } if defined &Win32::GetConsoleCP;
57 *GetOutputCP = sub { &Win32::GetConsoleOutputCP } if defined &Win32::GetConsoleOutputCP;
58 };
59 unless (defined &GetInputCP) {
60 eval {
61 # try Win32::Console module for codepage to use
62 require Win32::Console;
63 *GetInputCP = sub { &Win32::Console::InputCP }
64 if defined &Win32::Console::InputCP;
65 *GetOutputCP = sub { &Win32::Console::OutputCP }
66 if defined &Win32::Console::OutputCP;
67 };
68 }
69 unless (defined &GetInputCP) {
70 # final fallback
71 *GetInputCP = *GetOutputCP = sub {
72 # another fallback that could work is:
73 # reg query HKLM\System\CurrentControlSet\Control\Nls\CodePage /v ACP
74 ((qx(chcp) || '') =~ /^Active code page: (\d+)/)
75 ? $1 : ();
76 };
77 }
78 }
79 my $cp = GetInputCP();
80 $ENCODING_CONSOLE_IN = "cp$cp" if $cp;
81 $cp = GetOutputCP();
82 $ENCODING_CONSOLE_OUT = "cp$cp" if $cp;
83 }
84 }
85
861100ns unless ($ENCODING_LOCALE) {
871200ns eval {
88191µs require I18N::Langinfo;
8918µs24µs $ENCODING_LOCALE = I18N::Langinfo::langinfo(I18N::Langinfo::CODESET());
# spent 3µs making 1 call to I18N::Langinfo::langinfo # spent 400ns making 1 call to I18N::Langinfo::CODESET
90
91 # Workaround of Encode < v2.25. The "646" encoding alias was
92 # introduced in Encode-2.25, but we don't want to require that version
93 # quite yet. Should avoid the CPAN testers failure reported from
94 # openbsd-4.7/perl-5.10.0 combo.
951200ns $ENCODING_LOCALE = "ascii" if $ENCODING_LOCALE eq "646";
96
97 # https://rt.cpan.org/Ticket/Display.html?id=66373
981800ns $ENCODING_LOCALE = "hp-roman8" if $^O eq "hpux" && $ENCODING_LOCALE eq "roman8";
99 };
1001200ns $ENCODING_LOCALE ||= $ENCODING_CONSOLE_IN;
101 }
102
103 # Workaround of Encode < v2.71 for "cp65000" and "cp65001"
104 # The "cp65000" and "cp65001" aliases were added in [Encode v2.71](https://github.com/dankogai/p5-encode/commit/7874bd95aa10967a3b5dbae333d16bcd703ac6c6)
105 # via commit <https://github.com/dankogai/p5-encode/commit/84b9c1101d5251d37e226f80d1c6781718779047>.
106 # This will avoid test failures for Win32 machines using the UTF-7 or UTF-8 code pages.
1071500ns $ENCODING_LOCALE = 'UTF-7' if $ENCODING_LOCALE && lc($ENCODING_LOCALE) eq "cp65000";
1081200ns $ENCODING_LOCALE = 'utf-8-strict' if $ENCODING_LOCALE && lc($ENCODING_LOCALE) eq "cp65001";
109
1101200ns if ($^O eq "darwin") {
111 $ENCODING_LOCALE_FS ||= "UTF-8";
112 }
113
114 # final fallback
11510s $ENCODING_LOCALE ||= $^O eq "MSWin32" ? "cp1252" : "UTF-8";
1161300ns $ENCODING_LOCALE_FS ||= $ENCODING_LOCALE;
1171100ns $ENCODING_CONSOLE_IN ||= $ENCODING_LOCALE;
1181200ns $ENCODING_CONSOLE_OUT ||= $ENCODING_CONSOLE_IN;
119
12013µs168µs unless (Encode::find_encoding($ENCODING_LOCALE)) {
# spent 68µs making 1 call to Encode::find_encoding
121 my $foundit;
122 if (lc($ENCODING_LOCALE) eq "gb18030") {
123 eval {
124 require Encode::HanExtra;
125 };
126 if ($@) {
127 die "Need Encode::HanExtra to be installed to support locale codeset ($ENCODING_LOCALE), stopped";
128 }
129 $foundit++ if Encode::find_encoding($ENCODING_LOCALE);
130 }
131 die "The locale codeset ($ENCODING_LOCALE) isn't one that perl can decode, stopped"
132 unless $foundit;
133
134 }
135
136 # use Data::Dump; ddx $ENCODING_LOCALE, $ENCODING_LOCALE_FS, $ENCODING_CONSOLE_IN, $ENCODING_CONSOLE_OUT;
137}
138
1391800ns1526µs_init();
# spent 526µs making 1 call to ExtUtils::MakeMaker::Locale::_init
140
# spent 3µs within ExtUtils::MakeMaker::Locale::__ANON__[/usr/share/perl/5.36/ExtUtils/MakeMaker/Locale.pm:144] which was called 2 times, avg 2µs/call: # once (2µs+0s) by Encode::Alias::define_alias at line 89 of Encode/Alias.pm # once (1µs+0s) by Encode::Alias::find_alias at line 36 of Encode/Alias.pm
Encode::Alias::define_alias(sub {
141223µs214µs
# spent 10µs (6+4) within ExtUtils::MakeMaker::Locale::BEGIN@141 which was called: # once (6µs+4µs) by IPC::Cmd::can_run at line 141
no strict 'refs';
# spent 10µs making 1 call to ExtUtils::MakeMaker::Locale::BEGIN@141 # spent 4µs making 1 call to strict::unimport
142239µs239µs
# spent 25µs (12+13) within ExtUtils::MakeMaker::Locale::BEGIN@142 which was called: # once (12µs+13µs) by IPC::Cmd::can_run at line 142
no warnings 'once';
# spent 25µs making 1 call to ExtUtils::MakeMaker::Locale::BEGIN@142 # spent 13µs making 1 call to warnings::unimport
14325µs return ${"ENCODING_" . uc(shift)};
14412µs19µs}, "locale");
# spent 9µs making 1 call to Encode::Alias::define_alias
145
146sub _flush_aliases {
1472167µs29µs
# spent 7µs (4+3) within ExtUtils::MakeMaker::Locale::BEGIN@147 which was called: # once (4µs+3µs) by IPC::Cmd::can_run at line 147
no strict 'refs';
# spent 7µs making 1 call to ExtUtils::MakeMaker::Locale::BEGIN@147 # spent 3µs making 1 call to strict::unimport
148 for my $a (sort keys %Encode::Alias::Alias) {
149 if (defined ${"ENCODING_" . uc($a)}) {
150 delete $Encode::Alias::Alias{$a};
151 warn "Flushed alias cache for $a" if DEBUG;
152 }
153 }
154}
155
156sub reinit {
157 $ENCODING_LOCALE = shift;
158 $ENCODING_LOCALE_FS = shift;
159 $ENCODING_CONSOLE_IN = $ENCODING_LOCALE;
160 $ENCODING_CONSOLE_OUT = $ENCODING_LOCALE;
161 _init();
162 _flush_aliases();
163}
164
165sub decode_argv {
166 die if defined wantarray;
167 for (@ARGV) {
168 $_ = Encode::decode(locale => $_, @_);
169 }
170}
171
172sub env {
173 my $k = Encode::encode(locale => shift);
174 my $old = $ENV{$k};
175 if (@_) {
176 my $v = shift;
177 if (defined $v) {
178 $ENV{$k} = Encode::encode(locale => $v);
179 }
180 else {
181 delete $ENV{$k};
182 }
183 }
184 return Encode::decode(locale => $old) if defined wantarray;
185}
186
18715µs1;
188
189__END__