Profile of /usr/local/lib/perl5/site_perl/5.10.1/URI/_idna.pm

← Index
NYTProf Performance Profile «block view•line view•sub view»
For 05.Domain_and_Item.t
Run on Tue May 4 17:21:41 2010
Reported on Tue May 4 17:23:07 2010

File | /usr/local/lib/perl5/site_perl/5.10.1/URI/_idna.pm
Statements Executed | 1145
Statement Execution Time | 2.84ms

Subroutines — ordered by exclusive time
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
1 | 1 | 1 | 979µs | 1.30ms | URI::_idna::::BEGIN@7URI::_idna::BEGIN@7
126 | 1 | 1 | 959µs | 1.60ms | URI::_idna::::ToASCIIURI::_idna::ToASCII
42 | 1 | 1 | 924µs | 2.52ms | URI::_idna::::encodeURI::_idna::encode
126 | 1 | 1 | 348µs | 348µs | URI::_idna::::check_sizeURI::_idna::check_size
126 | 1 | 2 | 165µs | 165µs | URI::_idna::::CORE:regcompURI::_idna::CORE:regcomp (opcode)
126 | 1 | 2 | 125µs | 125µs | URI::_idna::::CORE:matchURI::_idna::CORE:match (opcode)
1 | 1 | 1 | 14µs | 17µs | URI::_idna::::BEGIN@6URI::_idna::BEGIN@6
1 | 1 | 1 | 9µs | 32µs | URI::_idna::::BEGIN@8URI::_idna::BEGIN@8
1 | 1 | 2 | 2µs | 2µs | URI::_idna::::CORE:qrURI::_idna::CORE:qr (opcode)
0 | 0 | 0 | 0s | 0s | URI::_idna::::ToUnicodeURI::_idna::ToUnicode
0 | 0 | 0 | 0s | 0s | URI::_idna::::decodeURI::_idna::decode
0 | 0 | 0 | 0s | 0s | URI::_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
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | package 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 |  |  |  |  |
6 | 3 | 25µs | 2 | 20µs | # spent 17µs (14+3) within URI::_idna::BEGIN@6 which was called # once (14µs+3µs) by URI::_server::_host_escape at line 6 use strict; # spent 17µs making 1 call to URI::_idna::BEGIN@6 # spent 3µs making 1 call to strict::import
7 | 3 | 98µs | 2 | 1.34ms | # spent 1.30ms (979µs+317µs) within URI::_idna::BEGIN@7 which was called # once (979µs+317µs) by URI::_server::_host_escape at line 7 use URI::_punycode qw(encode_punycode decode_punycode); # spent 1.30ms making 1 call to URI::_idna::BEGIN@7 # spent 40µs making 1 call to Exporter::import
8 | 3 | 311µs | 2 | 55µs | # spent 32µs (9+23) within URI::_idna::BEGIN@8 which was called # once (9µs+23µs) by URI::_server::_host_escape at line 8 use Carp qw(croak); # spent 32µs making 1 call to URI::_idna::BEGIN@8 # spent 23µs making 1 call to Exporter::import
9 |  |  |  |  |
10 | 1 | 10µs | 1 | 2µs | my $ASCII = qr/^[\x00-\x7F]*\z/; # spent 2µs making 1 call to URI::_idna::CORE:qr
11 |  |  |  |  |
12 |  |  |  |  | # spent 2.52ms (924µs+1.60) within URI::_idna::encode which was called 42 times, avg 60µs/call: # 42 times (924µs+1.60ms) by URI::_server::_host_escape at line 24 of URI/_server.pm, avg 60µs/call sub encode {
13 | 42 | 30µs |  |  | my $idomain = shift;
14 | 42 | 185µs |  |  | my @labels = split(/\./, $idomain, -1);
15 | 42 | 13µs |  |  | my @last_empty;
16 | 42 | 88µs |  |  | push(@last_empty, pop @labels) if @labels > 1 && $labels[-1] eq "";
17 | 42 | 56µs |  |  | for (@labels) {
18 | 126 | 241µs | 126 | 1.60ms | $_ = ToASCII($_); # spent 1.60ms making 126 calls to URI::_idna::ToASCII, avg 13µs/call
19 |  |  |  |  | }
20 | 42 | 176µs |  |  | return join(".", @labels, @last_empty);
21 |  |  |  |  | }
22 |  |  |  |  |
23 |  |  |  |  | sub decode {
24 |  |  |  |  | my $domain = shift;
25 |  |  |  |  | return join(".", map ToUnicode($_), split(/\./, $domain, -1))
26 |  |  |  |  | }
27 |  |  |  |  |
28 |  |  |  |  | sub nameprep { # XXX real implementation missing
29 |  |  |  |  | my $label = shift;
30 |  |  |  |  | $label = lc($label);
31 |  |  |  |  | return $label;
32 |  |  |  |  | }
33 |  |  |  |  |
34 |  |  |  |  | # spent 348µs within URI::_idna::check_size which was called 126 times, avg 3µs/call: # 126 times (348µs+0s) by URI::_idna::ToASCII at line 43, avg 3µs/call sub check_size {
35 | 126 | 38µs |  |  | my $label = shift;
36 | 126 | 28µs |  |  | croak "Label empty" if $label eq "";
37 | 126 | 40µs |  |  | croak "Label too long" if length($label) > 63;
38 | 126 | 282µs |  |  | return $label;
39 |  |  |  |  | }
40 |  |  |  |  |
41 |  |  |  |  | # spent 1.60ms (959µs+638µs) within URI::_idna::ToASCII which was called 126 times, avg 13µs/call: # 126 times (959µs+638µs) by URI::_idna::encode at line 18, avg 13µs/call sub ToASCII {
42 | 126 | 44µs |  |  | my $label = shift;
43 | 126 | 1.17ms | 378 | 638µs | return check_size($label) if $label =~ $ASCII; # spent 348µs making 126 calls to URI::_idna::check_size, avg 3µs/call # spent 165µs making 126 calls to URI::_idna::CORE:regcomp, avg 1µs/call # spent 125µs making 126 calls to URI::_idna::CORE:match, avg 990ns/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 |  |  |  |  |
66 |  |  |  |  | sub 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 |  |  |  |  |
78 | 1 | 3µs |  |  | 1;
|  |  |  |  | # spent 125µs within URI::_idna::CORE:match which was called 126 times, avg 990ns/call: # 126 times (125µs+0s) by URI::_idna::ToASCII at line 43 of URI/_idna.pm, avg 990ns/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 165µs within URI::_idna::CORE:regcomp which was called 126 times, avg 1µs/call: # 126 times (165µs+0s) by URI::_idna::ToASCII at line 43 of URI/_idna.pm, avg 1µs/call sub URI::_idna::CORE:regcomp; # xsub