← Index
NYTProf Performance Profile   « line view »
For flows_to_es.pl
  Run on Mon May 9 23:27:59 2016
Reported on Mon May 9 23:28:09 2016

Filename/usr/share/perl5/URI/_idna.pm
StatementsExecuted 77 statements in 840µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1111.45ms1.94msURI::_idna::::BEGIN@7URI::_idna::BEGIN@7
81151µs83µsURI::_idna::::ToASCIIURI::_idna::ToASCII
21134µs118µsURI::_idna::::encodeURI::_idna::encode
81114µs14µsURI::_idna::::check_sizeURI::_idna::check_size
11112µs26µsURI::_idna::::BEGIN@6URI::_idna::BEGIN@6
11110µs37µsURI::_idna::::BEGIN@8URI::_idna::BEGIN@8
81110µs10µsURI::_idna::::CORE:regcompURI::_idna::CORE:regcomp (opcode)
8119µs9µsURI::_idna::::CORE:matchURI::_idna::CORE:match (opcode)
1116µs6µsURI::_idna::::BEGIN@10URI::_idna::BEGIN@10
1112µ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
6233µs241µs
# spent 26µs (12+14) within URI::_idna::BEGIN@6 which was called: # once (12µs+14µs) by URI::_server::_host_escape at line 6
use strict;
# spent 26µs making 1 call to URI::_idna::BEGIN@6 # spent 14µs making 1 call to strict::import
72125µs21.98ms
# spent 1.94ms (1.45+487µs) within URI::_idna::BEGIN@7 which was called: # once (1.45ms+487µs) by URI::_server::_host_escape at line 7
use URI::_punycode qw(encode_punycode decode_punycode);
# spent 1.94ms making 1 call to URI::_idna::BEGIN@7 # spent 41µs making 1 call to Exporter::import
8270µs264µs
# spent 37µs (10+27) within URI::_idna::BEGIN@8 which was called: # once (10µs+27µs) by URI::_server::_host_escape at line 8
use Carp qw(croak);
# spent 37µs making 1 call to URI::_idna::BEGIN@8 # spent 27µs making 1 call to Exporter::import
9
10
# spent 6µs within URI::_idna::BEGIN@10 which was called: # once (6µs+0s) by URI::_server::_host_escape at line 15
BEGIN {
11 *URI::_idna::_ENV_::JOIN_LEAKS_UTF8_FLAGS = $] < 5.008_003
12 ? sub () { 1 }
13 : sub () { 0 }
1418µs ;
151471µs16µs}
# spent 6µs making 1 call to URI::_idna::BEGIN@10
16
17110µs12µsmy $ASCII = qr/^[\x00-\x7F]*\z/;
# spent 2µs making 1 call to URI::_idna::CORE:qr
18
19
# spent 118µs (34+83) within URI::_idna::encode which was called 2 times, avg 59µs/call: # 2 times (34µs+83µs) by URI::_server::_host_escape at line 25 of URI/_server.pm, avg 59µs/call
sub encode {
2021µs my $idomain = shift;
2127µs my @labels = split(/\./, $idomain, -1);
222300ns my @last_empty;
2322µs push(@last_empty, pop @labels) if @labels > 1 && $labels[-1] eq "";
2422µs for (@labels) {
25812µs883µs $_ = ToASCII($_);
# spent 83µs making 8 calls to URI::_idna::ToASCII, avg 10µs/call
26 }
27
28 return eval 'join(".", @labels, @last_empty)' if URI::_idna::_ENV_::JOIN_LEAKS_UTF8_FLAGS;
2928µs return join(".", @labels, @last_empty);
30}
31
32sub decode {
33 my $domain = shift;
34 return join(".", map ToUnicode($_), split(/\./, $domain, -1))
35}
36
37sub nameprep { # XXX real implementation missing
38 my $label = shift;
39 $label = lc($label);
40 return $label;
41}
42
43
# spent 14µs within URI::_idna::check_size which was called 8 times, avg 2µs/call: # 8 times (14µs+0s) by URI::_idna::ToASCII at line 52, avg 2µs/call
sub check_size {
4482µs my $label = shift;
4581µs croak "Label empty" if $label eq "";
4682µs croak "Label too long" if length($label) > 63;
47816µs return $label;
48}
49
50
# spent 83µs (51+32) within URI::_idna::ToASCII which was called 8 times, avg 10µs/call: # 8 times (51µs+32µs) by URI::_idna::encode at line 25, avg 10µs/call
sub ToASCII {
5182µs my $label = shift;
52867µs2432µs return check_size($label) if $label =~ $ASCII;
# spent 14µs making 8 calls to URI::_idna::check_size, avg 2µs/call # spent 10µs making 8 calls to URI::_idna::CORE:regcomp, avg 1µs/call # spent 9µs making 8 calls to URI::_idna::CORE:match, avg 1µs/call
53
54 # Step 2: nameprep
55 $label = nameprep($label);
56 # Step 3: UseSTD3ASCIIRules is false
57 # Step 4: try ASCII again
58 return check_size($label) if $label =~ $ASCII;
59
60 # Step 5: Check ACE prefix
61 if ($label =~ /^xn--/) {
62 croak "Label starts with ACE prefix";
63 }
64
65 # Step 6: Encode with PUNYCODE
66 $label = encode_punycode($label);
67
68 # Step 7: Prepend ACE prefix
69 $label = "xn--$label";
70
71 # Step 8: Check size
72 return check_size($label);
73}
74
75sub ToUnicode {
76 my $label = shift;
77 $label = nameprep($label) unless $label =~ $ASCII;
78 return $label unless $label =~ /^xn--/;
79 my $result = decode_punycode(substr($label, 4));
80 my $label2 = ToASCII($result);
81 if (lc($label) ne $label2) {
82 croak "IDNA does not round-trip: '\L$label\E' vs '$label2'";
83 }
84 return $result;
85}
86
8713µs1;
 
# spent 9µs within URI::_idna::CORE:match which was called 8 times, avg 1µs/call: # 8 times (9µs+0s) by URI::_idna::ToASCII at line 52, avg 1µs/call
sub URI::_idna::CORE:match; # opcode
# spent 2µs within URI::_idna::CORE:qr which was called: # once (2µs+0s) by URI::_server::_host_escape at line 17
sub URI::_idna::CORE:qr; # opcode
# spent 10µs within URI::_idna::CORE:regcomp which was called 8 times, avg 1µs/call: # 8 times (10µs+0s) by URI::_idna::ToASCII at line 52, avg 1µs/call
sub URI::_idna::CORE:regcomp; # opcode