← Index
NYTProf Performance Profile   « line view »
For ../prof.pl
  Run on Wed Dec 14 15:33:55 2022
Reported on Wed Dec 14 15:40:02 2022

Filename/Users/ether/perl5/perlbrew/perls/36.0/lib/5.36.0/darwin-2level/Encode.pm
StatementsExecuted 154 statements in 6.70ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
105303411894ms894msEncode::utf8::::encode Encode::utf8::encode (xsub)
18772822590ms746msEncode::utf8::::decode Encode::utf8::decode (xsub)
1113.67ms8.10msEncode::::BEGIN@56 Encode::BEGIN@56
1112.81ms3.51msEncode::::BEGIN@53 Encode::BEGIN@53
1111.15ms1.24msEncode::::BEGIN@54 Encode::BEGIN@54
111833µs2.32msEncode::UTF_EBCDIC::::BEGIN@178Encode::UTF_EBCDIC::BEGIN@178
111833µs908µsEncode::utf8::::BEGIN@229 Encode::utf8::BEGIN@229
11152µs76µsEncode::::onBOOT Encode::onBOOT (xsub)
31149µs145µsEncode::::getEncoding Encode::getEncoding (recurses: max depth 1, inclusive time 8µs)
72129µs29µsEncode::::define_encoding Encode::define_encoding
33322µs161µsEncode::::find_encoding Encode::find_encoding (recurses: max depth 1, inclusive time 14µs)
11121µs24µsEncode::::BEGIN@5 Encode::BEGIN@5
11111µs1.25msEncode::::BEGIN@9 Encode::BEGIN@9
11111µs11µsEncode::::CORE:match Encode::CORE:match (opcode)
11110µs21µsEncode::::BEGIN@15 Encode::BEGIN@15
1119µs30µsEncode::::BEGIN@7 Encode::BEGIN@7
3119µs9µsEncode::::CORE:subst Encode::CORE:subst (opcode)
1117µs31µsEncode::XS::::BEGIN@210 Encode::XS::BEGIN@210
1115µs14µsEncode::utf8::::BEGIN@215 Encode::utf8::BEGIN@215
1114µs31µsEncode::::BEGIN@6 Encode::BEGIN@6
2114µs4µsEncode::::find_alias Encode::find_alias
1112µs2µsEncode::::BEGIN@17 Encode::BEGIN@17
1112µs2µsEncode::::__ANON__ Encode::__ANON__ (xsub)
1111µs1µsEncode::::STOP_AT_PARTIAL Encode::STOP_AT_PARTIAL (xsub)
1110s0sEncode::::LEAVE_SRC Encode::LEAVE_SRC (xsub)
0000s0sEncode::UTF_EBCDIC::::decodeEncode::UTF_EBCDIC::decode
0000s0sEncode::UTF_EBCDIC::::encodeEncode::UTF_EBCDIC::encode
0000s0sEncode::::clone_encoding Encode::clone_encoding
0000s0sEncode::::define_alias Encode::define_alias
0000s0sEncode::::encodings Encode::encodings
0000s0sEncode::::find_mime_encoding Encode::find_mime_encoding
0000s0sEncode::::perlio_ok Encode::perlio_ok
0000s0sEncode::::resolve_alias Encode::resolve_alias
0000s0sEncode::utf8::::cat_decode Encode::utf8::cat_decode
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1#
2# $Id: Encode.pm,v 3.17 2022/04/07 03:05:51 dankogai Exp $
3#
4package Encode;
5222µs227µs
# spent 24µs (21+3) within Encode::BEGIN@5 which was called: # once (21µs+3µs) by OpenAPI::Modern::BEGIN@24 at line 5
use strict;
# spent 24µs making 1 call to Encode::BEGIN@5 # spent 3µs making 1 call to strict::import
6225µs258µs
# spent 31µs (4+27) within Encode::BEGIN@6 which was called: # once (4µs+27µs) by OpenAPI::Modern::BEGIN@24 at line 6
use warnings;
# spent 31µs making 1 call to Encode::BEGIN@6 # spent 27µs making 1 call to warnings::import
7252µs251µs
# spent 30µs (9+21) within Encode::BEGIN@7 which was called: # once (9µs+21µs) by OpenAPI::Modern::BEGIN@24 at line 7
use constant DEBUG => !!$ENV{PERL_ENCODE_DEBUG};
# spent 30µs making 1 call to Encode::BEGIN@7 # spent 21µs making 1 call to constant::import
8our $VERSION;
9
# spent 1.25ms (11µs+1.24) within Encode::BEGIN@9 which was called: # once (11µs+1.24ms) by OpenAPI::Modern::BEGIN@24 at line 13
BEGIN {
10116µs111µs $VERSION = sprintf "%d.%02d", q$Revision: 3.17 $ =~ /(\d+)/g;
# spent 11µs making 1 call to Encode::CORE:match
1110s require XSLoader;
1211.23ms11.22ms XSLoader::load( __PACKAGE__, $VERSION );
# spent 1.22ms making 1 call to XSLoader::load
13126µs11.25ms}
# spent 1.25ms making 1 call to Encode::BEGIN@9
14
15329µs332µs
# spent 21µs (10+11) within Encode::BEGIN@15 which was called: # once (10µs+11µs) by OpenAPI::Modern::BEGIN@24 at line 15
use Exporter 5.57 'import';
# spent 21µs making 1 call to Encode::BEGIN@15 # spent 6µs making 1 call to UNIVERSAL::VERSION # spent 5µs making 1 call to Exporter::import
16
17284µs12µs
# spent 2µs within Encode::BEGIN@17 which was called: # once (2µs+0s) by OpenAPI::Modern::BEGIN@24 at line 17
use Carp ();
# spent 2µs making 1 call to Encode::BEGIN@17
1811µsour @CARP_NOT = qw(Encode::Encoder);
19
20# Public, encouraged API is exported by default
21
2213µsour @EXPORT = qw(
23 decode decode_utf8 encode encode_utf8 str2bytes bytes2str
24 encodings find_encoding find_mime_encoding clone_encoding
25);
2611µsour @FB_FLAGS = qw(
27 DIE_ON_ERR WARN_ON_ERR RETURN_ON_ERR LEAVE_SRC
28 PERLQQ HTMLCREF XMLCREF STOP_AT_PARTIAL
29);
3011µsour @FB_CONSTS = qw(
31 FB_DEFAULT FB_CROAK FB_QUIET FB_WARN
32 FB_PERLQQ FB_HTMLCREF FB_XMLCREF
33);
3412µsour @EXPORT_OK = (
35 qw(
36 _utf8_off _utf8_on define_encoding from_to is_16bit is_8bit
37 is_utf8 perlio_ok resolve_alias utf8_downgrade utf8_upgrade
38 ),
39 @FB_FLAGS, @FB_CONSTS,
40);
41
4217µsour %EXPORT_TAGS = (
43 all => [ @EXPORT, @EXPORT_OK ],
44 default => [ @EXPORT ],
45 fallbacks => [ @FB_CONSTS ],
46 fallback_all => [ @FB_CONSTS, @FB_FLAGS ],
47);
48
49# Documentation moved after __END__ for speed - NI-S
50
5111µsour $ON_EBCDIC = ( ord("A") == 193 );
52
532531µs13.51ms
# spent 3.51ms (2.81+701µs) within Encode::BEGIN@53 which was called: # once (2.81ms+701µs) by OpenAPI::Modern::BEGIN@24 at line 53
use Encode::Alias ();
# spent 3.51ms making 1 call to Encode::BEGIN@53
542668µs21.25ms
# spent 1.24ms (1.15+95µs) within Encode::BEGIN@54 which was called: # once (1.15ms+95µs) by OpenAPI::Modern::BEGIN@24 at line 54
use Encode::MIME::Name;
# spent 1.24ms making 1 call to Encode::BEGIN@54 # spent 2µs making 1 call to Encode::__ANON__
55
5621.37ms28.14ms
# spent 8.10ms (3.67+4.43) within Encode::BEGIN@56 which was called: # once (3.67ms+4.43ms) by OpenAPI::Modern::BEGIN@24 at line 56
use Storable;
# spent 8.10ms making 1 call to Encode::BEGIN@56 # spent 45µs making 1 call to Exporter::import
57
58# Make a %Encoding package variable to allow a certain amount of cheating
59our %Encoding;
60our %ExtModule;
611617µsrequire Encode::Config;
62# See
63# https://bugzilla.redhat.com/show_bug.cgi?id=435505#c2
64# to find why sig handlers inside eval{} are disabled.
6511µseval {
6612µs local $SIG{__DIE__};
6710s local $SIG{__WARN__};
6811µs local @INC = @INC;
6910s pop @INC if @INC && $INC[-1] eq '.';
70183µs require Encode::ConfigLocal;
71};
72
73sub encodings {
74 my %enc;
75 my $arg = $_[1] || '';
76 if ( $arg eq ":all" ) {
77 %enc = ( %Encoding, %ExtModule );
78 }
79 else {
80 %enc = %Encoding;
81 for my $mod ( map { m/::/ ? $_ : "Encode::$_" } @_ ) {
82 DEBUG and warn $mod;
83 for my $enc ( keys %ExtModule ) {
84 $ExtModule{$enc} eq $mod and $enc{$enc} = $mod;
85 }
86 }
87 }
88 return sort { lc $a cmp lc $b }
89 grep { !/^(?:Internal|Unicode|Guess)$/o } keys %enc;
90}
91
92sub perlio_ok {
93 my $obj = ref( $_[0] ) ? $_[0] : find_encoding( $_[0] );
94 $obj->can("perlio_ok") and return $obj->perlio_ok();
95 return 0; # safety net
96}
97
98
# spent 29µs within Encode::define_encoding which was called 7 times, avg 4µs/call: # 5 times (24µs+0s) by Encode::onBOOT at line 174, avg 5µs/call # 2 times (5µs+0s) by OpenAPI::Modern::BEGIN@24 at line 222, avg 2µs/call
sub define_encoding {
9972µs my $obj = shift;
10072µs my $name = shift;
10172µs $Encoding{$name} = $obj;
10275µs my $lc = lc($name);
10372µs define_alias( $lc => $obj ) unless $lc eq $name;
10471µs while (@_) {
105 my $alias = shift;
106 define_alias( $alias, $obj );
107 }
10872µs my $class = ref($obj);
10974µs push @Encode::CARP_NOT, $class unless grep { $_ eq $class } @Encode::CARP_NOT;
11073µs push @Encode::Encoding::CARP_NOT, $class unless grep { $_ eq $class } @Encode::Encoding::CARP_NOT;
111715µs return $obj;
112}
113
114
# spent 145µs (49+96) within Encode::getEncoding which was called 3 times, avg 48µs/call: # 3 times (49µs+96µs) by Encode::find_encoding at line 153, avg 48µs/call
sub getEncoding {
11533µs my ( $class, $name, $skip_external ) = @_;
116
11732µs defined($name) or return;
118
119324µs39µs $name =~ s/\s+//g; # https://rt.cpan.org/Ticket/Display.html?id=65796
# spent 9µs making 3 calls to Encode::CORE:subst, avg 3µs/call
120
12130s ref($name) && $name->can('renew') and return $name;
12237µs exists $Encoding{$name} and return $Encoding{$name};
12322µs my $lc = lc $name;
12420s exists $Encoding{$lc} and return $Encoding{$lc};
125
12624µs24µs my $oc = $class->find_alias($name);
# spent 4µs making 2 calls to Encode::find_alias, avg 2µs/call
12725µs defined($oc) and return $oc;
128 $lc ne $name and $oc = $class->find_alias($lc);
129 defined($oc) and return $oc;
130
131 unless ($skip_external) {
132 if ( my $mod = $ExtModule{$name} || $ExtModule{$lc} ) {
133 $mod =~ s,::,/,g;
134 $mod .= '.pm';
135 eval { require $mod; };
136 exists $Encoding{$name} and return $Encoding{$name};
137 }
138 }
139 return;
140}
141
142# HACK: These two functions must be defined in Encode and because of
143# cyclic dependency between Encode and Encode::Alias, Exporter does not work
144
# spent 4µs within Encode::find_alias which was called 2 times, avg 2µs/call: # 2 times (4µs+0s) by Encode::getEncoding at line 126, avg 2µs/call
sub find_alias {
145213µs291µs goto &Encode::Alias::find_alias;
# spent 91µs making 2 calls to Encode::Alias::find_alias, avg 46µs/call
146}
147sub define_alias {
148 goto &Encode::Alias::define_alias;
149}
150
151
# spent 161µs (22+139) within Encode::find_encoding which was called 3 times, avg 54µs/call: # once (10µs+125µs) by YAML::PP::Reader::File::CORE:open at line 56 of YAML/PP/Reader.pm # once (6µs+20µs) by Mojo::Util::_encoding at line 444 of Mojo/Util.pm # once (6µs+-6µs) by Encode::Alias::find_alias at line 44 of Encode/Alias.pm
sub find_encoding($;$) {
15233µs my ( $name, $skip_external ) = @_;
153326µs3145µs return __PACKAGE__->getEncoding( $name, $skip_external );
# spent 153µs making 3 calls to Encode::getEncoding, avg 51µs/call, recursion: max depth 1, sum of overlapping time 8µs
154}
155
156sub find_mime_encoding($;$) {
157 my ( $mime_name, $skip_external ) = @_;
158 my $name = Encode::MIME::Name::get_encode_name( $mime_name );
159 return find_encoding( $name, $skip_external );
160}
161
162sub resolve_alias($) {
163 my $obj = find_encoding(shift);
164 defined $obj and return $obj->name;
165 return;
166}
167
168sub clone_encoding($) {
169 my $obj = find_encoding(shift);
170 ref $obj or return;
171 return Storable::dclone($obj);
172}
173
174152µs6100µsonBOOT;
# spent 76µs making 1 call to Encode::onBOOT # spent 24µs making 5 calls to Encode::define_encoding, avg 5µs/call
175
17611µsif ($ON_EBCDIC) {
177 package Encode::UTF_EBCDIC;
1782840µs23.74ms
# spent 2.32ms (833µs+1.49) within Encode::UTF_EBCDIC::BEGIN@178 which was called: # once (833µs+1.49ms) by OpenAPI::Modern::BEGIN@24 at line 178
use parent 'Encode::Encoding';
# spent 2.32ms making 1 call to Encode::UTF_EBCDIC::BEGIN@178 # spent 1.42ms making 1 call to parent::import
179 my $obj = bless { Name => "UTF_EBCDIC" } => "Encode::UTF_EBCDIC";
180 Encode::define_encoding($obj, 'Unicode');
181 sub decode {
182 my ( undef, $str, $chk ) = @_;
183 my $res = '';
184 for ( my $i = 0 ; $i < length($str) ; $i++ ) {
185 $res .=
186 chr(
187 utf8::unicode_to_native( ord( substr( $str, $i, 1 ) ) )
188 );
189 }
190 $_[1] = '' if $chk;
191 return $res;
192 }
193 sub encode {
194 my ( undef, $str, $chk ) = @_;
195 my $res = '';
196 for ( my $i = 0 ; $i < length($str) ; $i++ ) {
197 $res .=
198 chr(
199 utf8::native_to_unicode( ord( substr( $str, $i, 1 ) ) )
200 );
201 }
202 $_[1] = '' if $chk;
203 return $res;
204 }
205}
206
207{
208 # https://rt.cpan.org/Public/Bug/Display.html?id=103253
209 package Encode::XS;
210228µs255µs
# spent 31µs (7+24) within Encode::XS::BEGIN@210 which was called: # once (7µs+24µs) by OpenAPI::Modern::BEGIN@24 at line 210
use parent 'Encode::Encoding';
# spent 31µs making 1 call to Encode::XS::BEGIN@210 # spent 24µs making 1 call to parent::import
211}
212
213{
21411µs package Encode::utf8;
215289µs223µs
# spent 14µs (5+9) within Encode::utf8::BEGIN@215 which was called: # once (5µs+9µs) by OpenAPI::Modern::BEGIN@24 at line 215
use parent 'Encode::Encoding';
# spent 14µs making 1 call to Encode::utf8::BEGIN@215 # spent 9µs making 1 call to parent::import
21613µs my %obj = (
217 'utf8' => { Name => 'utf8' },
218 'utf-8-strict' => { Name => 'utf-8-strict', strict_utf8 => 1 }
219 );
22011µs for ( keys %obj ) {
22121µs bless $obj{$_} => __PACKAGE__;
22222µs25µs Encode::define_encoding( $obj{$_} => $_ );
# spent 5µs making 2 calls to Encode::define_encoding, avg 2µs/call
223 }
224 sub cat_decode {
225 # ($obj, $dst, $src, $pos, $trm, $chk)
226 # currently ignores $chk
227 my ( undef, undef, undef, $pos, $trm ) = @_;
228 my ( $rdst, $rsrc, $rpos ) = \@_[ 1, 2, 3 ];
2292760µs2911µs
# spent 908µs (833+75) within Encode::utf8::BEGIN@229 which was called: # once (833µs+75µs) by OpenAPI::Modern::BEGIN@24 at line 229
use bytes;
# spent 908µs making 1 call to Encode::utf8::BEGIN@229 # spent 3µs making 1 call to bytes::import
230 if ( ( my $npos = index( $$rsrc, $trm, $pos ) ) >= 0 ) {
231 $$rdst .=
232 substr( $$rsrc, $pos, $npos - $pos + length($trm) );
233 $$rpos = $npos + length($trm);
234 return 1;
235 }
236 $$rdst .= substr( $$rsrc, $pos );
237 $$rpos = length($$rsrc);
238 return '';
239 }
240}
241
242222µs1;
243
244__END__
 
# spent 11µs within Encode::CORE:match which was called: # once (11µs+0s) by Encode::BEGIN@9 at line 10
sub Encode::CORE:match; # opcode
# spent 9µs within Encode::CORE:subst which was called 3 times, avg 3µs/call: # 3 times (9µs+0s) by Encode::getEncoding at line 119, avg 3µs/call
sub Encode::CORE:subst; # opcode
# spent 0s within Encode::LEAVE_SRC which was called: # once (0s+0s) by XSLoader::load at line 115 of XSLoader.pm
sub Encode::LEAVE_SRC; # xsub
# spent 1µs within Encode::STOP_AT_PARTIAL which was called: # once (1µs+0s) by XSLoader::load at line 115 of XSLoader.pm
sub Encode::STOP_AT_PARTIAL; # xsub
# spent 2µs within Encode::__ANON__ which was called: # once (2µs+0s) by Encode::BEGIN@54 at line 54
sub Encode::__ANON__; # xsub
# spent 76µs (52+24) within Encode::onBOOT which was called: # once (52µs+24µs) by OpenAPI::Modern::BEGIN@24 at line 174
sub Encode::onBOOT; # xsub
# spent 746ms (590+156) within Encode::utf8::decode which was called 187728 times, avg 4µs/call: # 187289 times (587ms+155ms) by Mojo::Util::decode at line 122 of Mojo/Util.pm, avg 4µs/call # 439 times (3.27ms+954µs) by YAML::PP::Reader::File::CORE:readline at line 75 of YAML/PP/Reader.pm, avg 10µs/call
sub Encode::utf8::decode; # xsub
# spent 894ms within Encode::utf8::encode which was called 1053034 times, avg 849ns/call: # 1053034 times (894ms+0s) by Mojo::Util::encode at line 133 of Mojo/Util.pm, avg 849ns/call
sub Encode::utf8::encode; # xsub