← Index
NYTProf Performance Profile   « block view • line view • sub view »
For 01.HTTP.t
  Run on Tue May 4 15:25:55 2010
Reported on Tue May 4 15:26:06 2010

File /usr/local/lib/perl5/site_perl/5.10.1/URI/_idna.pm
Statements Executed 119
Statement Execution Time 672µs
Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111947µs1.28msURI::_idna::::BEGIN@7URI::_idna::BEGIN@7
121195µs155µsURI::_idna::::ToASCIIURI::_idna::ToASCII
41182µs237µsURI::_idna::::encodeURI::_idna::encode
121133µs33µsURI::_idna::::check_sizeURI::_idna::check_size
11118µs21µsURI::_idna::::BEGIN@6URI::_idna::BEGIN@6
121214µs14µsURI::_idna::::CORE:regcompURI::_idna::CORE:regcomp (opcode)
121213µs13µsURI::_idna::::CORE:matchURI::_idna::CORE:match (opcode)
1117µs30µsURI::_idna::::BEGIN@8URI::_idna::BEGIN@8
1122µs2µsURI::_idna::::CORE:qrURI::_idna::CORE:qr (opcode)
0000s0sURI::_idna::::ToUnicodeURI::_idna::ToUnicode
0000s0sURI::_idna::::decodeURI::_idna::decode
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
6326µs224µs
# spent 21µs (18+3) within URI::_idna::BEGIN@6 which was called # once (18µs+3µs) by URI::_server::_host_escape at line 6
use strict;
# spent 21µs making 1 call to URI::_idna::BEGIN@6 # spent 3µs making 1 call to strict::import
7399µs21.32ms
# spent 1.28ms (947µs+328µs) within URI::_idna::BEGIN@7 which was called # once (947µs+328µs) by URI::_server::_host_escape at line 7
use URI::_punycode qw(encode_punycode decode_punycode);
# spent 1.28ms making 1 call to URI::_idna::BEGIN@7 # spent 42µs making 1 call to Exporter::import
83311µs252µs
# spent 30µs (7+23) within URI::_idna::BEGIN@8 which was called # once (7µs+23µs) by URI::_server::_host_escape at line 8
use Carp qw(croak);
# spent 30µs making 1 call to URI::_idna::BEGIN@8 # spent 22µs making 1 call to Exporter::import
9
1019µs12µsmy $ASCII = qr/^[\x00-\x7F]*\z/;
# spent 2µs making 1 call to URI::_idna::CORE:qr
11
12
# spent 237µs (82+155) within URI::_idna::encode which was called 4 times, avg 59µs/call: # 4 times (82µs+155µs) by URI::_server::_host_escape at line 24 of URI/_server.pm, avg 59µs/call
sub encode {
133670µs my $idomain = shift;
14 my @labels = split(/\./, $idomain, -1);
15 my @last_empty;
16 push(@last_empty, pop @labels) if @labels > 1 && $labels[-1] eq "";
17 for (@labels) {
18 $_ = ToASCII($_);
# spent 155µs making 12 calls to URI::_idna::ToASCII, avg 13µs/call
19 }
20 return join(".", @labels, @last_empty);
21}
22
23sub decode {
24 my $domain = shift;
25 return join(".", map ToUnicode($_), split(/\./, $domain, -1))
26}
27
28sub nameprep { # XXX real implementation missing
29 my $label = shift;
30 $label = lc($label);
31 return $label;
32}
33
34
# spent 33µs within URI::_idna::check_size which was called 12 times, avg 3µs/call: # 12 times (33µs+0s) by URI::_idna::ToASCII at line 43, avg 3µs/call
sub check_size {
354838µs my $label = shift;
36 croak "Label empty" if $label eq "";
37 croak "Label too long" if length($label) > 63;
38 return $label;
39}
40
41
# spent 155µs (95+60) within URI::_idna::ToASCII which was called 12 times, avg 13µs/call: # 12 times (95µs+60µs) by URI::_idna::encode at line 18, avg 13µs/call
sub ToASCII {
4224116µs my $label = shift;
43 return check_size($label) if $label =~ $ASCII;
# spent 33µs making 12 calls to URI::_idna::check_size, avg 3µs/call # spent 14µs making 12 calls to URI::_idna::CORE:regcomp, avg 1µs/call # spent 13µs making 12 calls to URI::_idna::CORE:match, avg 1µs/call
44
45 # Step 2: nameprep
46 $label = nameprep($label);
47 # Step 3: UseSTD3ASCIIRules is false
48 # Step 4: try ASCII again
49 return check_size($label) if $label =~ $ASCII;
50
51 # Step 5: Check ACE prefix
52 if ($label =~ /^xn--/) {
53 croak "Label starts with ACE prefix";
54 }
55
56 # Step 6: Encode with PUNYCODE
57 $label = encode_punycode($label);
58
59 # Step 7: Prepend ACE prefix
60 $label = "xn--$label";
61
62 # Step 8: Check size
63 return check_size($label);
64}
65
66sub ToUnicode {
67 my $label = shift;
68 $label = nameprep($label) unless $label =~ $ASCII;
69 return $label unless $label =~ /^xn--/;
70 my $label1 = decode_punycode(substr($label, 4));
71 my $label2 = ToASCII($label);
72 if (lc($label) ne $label2) {
73 croak "IDNA does not round-trip: '$label' vs '$label2'";
74 }
75 return $label1;
76}
77
7813µs1;
# spent 13µs within URI::_idna::CORE:match which was called 12 times, avg 1µs/call: # 12 times (13µs+0s) by URI::_idna::ToASCII at line 43 of URI/_idna.pm, avg 1µs/call
sub URI::_idna::CORE:match; # xsub
# spent 2µs within URI::_idna::CORE:qr which was called # once (2µs+0s) by URI::_server::_host_escape at line 10 of URI/_idna.pm
sub URI::_idna::CORE:qr; # xsub
# spent 14µs within URI::_idna::CORE:regcomp which was called 12 times, avg 1µs/call: # 12 times (14µs+0s) by URI::_idna::ToASCII at line 43 of URI/_idna.pm, avg 1µs/call
sub URI::_idna::CORE:regcomp; # xsub