Filename | /usr/local/lib/perl5/site_perl/Net/DNS/Domain.pm |
Statements | Executed 76071 statements in 714ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
3936 | 2 | 2 | 413ms | 500ms | new | Net::DNS::Domain::
1968 | 1 | 1 | 123ms | 194ms | name | Net::DNS::Domain::
15842 | 5 | 1 | 43.1ms | 43.1ms | CORE:subst (opcode) | Net::DNS::Domain::
1039 | 1 | 1 | 31.9ms | 41.9ms | _encode_utf8 | Net::DNS::Domain::
1038 | 1 | 1 | 28.9ms | 38.0ms | _decode_ascii | Net::DNS::Domain::
5627 | 2 | 1 | 20.1ms | 20.1ms | CORE:match (opcode) | Net::DNS::Domain::
1 | 1 | 1 | 1.49ms | 3.50ms | BEGIN@53 | Net::DNS::Domain::
773 | 5 | 1 | 1.47ms | 1.47ms | CORE:pack (opcode) | Net::DNS::Domain::
1 | 1 | 1 | 872µs | 2.54ms | BEGIN@54 | Net::DNS::Domain::
1 | 1 | 1 | 69µs | 249µs | BEGIN@56 | Net::DNS::Domain::
1 | 1 | 1 | 44µs | 53µs | BEGIN@38 | Net::DNS::Domain::
1 | 1 | 1 | 42µs | 285µs | BEGIN@44 | Net::DNS::Domain::
1 | 1 | 1 | 36µs | 276µs | BEGIN@49 | Net::DNS::Domain::
1 | 1 | 1 | 24µs | 38µs | BEGIN@40 | Net::DNS::Domain::
1 | 1 | 1 | 24µs | 260µs | BEGIN@41 | Net::DNS::Domain::
1 | 1 | 1 | 20µs | 48µs | BEGIN@39 | Net::DNS::Domain::
0 | 0 | 0 | 0s | 0s | __ANON__[:274] | Net::DNS::Domain::
0 | 0 | 0 | 0s | 0s | __ANON__[:284] | Net::DNS::Domain::
0 | 0 | 0 | 0s | 0s | _wire | Net::DNS::Domain::
0 | 0 | 0 | 0s | 0s | fqdn | Net::DNS::Domain::
0 | 0 | 0 | 0s | 0s | label | Net::DNS::Domain::
0 | 0 | 0 | 0s | 0s | origin | Net::DNS::Domain::
0 | 0 | 0 | 0s | 0s | string | Net::DNS::Domain::
0 | 0 | 0 | 0s | 0s | xname | Net::DNS::Domain::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Net::DNS::Domain; | ||||
2 | |||||
3 | # | ||||
4 | # $Id: Domain.pm 1603 2017-10-17 14:45:45Z willem $ | ||||
5 | # | ||||
6 | 1 | 3µs | our $VERSION = (qw$LastChangedRevision: 1603 $)[1]; | ||
7 | |||||
8 | |||||
9 | =head1 NAME | ||||
10 | |||||
11 | Net::DNS::Domain - DNS domains | ||||
12 | |||||
13 | =head1 SYNOPSIS | ||||
14 | |||||
15 | use Net::DNS::Domain; | ||||
16 | |||||
17 | $domain = new Net::DNS::Domain('example.com'); | ||||
18 | $name = $domain->name; | ||||
19 | |||||
20 | =head1 DESCRIPTION | ||||
21 | |||||
22 | The Net::DNS::Domain module implements a class of abstract DNS | ||||
23 | domain objects with associated class and instance methods. | ||||
24 | |||||
25 | Each domain object instance represents a single DNS domain which | ||||
26 | has a fixed identity throughout its lifetime. | ||||
27 | |||||
28 | Internally, the primary representation is a (possibly empty) list | ||||
29 | of ASCII domain name labels, and optional link to an arbitrary | ||||
30 | origin domain object topologically closer to the DNS root. | ||||
31 | |||||
32 | The computational expense of Unicode character-set conversion is | ||||
33 | partially mitigated by use of caches. | ||||
34 | |||||
35 | =cut | ||||
36 | |||||
37 | |||||
38 | 2 | 62µs | 2 | 62µs | # spent 53µs (44+9) within Net::DNS::Domain::BEGIN@38 which was called:
# once (44µs+9µs) by Net::DNS::RR::BEGIN@42 at line 38 # spent 53µs making 1 call to Net::DNS::Domain::BEGIN@38
# spent 9µs making 1 call to strict::import |
39 | 2 | 59µs | 2 | 75µs | # spent 48µs (20+27) within Net::DNS::Domain::BEGIN@39 which was called:
# once (20µs+27µs) by Net::DNS::RR::BEGIN@42 at line 39 # spent 48µs making 1 call to Net::DNS::Domain::BEGIN@39
# spent 27µs making 1 call to warnings::import |
40 | 2 | 100µs | 2 | 53µs | # spent 38µs (24+15) within Net::DNS::Domain::BEGIN@40 which was called:
# once (24µs+15µs) by Net::DNS::RR::BEGIN@42 at line 40 # spent 38µs making 1 call to Net::DNS::Domain::BEGIN@40
# spent 15µs making 1 call to integer::import |
41 | 2 | 100µs | 2 | 496µs | # spent 260µs (24+236) within Net::DNS::Domain::BEGIN@41 which was called:
# once (24µs+236µs) by Net::DNS::RR::BEGIN@42 at line 41 # spent 260µs making 1 call to Net::DNS::Domain::BEGIN@41
# spent 236µs making 1 call to Exporter::import |
42 | |||||
43 | |||||
44 | 1 | 2µs | # spent 285µs (42+242) within Net::DNS::Domain::BEGIN@44 which was called:
# once (42µs+242µs) by Net::DNS::RR::BEGIN@42 at line 47 | ||
45 | 1 | 9µs | require Encode; | ||
46 | 1 | 11µs | 1 | 46µs | Encode::find_encoding('ascii'); # spent 46µs making 1 call to Encode::find_encoding |
47 | 1 | 135µs | 2 | 481µs | }; # spent 285µs making 1 call to Net::DNS::Domain::BEGIN@44
# spent 196µs making 1 call to constant::import |
48 | |||||
49 | 1 | 2µs | # spent 276µs (36+240) within Net::DNS::Domain::BEGIN@49 which was called:
# once (36µs+240µs) by Net::DNS::RR::BEGIN@42 at line 51 | ||
50 | 1 | 18µs | 2 | 48µs | Encode::encode_utf8( chr(182) ) eq pack( 'H*', 'C2B6' ); # spent 32µs making 1 call to Encode::encode_utf8
# spent 15µs making 1 call to main::CORE:pack |
51 | 1 | 77µs | 2 | 483µs | }; # spent 276µs making 1 call to Net::DNS::Domain::BEGIN@49
# spent 208µs making 1 call to constant::import |
52 | |||||
53 | 2 | 158µs | 2 | 3.70ms | # spent 3.50ms (1.49+2.00) within Net::DNS::Domain::BEGIN@53 which was called:
# once (1.49ms+2.00ms) by Net::DNS::RR::BEGIN@42 at line 53 # spent 3.50ms making 1 call to Net::DNS::Domain::BEGIN@53
# spent 200µs making 1 call to constant::import # spent 247µs executing statements in string eval |
54 | 2 | 174µs | 2 | 2.74ms | # spent 2.54ms (872µs+1.66) within Net::DNS::Domain::BEGIN@54 which was called:
# once (872µs+1.66ms) by Net::DNS::RR::BEGIN@42 at line 54 # spent 2.54ms making 1 call to Net::DNS::Domain::BEGIN@54
# spent 202µs making 1 call to constant::import # spent 272µs executing statements in string eval |
55 | |||||
56 | 2 | 2.97ms | 2 | 428µs | # spent 249µs (69+180) within Net::DNS::Domain::BEGIN@56 which was called:
# once (69µs+180µs) by Net::DNS::RR::BEGIN@42 at line 56 # spent 249µs making 1 call to Net::DNS::Domain::BEGIN@56
# spent 180µs making 1 call to constant::import # spent 5µs executing statements in string eval |
57 | |||||
58 | # perlcc: address of encoding objects must be determined at runtime | ||||
59 | 1 | 10µs | 1 | 46µs | my $ascii = ASCII ? Encode::find_encoding('ascii') : undef; # Osborn's Law: # spent 46µs making 1 call to Encode::find_encoding |
60 | 1 | 6µs | 1 | 30µs | my $utf8 = UTF8 ? Encode::find_encoding('utf8') : undef; # Variables won't; constants aren't. # spent 30µs making 1 call to Encode::find_encoding |
61 | |||||
62 | |||||
63 | =head1 METHODS | ||||
64 | |||||
65 | =head2 new | ||||
66 | |||||
67 | $object = new Net::DNS::Domain('example.com'); | ||||
68 | |||||
69 | Creates a domain object which represents the DNS domain specified | ||||
70 | by the character string argument. The argument consists of a | ||||
71 | sequence of labels delimited by dots. | ||||
72 | |||||
73 | A character preceded by \ represents itself, without any special | ||||
74 | interpretation. | ||||
75 | |||||
76 | Arbitrary 8-bit codes can be represented by \ followed by exactly | ||||
77 | three decimal digits. | ||||
78 | Character code points are ASCII, irrespective of the character | ||||
79 | coding scheme employed by the underlying platform. | ||||
80 | |||||
81 | Argument string literals should be delimited by single quotes to | ||||
82 | avoid escape sequences being interpreted as octal character codes | ||||
83 | by the Perl compiler. | ||||
84 | |||||
85 | The character string presentation format follows the conventions | ||||
86 | for zone files described in RFC1035. | ||||
87 | |||||
88 | Users should be aware that non-ASCII domain names will be transcoded | ||||
89 | to NFC before encoding, which is an irreversible process. | ||||
90 | |||||
91 | =cut | ||||
92 | |||||
93 | 1 | 2µs | my ( %escape, %unescape ); ## precalculated ASCII escape tables | ||
94 | |||||
95 | our $ORIGIN; | ||||
96 | 1 | 10µs | my ( $cache1, $cache2, $limit ) = ( {}, {}, 100 ); | ||
97 | |||||
98 | # spent 500ms (413+87.3) within Net::DNS::Domain::new which was called 3936 times, avg 127µs/call:
# 1968 times (375ms+87.3ms) by Net::DNS::Question::new at line 80 of Net/DNS/Question.pm, avg 235µs/call
# 1968 times (38.2ms+43µs) by Net::DNS::RR::owner at line 424 of Net/DNS/RR.pm, avg 19µs/call | ||||
99 | 3936 | 18.0ms | my ( $class, $s ) = @_; | ||
100 | 3936 | 6.88ms | croak 'domain identifier undefined' unless defined $s; | ||
101 | |||||
102 | 3936 | 16.1ms | my $k = join '', $s, $class, $ORIGIN || ''; # cache key | ||
103 | 3936 | 27.2ms | my $cache = $$cache1{$k} ||= $$cache2{$k}; # two layer cache | ||
104 | 3936 | 43.5ms | return $cache if defined $cache; | ||
105 | |||||
106 | 1039 | 2.61ms | ( $cache1, $cache2, $limit ) = ( {}, $cache1, 500 ) unless $limit--; # recycle cache | ||
107 | |||||
108 | 1039 | 4.99ms | my $self = bless {}, $class; | ||
109 | |||||
110 | 1039 | 10.8ms | 1039 | 3.08ms | $s =~ s/\\\\/\\092/g; # disguise escaped escape # spent 3.08ms making 1039 calls to Net::DNS::Domain::CORE:subst, avg 3µs/call |
111 | 1039 | 9.69ms | 1039 | 2.94ms | $s =~ s/\\\./\\046/g; # disguise escaped dot # spent 2.94ms making 1039 calls to Net::DNS::Domain::CORE:subst, avg 3µs/call |
112 | |||||
113 | 1039 | 28.2ms | 1039 | 41.9ms | my $label = $self->{label} = ( $s eq '@' ) ? [] : [split /\056/, _encode_utf8($s)]; # spent 41.9ms making 1039 calls to Net::DNS::Domain::_encode_utf8, avg 40µs/call |
114 | |||||
115 | 1039 | 21.6ms | foreach (@$label) { | ||
116 | |||||
117 | 4588 | 79.4ms | 4588 | 14.0ms | if ( LIBIDN2 && UTF8 && /[^\000-\177]/ ) { # spent 14.0ms making 4588 calls to Net::DNS::Domain::CORE:match, avg 3µs/call |
118 | my $rc = 0; | ||||
119 | s/\134/\357\277\275/; # disallow escapes | ||||
120 | $_ = Net::LibIDN2::idn2_to_ascii_8( $_, IDN2FLAG, $rc ); | ||||
121 | croak Net::LibIDN2::idn2_strerror($rc) unless $_; | ||||
122 | } | ||||
123 | |||||
124 | if ( !LIBIDN2 && LIBIDN && UTF8 && /[^\000-\177]/ ) { | ||||
125 | s/\134/\357\277\275/; # disallow escapes | ||||
126 | $_ = Net::LibIDN::idn_to_ascii( $_, 'utf-8' ); | ||||
127 | croak 'name contains disallowed character' unless $_; | ||||
128 | } | ||||
129 | |||||
130 | 4588 | 70.9ms | 4588 | 9.40ms | s/\134([\060-\071]{3})/$unescape{$1}/eg; # numeric escape # spent 9.40ms making 4588 calls to Net::DNS::Domain::CORE:subst, avg 2µs/call |
131 | 4588 | 57.9ms | 4588 | 9.96ms | s/\134(.)/$1/g; # character escape # spent 9.96ms making 4588 calls to Net::DNS::Domain::CORE:subst, avg 2µs/call |
132 | 4588 | 10.2ms | croak 'empty domain label' unless length; | ||
133 | 4588 | 11.0ms | next unless length > 63; | ||
134 | substr( $_, 63 ) = ''; | ||||
135 | carp 'domain label truncated'; | ||||
136 | } | ||||
137 | |||||
138 | 1039 | 3.43ms | $$cache1{$k} = $self; # cache object reference | ||
139 | |||||
140 | 1039 | 44.2ms | 1039 | 6.07ms | return $self if $s =~ /\.$/; # fully qualified name # spent 6.07ms making 1039 calls to Net::DNS::Domain::CORE:match, avg 6µs/call |
141 | $self->{origin} = $ORIGIN || return $self; # dynamically scoped $ORIGIN | ||||
142 | return $self; | ||||
143 | } | ||||
144 | |||||
145 | |||||
146 | =head2 name | ||||
147 | |||||
148 | $name = $domain->name; | ||||
149 | |||||
150 | Returns the domain name as a character string corresponding to the | ||||
151 | "common interpretation" to which RFC1034, 3.1, paragraph 9 alludes. | ||||
152 | |||||
153 | Character escape sequences are used to represent a dot inside a | ||||
154 | domain name label and the escape character itself. | ||||
155 | |||||
156 | Any non-printable code point is represented using the appropriate | ||||
157 | numerical escape sequence. | ||||
158 | |||||
159 | =cut | ||||
160 | |||||
161 | # spent 194ms (123+70.7) within Net::DNS::Domain::name which was called 1968 times, avg 98µs/call:
# 1968 times (123ms+70.7ms) by Net::DNS::Question::qname at line 215 of Net/DNS/Question.pm, avg 98µs/call | ||||
162 | 1968 | 4.06ms | my ($self) = @_; | ||
163 | |||||
164 | 1968 | 16.0ms | return $self->{name} if defined $self->{name}; | ||
165 | 1038 | 2.06ms | return unless defined wantarray; | ||
166 | |||||
167 | 10214 | 89.5ms | 5626 | 32.7ms | my @label = map { s/([^\055\101-\132\141-\172\060-\071])/$escape{$1}/eg; $_ } $self->_wire; # spent 17.8ms making 4588 calls to Net::DNS::Domain::CORE:subst, avg 4µs/call
# spent 14.9ms making 1038 calls to Net::DNS::DomainName::_wire, avg 14µs/call |
168 | |||||
169 | 1038 | 2.05ms | return $self->{name} = '.' unless scalar @label; | ||
170 | 1038 | 23.7ms | 1038 | 38.0ms | $self->{name} = _decode_ascii( join chr(46), @label ); # spent 38.0ms making 1038 calls to Net::DNS::Domain::_decode_ascii, avg 37µs/call |
171 | } | ||||
172 | |||||
173 | |||||
174 | =head2 fqdn | ||||
175 | |||||
176 | @fqdn = $domain->fqdn; | ||||
177 | |||||
178 | Returns a character string containing the fully qualified domain | ||||
179 | name, including the trailing dot. | ||||
180 | |||||
181 | =cut | ||||
182 | |||||
183 | sub fqdn { | ||||
184 | my $name = &name; | ||||
185 | return $name =~ /[.]$/ ? $name : $name . '.'; # append trailing dot | ||||
186 | } | ||||
187 | |||||
188 | |||||
189 | =head2 xname | ||||
190 | |||||
191 | $xname = $domain->xname; | ||||
192 | |||||
193 | Interprets an extended name containing Unicode domain name labels | ||||
194 | encoded as Punycode A-labels. | ||||
195 | |||||
196 | If decoding is not possible, the ACE encoded name is returned. | ||||
197 | |||||
198 | =cut | ||||
199 | |||||
200 | sub xname { | ||||
201 | my $name = &name; | ||||
202 | |||||
203 | if ( LIBIDN2 && UTF8 && $name =~ /xn--/i ) { | ||||
204 | my $self = shift; | ||||
205 | return $self->{xname} if defined $self->{xname}; | ||||
206 | my $u8 = Net::LibIDN2::idn2_to_unicode_88($name); | ||||
207 | return $self->{xname} = $u8 ? $utf8->decode($u8) : $name; | ||||
208 | } | ||||
209 | |||||
210 | if ( !LIBIDN2 && LIBIDN && UTF8 && $name =~ /xn--/i ) { | ||||
211 | my $self = shift; | ||||
212 | return $self->{xname} if defined $self->{xname}; | ||||
213 | return $self->{xname} = $utf8->decode( Net::LibIDN::idn_to_unicode $name, 'utf-8' ); | ||||
214 | } | ||||
215 | return $name; | ||||
216 | } | ||||
217 | |||||
218 | |||||
219 | =head2 label | ||||
220 | |||||
221 | @label = $domain->label; | ||||
222 | |||||
223 | Identifies the domain by means of a list of domain labels. | ||||
224 | |||||
225 | =cut | ||||
226 | |||||
227 | sub label { | ||||
228 | map { | ||||
229 | s/([^\055\101-\132\141-\172\060-\071])/$escape{$1}/eg; | ||||
230 | _decode_ascii($_) | ||||
231 | } shift->_wire; | ||||
232 | } | ||||
233 | |||||
234 | |||||
235 | sub _wire { | ||||
236 | my $self = shift; | ||||
237 | |||||
238 | my $label = $self->{label}; | ||||
239 | my $origin = $self->{origin} || return (@$label); | ||||
240 | return ( @$label, $origin->_wire ); | ||||
241 | } | ||||
242 | |||||
243 | |||||
244 | =head2 string | ||||
245 | |||||
246 | $string = $object->string; | ||||
247 | |||||
248 | Returns a character string containing the fully qualified domain | ||||
249 | name as it appears in a zone file. | ||||
250 | |||||
251 | Characters which are recognised by RFC1035 zone file syntax are | ||||
252 | represented by the appropriate escape sequence. | ||||
253 | |||||
254 | =cut | ||||
255 | |||||
256 | sub string { | ||||
257 | ( my $name = &name ) =~ s/(["'\$();@])/\\$1/; # escape special char | ||||
258 | return $name =~ /[.]$/ ? $name : $name . '.'; # append trailing dot | ||||
259 | } | ||||
260 | |||||
261 | |||||
262 | =head2 origin | ||||
263 | |||||
264 | $create = origin Net::DNS::Domain( $ORIGIN ); | ||||
265 | $result = &$create( sub{ new Net::DNS::RR( 'mx MX 10 a' ); } ); | ||||
266 | $expect = new Net::DNS::RR( "mx.$ORIGIN. MX 10 a.$ORIGIN." ); | ||||
267 | |||||
268 | Class method which returns a reference to a subroutine wrapper | ||||
269 | which executes a given constructor in a dynamically scoped context | ||||
270 | where relative names become descendents of the specified $ORIGIN. | ||||
271 | |||||
272 | =cut | ||||
273 | |||||
274 | 1 | 7µs | my $placebo = sub { my $constructor = shift; &$constructor; }; | ||
275 | |||||
276 | sub origin { | ||||
277 | my ( $class, $name ) = @_; | ||||
278 | my $domain = defined $name ? new Net::DNS::Domain($name) : return $placebo; | ||||
279 | |||||
280 | return sub { # closure w.r.t. $domain | ||||
281 | my $constructor = shift; | ||||
282 | local $ORIGIN = $domain; # dynamically scoped $ORIGIN | ||||
283 | &$constructor; | ||||
284 | } | ||||
285 | } | ||||
286 | |||||
287 | |||||
288 | ######################################## | ||||
289 | |||||
290 | # spent 38.0ms (28.9+9.15) within Net::DNS::Domain::_decode_ascii which was called 1038 times, avg 37µs/call:
# 1038 times (28.9ms+9.15ms) by Net::DNS::Domain::name at line 170, avg 37µs/call | ||||
291 | 1038 | 3.92ms | local $_ = shift; | ||
292 | |||||
293 | # partial transliteration for non-ASCII character encodings | ||||
294 | tr | ||||
295 | [\040-\176\000-\377] | ||||
296 | [ !"#$%&'()*+,\-./0-9:;<=>?@A-Z\[\\\]^_`a-z{|}~?] unless ASCII; | ||||
297 | |||||
298 | 1038 | 4.21ms | my $z = length($_) - length($_); # pre-5.18 taint workaround | ||
299 | 1038 | 31.1ms | 1038 | 9.15ms | ASCII ? substr( $ascii->decode($_), $z ) : $_; # spent 9.15ms making 1038 calls to Encode::XS::decode, avg 9µs/call |
300 | } | ||||
301 | |||||
302 | |||||
303 | # spent 41.9ms (31.9+9.94) within Net::DNS::Domain::_encode_utf8 which was called 1039 times, avg 40µs/call:
# 1039 times (31.9ms+9.94ms) by Net::DNS::Domain::new at line 113, avg 40µs/call | ||||
304 | 1039 | 5.76ms | local $_ = shift; | ||
305 | |||||
306 | # partial transliteration for non-ASCII character encodings | ||||
307 | tr | ||||
308 | [ !"#$%&'()*+,\-./0-9:;<=>?@A-Z\[\\\]^_`a-z{|}~\000-\377] | ||||
309 | [\040-\176\077] unless ASCII; | ||||
310 | |||||
311 | 1039 | 5.54ms | my $z = length($_) - length($_); # pre-5.18 taint workaround | ||
312 | 1039 | 41.1ms | 1039 | 9.94ms | ASCII ? substr( ( UTF8 ? $utf8 : $ascii )->encode($_), $z ) : $_; # spent 9.94ms making 1039 calls to Encode::utf8::encode_xs, avg 10µs/call |
313 | } | ||||
314 | |||||
315 | |||||
316 | 1 | 129µs | %escape = eval { ## precalculated ASCII escape table | ||
317 | 1 | 9µs | my %table; | ||
318 | |||||
319 | 1 | 6µs | foreach ( 33 .. 126 ) { # ASCII printable | ||
320 | 94 | 2.52ms | 188 | 346µs | $table{pack( 'C', $_ )} = pack 'C', $_; # spent 346µs making 188 calls to Net::DNS::Domain::CORE:pack, avg 2µs/call |
321 | } | ||||
322 | |||||
323 | # minimal character escapes | ||||
324 | 1 | 3µs | foreach ( 46, 92 ) { # \. \\ | ||
325 | 2 | 67µs | 4 | 18µs | $table{pack( 'C', $_ )} = pack 'C*', 92, $_; # spent 18µs making 4 calls to Net::DNS::Domain::CORE:pack, avg 5µs/call |
326 | } | ||||
327 | |||||
328 | 1 | 4µs | foreach my $n ( 0 .. 32, 127 .. 255 ) { # \ddd | ||
329 | 162 | 391µs | my $codepoint = sprintf( '%03u', $n ); | ||
330 | |||||
331 | # partial transliteration for non-ASCII character encodings | ||||
332 | 162 | 286µs | $codepoint =~ tr [0-9] [\060-\071]; | ||
333 | |||||
334 | 162 | 4.56ms | 324 | 621µs | $table{pack( 'C', $n )} = pack 'C a3', 92, $codepoint; # spent 621µs making 324 calls to Net::DNS::Domain::CORE:pack, avg 2µs/call |
335 | } | ||||
336 | |||||
337 | 1 | 198µs | return %table; | ||
338 | }; | ||||
339 | |||||
340 | |||||
341 | 1 | 127µs | %unescape = eval { ## precalculated numeric escape table | ||
342 | 1 | 2µs | my %table; | ||
343 | |||||
344 | 1 | 14µs | foreach my $n ( 0 .. 255 ) { | ||
345 | 256 | 599µs | my $key = sprintf( '%03u', $n ); | ||
346 | |||||
347 | # partial transliteration for non-ASCII character encodings | ||||
348 | 256 | 429µs | $key =~ tr [0-9] [\060-\071]; | ||
349 | |||||
350 | 256 | 4.18ms | 256 | 482µs | $table{$key} = pack 'C', $n; # spent 482µs making 256 calls to Net::DNS::Domain::CORE:pack, avg 2µs/call |
351 | 256 | 867µs | 1 | 2µs | $table{$key} = pack 'C2', 92, $n if $n == 92; # escaped escape # spent 2µs making 1 call to Net::DNS::Domain::CORE:pack |
352 | } | ||||
353 | |||||
354 | 1 | 176µs | return %table; | ||
355 | }; | ||||
356 | |||||
357 | |||||
358 | 1 | 72µs | 1; | ||
359 | __END__ | ||||
sub Net::DNS::Domain::CORE:match; # opcode | |||||
# spent 1.47ms within Net::DNS::Domain::CORE:pack which was called 773 times, avg 2µs/call:
# 324 times (621µs+0s) by Net::DNS::RR::BEGIN@42 at line 334, avg 2µs/call
# 256 times (482µs+0s) by Net::DNS::RR::BEGIN@42 at line 350, avg 2µs/call
# 188 times (346µs+0s) by Net::DNS::RR::BEGIN@42 at line 320, avg 2µs/call
# 4 times (18µs+0s) by Net::DNS::RR::BEGIN@42 at line 325, avg 5µs/call
# once (2µs+0s) by Net::DNS::RR::BEGIN@42 at line 351 | |||||
# spent 43.1ms within Net::DNS::Domain::CORE:subst which was called 15842 times, avg 3µs/call:
# 4588 times (17.8ms+0s) by Net::DNS::Domain::name at line 167, avg 4µs/call
# 4588 times (9.96ms+0s) by Net::DNS::Domain::new at line 131, avg 2µs/call
# 4588 times (9.40ms+0s) by Net::DNS::Domain::new at line 130, avg 2µs/call
# 1039 times (3.08ms+0s) by Net::DNS::Domain::new at line 110, avg 3µs/call
# 1039 times (2.94ms+0s) by Net::DNS::Domain::new at line 111, avg 3µs/call |