← Index
NYTProf Performance Profile   « line view »
For /usr/local/bin/sa-learn
  Run on Tue Nov 7 05:38:10 2017
Reported on Tue Nov 7 06:16:04 2017

Filename/usr/local/lib/perl5/site_perl/URI/_idna.pm
StatementsExecuted 13 statements in 1.69ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1112.74ms4.66msURI::_idna::::BEGIN@9URI::_idna::BEGIN@9
11143µs55µsURI::_idna::::BEGIN@6URI::_idna::BEGIN@6
11125µs155µsURI::_idna::::BEGIN@10URI::_idna::BEGIN@10
11118µs56µsURI::_idna::::BEGIN@7URI::_idna::BEGIN@7
11118µs18µsURI::_idna::::BEGIN@15URI::_idna::BEGIN@15
1114µs4µsURI::_idna::::CORE:qrURI::_idna::CORE:qr (opcode)
0000s0sURI::_idna::::ToASCIIURI::_idna::ToASCII
0000s0sURI::_idna::::ToUnicodeURI::_idna::ToUnicode
0000s0sURI::_idna::::check_sizeURI::_idna::check_size
0000s0sURI::_idna::::decodeURI::_idna::decode
0000s0sURI::_idna::::encodeURI::_idna::encode
0000s0sURI::_idna::::nameprepURI::_idna::nameprep
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package URI::_idna;
2
3# This module implements the RFCs 3490 (IDNA) and 3491 (Nameprep)
4# based on Python-2.6.4/Lib/encodings/idna.py
5
6268µs267µs
# spent 55µs (43+12) within URI::_idna::BEGIN@6 which was called: # once (43µs+12µs) by IO::Socket::SSL::PublicSuffix::BEGIN@122 at line 6
use strict;
# spent 55µs making 1 call to URI::_idna::BEGIN@6 # spent 12µs making 1 call to strict::import
72102µs293µs
# spent 56µs (18+37) within URI::_idna::BEGIN@7 which was called: # once (18µs+37µs) by IO::Socket::SSL::PublicSuffix::BEGIN@122 at line 7
use warnings;
# spent 56µs making 1 call to URI::_idna::BEGIN@7 # spent 37µs making 1 call to warnings::import
8
92275µs24.86ms
# spent 4.66ms (2.74+1.92) within URI::_idna::BEGIN@9 which was called: # once (2.74ms+1.92ms) by IO::Socket::SSL::PublicSuffix::BEGIN@122 at line 9
use URI::_punycode qw(encode_punycode decode_punycode);
# spent 4.66ms making 1 call to URI::_idna::BEGIN@9 # spent 204µs making 1 call to Exporter::import
102207µs2286µs
# spent 155µs (25+131) within URI::_idna::BEGIN@10 which was called: # once (25µs+131µs) by IO::Socket::SSL::PublicSuffix::BEGIN@122 at line 10
use Carp qw(croak);
# spent 155µs making 1 call to URI::_idna::BEGIN@10 # spent 131µs making 1 call to Exporter::import
11
1212µsour $VERSION = '1.72';
13139µs$VERSION = eval $VERSION;
# spent 6µs executing statements in string eval
14
15
# spent 18µs within URI::_idna::BEGIN@15 which was called: # once (18µs+0s) by IO::Socket::SSL::PublicSuffix::BEGIN@122 at line 20
BEGIN {
16 *URI::_idna::_ENV_::JOIN_LEAKS_UTF8_FLAGS = "$]" < 5.008_003
17 ? sub () { 1 }
18 : sub () { 0 }
19114µs ;
201953µs118µs}
# spent 18µs making 1 call to URI::_idna::BEGIN@15
21
22119µs14µsmy $ASCII = qr/^[\x00-\x7F]*\z/;
# spent 4µs making 1 call to URI::_idna::CORE:qr
23
24sub encode {
25 my $idomain = shift;
26 my @labels = split(/\./, $idomain, -1);
27 my @last_empty;
28 push(@last_empty, pop @labels) if @labels > 1 && $labels[-1] eq "";
29 for (@labels) {
30 $_ = ToASCII($_);
31 }
32
33 return eval 'join(".", @labels, @last_empty)' if URI::_idna::_ENV_::JOIN_LEAKS_UTF8_FLAGS;
34 return join(".", @labels, @last_empty);
35}
36
37sub decode {
38 my $domain = shift;
39 return join(".", map ToUnicode($_), split(/\./, $domain, -1))
40}
41
42sub nameprep { # XXX real implementation missing
43 my $label = shift;
44 $label = lc($label);
45 return $label;
46}
47
48sub check_size {
49 my $label = shift;
50 croak "Label empty" if $label eq "";
51 croak "Label too long" if length($label) > 63;
52 return $label;
53}
54
55sub ToASCII {
56 my $label = shift;
57 return check_size($label) if $label =~ $ASCII;
58
59 # Step 2: nameprep
60 $label = nameprep($label);
61 # Step 3: UseSTD3ASCIIRules is false
62 # Step 4: try ASCII again
63 return check_size($label) if $label =~ $ASCII;
64
65 # Step 5: Check ACE prefix
66 if ($label =~ /^xn--/) {
67 croak "Label starts with ACE prefix";
68 }
69
70 # Step 6: Encode with PUNYCODE
71 $label = encode_punycode($label);
72
73 # Step 7: Prepend ACE prefix
74 $label = "xn--$label";
75
76 # Step 8: Check size
77 return check_size($label);
78}
79
80sub ToUnicode {
81 my $label = shift;
82 $label = nameprep($label) unless $label =~ $ASCII;
83 return $label unless $label =~ /^xn--/;
84 my $result = decode_punycode(substr($label, 4));
85 my $label2 = ToASCII($result);
86 if (lc($label) ne $label2) {
87 croak "IDNA does not round-trip: '\L$label\E' vs '$label2'";
88 }
89 return $result;
90}
91
9218µs1;
 
# spent 4µs within URI::_idna::CORE:qr which was called: # once (4µs+0s) by IO::Socket::SSL::PublicSuffix::BEGIN@122 at line 22
sub URI::_idna::CORE:qr; # opcode