← Index
NYTProf Performance Profile   « line view »
For /usr/local/bin/sa-learn
  Run on Sun Nov 5 02:36:06 2017
Reported on Sun Nov 5 02:56:21 2017

Filename/usr/local/lib/perl5/site_perl/URI/_idna.pm
StatementsExecuted 13 statements in 1.71ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1112.75ms4.71msURI::_idna::::BEGIN@9URI::_idna::BEGIN@9
11142µs56µsURI::_idna::::BEGIN@6URI::_idna::BEGIN@6
11126µs146µsURI::_idna::::BEGIN@10URI::_idna::BEGIN@10
11122µs22µsURI::_idna::::BEGIN@15URI::_idna::BEGIN@15
11120µs59µsURI::_idna::::BEGIN@7URI::_idna::BEGIN@7
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
6264µs271µs
# spent 56µs (42+14) within URI::_idna::BEGIN@6 which was called: # once (42µs+14µs) by IO::Socket::SSL::PublicSuffix::BEGIN@122 at line 6
use strict;
# spent 56µs making 1 call to URI::_idna::BEGIN@6 # spent 14µs making 1 call to strict::import
7274µs298µs
# spent 59µs (20+38) within URI::_idna::BEGIN@7 which was called: # once (20µs+38µs) by IO::Socket::SSL::PublicSuffix::BEGIN@122 at line 7
use warnings;
# spent 59µs making 1 call to URI::_idna::BEGIN@7 # spent 38µs making 1 call to warnings::import
8
92296µs24.92ms
# spent 4.71ms (2.75+1.96) within URI::_idna::BEGIN@9 which was called: # once (2.75ms+1.96ms) by IO::Socket::SSL::PublicSuffix::BEGIN@122 at line 9
use URI::_punycode qw(encode_punycode decode_punycode);
# spent 4.71ms making 1 call to URI::_idna::BEGIN@9 # spent 206µs making 1 call to Exporter::import
102232µs2267µs
# spent 146µs (26+120) within URI::_idna::BEGIN@10 which was called: # once (26µs+120µs) by IO::Socket::SSL::PublicSuffix::BEGIN@122 at line 10
use Carp qw(croak);
# spent 146µs making 1 call to URI::_idna::BEGIN@10 # spent 120µs making 1 call to Exporter::import
11
1212µsour $VERSION = '1.72';
13131µs$VERSION = eval $VERSION;
# spent 6µs executing statements in string eval
14
15
# spent 22µs within URI::_idna::BEGIN@15 which was called: # once (22µ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 ;
201968µs122µs}
# spent 22µ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