← 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:19 2017

Filename/usr/local/lib/perl5/site_perl/Net/DNS/Parameters.pm
StatementsExecuted 15792 statements in 126ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
19703324.2ms24.2msNet::DNS::Parameters::::typebynameNet::DNS::Parameters::typebyname
19692220.4ms20.4msNet::DNS::Parameters::::typebyvalNet::DNS::Parameters::typebyval
19681120.3ms20.3msNet::DNS::Parameters::::classbynameNet::DNS::Parameters::classbyname
19681116.6ms16.6msNet::DNS::Parameters::::classbyvalNet::DNS::Parameters::classbyval
27471672µs672µsNet::DNS::Parameters::::CORE:matchNet::DNS::Parameters::CORE:match (opcode)
111226µs431µsNet::DNS::Parameters::::BEGIN@330Net::DNS::Parameters::BEGIN@330
11147µs61µsNet::DNS::Parameters::::BEGIN@17Net::DNS::Parameters::BEGIN@17
11132µs243µsNet::DNS::Parameters::::BEGIN@20Net::DNS::Parameters::BEGIN@20
11124µs38µsNet::DNS::Parameters::::BEGIN@19Net::DNS::Parameters::BEGIN@19
11123µs249µsNet::DNS::Parameters::::BEGIN@22Net::DNS::Parameters::BEGIN@22
11123µs57µsNet::DNS::Parameters::::BEGIN@18Net::DNS::Parameters::BEGIN@18
0000s0sNet::DNS::Parameters::::_typespecNet::DNS::Parameters::_typespec
0000s0sNet::DNS::Parameters::::ednsoptionbynameNet::DNS::Parameters::ednsoptionbyname
0000s0sNet::DNS::Parameters::::ednsoptionbyvalNet::DNS::Parameters::ednsoptionbyval
0000s0sNet::DNS::Parameters::::opcodebynameNet::DNS::Parameters::opcodebyname
0000s0sNet::DNS::Parameters::::opcodebyvalNet::DNS::Parameters::opcodebyval
0000s0sNet::DNS::Parameters::::rcodebynameNet::DNS::Parameters::rcodebyname
0000s0sNet::DNS::Parameters::::rcodebyvalNet::DNS::Parameters::rcodebyval
0000s0sNet::DNS::Parameters::::registerNet::DNS::Parameters::register
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Net::DNS::Parameters;
2
3#
4# $Id: Parameters.pm 1598 2017-10-03 09:48:30Z willem $
5#
613µsour $VERSION = (qw$LastChangedRevision: 1598 $)[1];
7
8
9################################################
10##
11## Domain Name System (DNS) Parameters
12## (last updated 2017-08-30)
13##
14################################################
15
16
17282µs276µs
# spent 61µs (47+15) within Net::DNS::Parameters::BEGIN@17 which was called: # once (47µs+15µs) by Net::DNS::RR::BEGIN@41 at line 17
use strict;
# spent 61µs making 1 call to Net::DNS::Parameters::BEGIN@17 # spent 15µs making 1 call to strict::import
18276µs291µs
# spent 57µs (23+34) within Net::DNS::Parameters::BEGIN@18 which was called: # once (23µs+34µs) by Net::DNS::RR::BEGIN@41 at line 18
use warnings;
# spent 57µs making 1 call to Net::DNS::Parameters::BEGIN@18 # spent 34µs making 1 call to warnings::import
19260µs252µs
# spent 38µs (24+14) within Net::DNS::Parameters::BEGIN@19 which was called: # once (24µs+14µs) by Net::DNS::RR::BEGIN@41 at line 19
use integer;
# spent 38µs making 1 call to Net::DNS::Parameters::BEGIN@19 # spent 14µs making 1 call to integer::import
20282µs2454µs
# spent 243µs (32+211) within Net::DNS::Parameters::BEGIN@20 which was called: # once (32µs+211µs) by Net::DNS::RR::BEGIN@41 at line 20
use Carp;
# spent 243µs making 1 call to Net::DNS::Parameters::BEGIN@20 # spent 211µs making 1 call to Exporter::import
21
2222.74ms2249µs
# spent 249µs (23+226) within Net::DNS::Parameters::BEGIN@22 which was called: # once (23µs+226µs) by Net::DNS::RR::BEGIN@41 at line 22
use base qw(Exporter);
# spent 249µs making 1 call to Net::DNS::Parameters::BEGIN@22 # spent 226µs making 1 call to base::import, recursion: max depth 2, sum of overlapping time 226µs
2315µsour @EXPORT = qw(
24 classbyname classbyval %classbyname
25 typebyname typebyval %typebyname
26 opcodebyname opcodebyval
27 rcodebyname rcodebyval
28 ednsoptionbyname ednsoptionbyval
29 );
30
31
32# Registry: DNS CLASSes
3313µsmy @classbyname = (
34 IN => 1, # RFC1035
35 CH => 3, # Chaosnet
36 HS => 4, # Hesiod
37 NONE => 254, # RFC2136
38 ANY => 255, # RFC1035
39 );
40121µsour %classbyval = reverse @classbyname, ( CLASS0 => 0 );
411111µs1032µspush @classbyname, map /^\d/ ? $_ : lc($_), @classbyname;
# spent 32µs making 10 calls to Net::DNS::Parameters::CORE:match, avg 3µs/call
42112µsour %classbyname = ( '*' => 255, @classbyname );
43
44
45# Registry: Resource Record (RR) TYPEs
46129µsmy @typebyname = (
47 A => 1, # RFC1035
48 NS => 2, # RFC1035
49 MD => 3, # RFC1035
50 MF => 4, # RFC1035
51 CNAME => 5, # RFC1035
52 SOA => 6, # RFC1035
53 MB => 7, # RFC1035
54 MG => 8, # RFC1035
55 MR => 9, # RFC1035
56 NULL => 10, # RFC1035
57 WKS => 11, # RFC1035
58 PTR => 12, # RFC1035
59 HINFO => 13, # RFC1035
60 MINFO => 14, # RFC1035
61 MX => 15, # RFC1035
62 TXT => 16, # RFC1035
63 RP => 17, # RFC1183
64 AFSDB => 18, # RFC1183 RFC5864
65 X25 => 19, # RFC1183
66 ISDN => 20, # RFC1183
67 RT => 21, # RFC1183
68 NSAP => 22, # RFC1706
69 'NSAP-PTR' => 23, # RFC1348 RFC1637 RFC1706
70 SIG => 24, # RFC4034 RFC3755 RFC2535 RFC2536 RFC2537 RFC2931 RFC3110 RFC3008
71 KEY => 25, # RFC4034 RFC3755 RFC2535 RFC2536 RFC2537 RFC2539 RFC3008 RFC3110
72 PX => 26, # RFC2163
73 GPOS => 27, # RFC1712
74 AAAA => 28, # RFC3596
75 LOC => 29, # RFC1876
76 NXT => 30, # RFC3755 RFC2535
77 EID => 31, # http://ana-3.lcs.mit.edu/~jnc/nimrod/dns.txt
78 NIMLOC => 32, # http://ana-3.lcs.mit.edu/~jnc/nimrod/dns.txt
79 SRV => 33, # RFC2782
80 ATMA => 34, # http://www.broadband-forum.org/ftp/pub/approved-specs/af-dans-0152.000.pdf
81 NAPTR => 35, # RFC2915 RFC2168 RFC3403
82 KX => 36, # RFC2230
83 CERT => 37, # RFC4398
84 A6 => 38, # RFC3226 RFC2874 RFC6563
85 DNAME => 39, # RFC6672
86 SINK => 40, # http://tools.ietf.org/html/draft-eastlake-kitchen-sink
87 OPT => 41, # RFC6891 RFC3225
88 APL => 42, # RFC3123
89 DS => 43, # RFC4034 RFC3658
90 SSHFP => 44, # RFC4255
91 IPSECKEY => 45, # RFC4025
92 RRSIG => 46, # RFC4034 RFC3755
93 NSEC => 47, # RFC4034 RFC3755
94 DNSKEY => 48, # RFC4034 RFC3755
95 DHCID => 49, # RFC4701
96 NSEC3 => 50, # RFC5155
97 NSEC3PARAM => 51, # RFC5155
98 TLSA => 52, # RFC6698
99 SMIMEA => 53, # RFC8162
100 HIP => 55, # RFC8005
101 NINFO => 56, #
102 RKEY => 57, #
103 TALINK => 58, #
104 CDS => 59, # RFC7344
105 CDNSKEY => 60, # RFC7344
106 OPENPGPKEY => 61, # RFC7929
107 CSYNC => 62, # RFC7477
108 SPF => 99, # RFC7208
109 UINFO => 100, # IANA-Reserved
110 UID => 101, # IANA-Reserved
111 GID => 102, # IANA-Reserved
112 UNSPEC => 103, # IANA-Reserved
113 NID => 104, # RFC6742
114 L32 => 105, # RFC6742
115 L64 => 106, # RFC6742
116 LP => 107, # RFC6742
117 EUI48 => 108, # RFC7043
118 EUI64 => 109, # RFC7043
119 TKEY => 249, # RFC2930
120 TSIG => 250, # RFC2845
121 IXFR => 251, # RFC1995
122 AXFR => 252, # RFC1035 RFC5936
123 MAILB => 253, # RFC1035
124 MAILA => 254, # RFC1035
125 ANY => 255, # RFC1035 RFC6895
126 URI => 256, # RFC7553
127 CAA => 257, # RFC6844
128 AVC => 258, #
129 DOA => 259, # draft-durand-doa-over-dns
130 TA => 32768, # http://cameo.library.cmu.edu/ http://www.watson.org/~weiler/INI1999-19.pdf
131 DLV => 32769, # RFC4431
132 );
1331102µsour %typebyval = reverse @typebyname, ( TYPE0 => 0 );
13411.39ms170388µspush @typebyname, map /^\d/ ? $_ : lc($_), @typebyname;
# spent 388µs making 170 calls to Net::DNS::Parameters::CORE:match, avg 2µs/call
1351157µsour %typebyname = ( '*' => 255, @typebyname );
136
137
138# Registry: DNS OpCodes
13914µsmy @opcodebyname = (
140 QUERY => 0, # RFC1035
141 IQUERY => 1, # RFC3425
142 STATUS => 2, # RFC1035
143 NOTIFY => 4, # RFC1996
144 UPDATE => 5, # RFC2136
145 );
14615µsour %opcodebyval = reverse @opcodebyname;
1471104µs1022µspush @opcodebyname, map /^\d/ ? $_ : lc($_), @opcodebyname;
# spent 22µs making 10 calls to Net::DNS::Parameters::CORE:match, avg 2µs/call
148112µsour %opcodebyname = ( NS_NOTIFY_OP => 4, @opcodebyname );
149
150
151# Registry: DNS RCODEs
15217µsmy @rcodebyname = (
153 NOERROR => 0, # RFC1035
154 FORMERR => 1, # RFC1035
155 SERVFAIL => 2, # RFC1035
156 NXDOMAIN => 3, # RFC1035
157 NOTIMP => 4, # RFC1035
158 REFUSED => 5, # RFC1035
159 YXDOMAIN => 6, # RFC2136 RFC6672
160 YXRRSET => 7, # RFC2136
161 NXRRSET => 8, # RFC2136
162 NOTAUTH => 9, # RFC2136
163 NOTAUTH => 9, # RFC2845
164 NOTZONE => 10, # RFC2136
165 BADVERS => 16, # RFC6891
166 BADSIG => 16, # RFC2845
167 BADKEY => 17, # RFC2845
168 BADTIME => 18, # RFC2845
169 BADMODE => 19, # RFC2930
170 BADNAME => 20, # RFC2930
171 BADALG => 21, # RFC2930
172 BADTRUNC => 22, # RFC4635
173 BADCOOKIE => 23, # RFC7873
174 );
175125µsour %rcodebyval = reverse( BADSIG => 16, @rcodebyname );
1761368µs42124µspush @rcodebyname, map /^\d/ ? $_ : lc($_), @rcodebyname;
# spent 124µs making 42 calls to Net::DNS::Parameters::CORE:match, avg 3µs/call
177145µsour %rcodebyname = @rcodebyname;
178
179
180# Registry: DNS EDNS0 Option Codes (OPT)
18116µsmy @ednsoptionbyname = (
182 LLQ => 1, # http://files.dns-sd.org/draft-sekar-dns-llq.txt
183 UL => 2, # http://files.dns-sd.org/draft-sekar-dns-ul.txt
184 NSID => 3, # RFC5001
185 DAU => 5, # RFC6975
186 DHU => 6, # RFC6975
187 N3U => 7, # RFC6975
188 'CLIENT-SUBNET' => 8, # RFC7871
189 EXPIRE => 9, # RFC7314
190 COOKIE => 10, # RFC7873
191 'TCP-KEEPALIVE' => 11, # RFC7828
192 PADDING => 12, # RFC7830
193 CHAIN => 13, # RFC7901
194 'KEY-TAG' => 14, # RFC8145
195 DEVICEID => 26946, # https://docs.umbrella.com/developer/networkdevices-api/identifying-dns-traffic2
196 );
197122µsour %ednsoptionbyval = reverse @ednsoptionbyname;
1981273µs2868µspush @ednsoptionbyname, map /^\d/ ? $_ : lc($_), @ednsoptionbyname;
# spent 68µs making 28 calls to Net::DNS::Parameters::CORE:match, avg 2µs/call
199130µsour %ednsoptionbyname = @ednsoptionbyname;
200
201
202# Registry: DNS Header Flags
203113µsmy @dnsflagbyname = (
204 AA => 0x0400, # RFC1035
205 TC => 0x0200, # RFC1035
206 RD => 0x0100, # RFC1035
207 RA => 0x0080, # RFC1035
208 AD => 0x0020, # RFC4035 RFC6840
209 CD => 0x0010, # RFC4035 RFC6840
210 );
211199µs1233µspush @dnsflagbyname, map /^\d/ ? $_ : lc($_), @dnsflagbyname;
# spent 33µs making 12 calls to Net::DNS::Parameters::CORE:match, avg 3µs/call
212115µsour %dnsflagbyname = @dnsflagbyname;
213
214
215# Registry: EDNS Header Flags (16 bits)
21612µsmy @ednsflagbyname = (
217 DO => 0x8000, # RFC4035 RFC3225 RFC6840
218 );
219133µs25µspush @ednsflagbyname, map /^\d/ ? $_ : lc($_), @ednsflagbyname;
# spent 5µs making 2 calls to Net::DNS::Parameters::CORE:match, avg 2µs/call
22014µsour %ednsflagbyname = @ednsflagbyname;
221
222
223########
224
225# The following functions are wrappers around similarly named hashes.
226
227
# spent 20.3ms within Net::DNS::Parameters::classbyname which was called 1968 times, avg 10µs/call: # 1968 times (20.3ms+0s) by Net::DNS::Question::new at line 82 of Net/DNS/Question.pm, avg 10µs/call
sub classbyname {
22819684.29ms my $name = shift;
229
230196820.6ms $classbyname{$name} || $classbyname{uc $name} || do {
231 croak "unknown class $name" unless $name =~ m/^(CLASS)?(\d+)/i;
232 my $val = 0 + $2;
233 croak "classbyname( $name ) out of range" if $val > 0xffff;
234 return $val;
235 }
236}
237
238
# spent 16.6ms within Net::DNS::Parameters::classbyval which was called 1968 times, avg 8µs/call: # 1968 times (16.6ms+0s) by Net::DNS::Question::class at line 258 of Net/DNS/Question.pm, avg 8µs/call
sub classbyval {
23919684.14ms my $val = shift;
240
241196827.6ms $classbyval{$val} || do {
242 $val += 0;
243 croak "classbyval( $val ) out of range" if $val > 0xffff;
244 return "CLASS$val";
245 }
246}
247
248
249
# spent 24.2ms within Net::DNS::Parameters::typebyname which was called 1970 times, avg 12µs/call: # 1968 times (24.2ms+0s) by Net::DNS::Question::new at line 81 of Net/DNS/Question.pm, avg 12µs/call # once (11µs+0s) by Net::DNS::RR::_subclass at line 675 of Net/DNS/RR.pm # once (8µs+0s) by Net::DNS::RR::OPT::BEGIN@27 at line 27 of Net/DNS/RR/OPT.pm
sub typebyname {
25019705.21ms my $name = shift;
251
252197020.9ms $typebyname{$name} || do {
253 if ( $name =~ m/^(TYPE)?(\d+)/i ) {
254 my $val = 0 + $2;
255 croak "typebyname( $name ) out of range" if $val > 0xffff;
256 return $val;
257 }
258 _typespec("$name.RRNAME") unless $typebyname{uc $name};
259 return $typebyname{uc $name} || croak "unknown type $name";
260 }
261}
262
263
# spent 20.4ms within Net::DNS::Parameters::typebyval which was called 1969 times, avg 10µs/call: # 1968 times (20.4ms+0s) by Net::DNS::Question::type at line 236 of Net/DNS/Question.pm, avg 10µs/call # once (11µs+0s) by Net::DNS::RR::_subclass at line 680 of Net/DNS/RR.pm
sub typebyval {
26419693.96ms my $val = shift;
265
266196932.5ms $typebyval{$val} || do {
267 $val += 0;
268 croak "typebyval( $val ) out of range" if $val > 0xffff;
269 $typebyval{$val} = "TYPE$val";
270 _typespec("$val.RRTYPE");
271 return $typebyval{$val};
272 }
273}
274
275
276sub opcodebyname {
277 my $arg = shift;
278 return $opcodebyname{$arg} if defined $opcodebyname{$arg};
279 return 0 + $arg if $arg =~ /^\d/;
280 croak "unknown opcode $arg";
281}
282
283sub opcodebyval {
284 my $val = shift;
285 $opcodebyval{$val} || return $val;
286}
287
288
289sub rcodebyname {
290 my $arg = shift;
291 return $rcodebyname{$arg} if defined $rcodebyname{$arg};
292 return 0 + $arg if $arg =~ /^\d/;
293 croak "unknown rcode $arg";
294}
295
296sub rcodebyval {
297 my $val = shift;
298 $rcodebyval{$val} || return $val;
299}
300
301
302sub ednsoptionbyname {
303 my $arg = shift;
304 return $ednsoptionbyname{$arg} if defined $ednsoptionbyname{$arg};
305 return 0 + $arg if $arg =~ /^\d/;
306 croak "unknown option $arg";
307}
308
309sub ednsoptionbyval {
310 my $val = shift;
311 $ednsoptionbyval{$val} || return $val;
312}
313
314
315sub register { ## register( 'TOY', 1234 ) (NOT part of published API)
316 my ( $mnemonic, $rrtype ) = map uc($_), @_; # uncoverable pod
317 $rrtype = rand(255) + 65280 unless $rrtype;
318 for ( typebyval $rrtype = int($rrtype) ) {
319 croak "'$mnemonic' is a CLASS identifier" if $classbyname{$mnemonic};
320 return $rrtype if /^$mnemonic$/; # duplicate registration
321 croak "'$mnemonic' conflicts with TYPE$rrtype ($_)" unless /^TYPE\d+$/;
322 my $known = $typebyname{$mnemonic};
323 croak "'$mnemonic' conflicts with TYPE$known" if $known;
324 }
325 $typebyval{$rrtype} = $mnemonic;
326 return $typebyname{$mnemonic} = $rrtype;
327}
328
329
3302432µs2636µs
# spent 431µs (226+205) within Net::DNS::Parameters::BEGIN@330 which was called: # once (226µs+205µs) by Net::DNS::RR::BEGIN@41 at line 330
use constant EXTLANG => defined eval 'require Net::DNS::Extlang';
# spent 431µs making 1 call to Net::DNS::Parameters::BEGIN@330 # spent 205µs making 1 call to constant::import
# spent 157µs executing statements in string eval
331
33212µsour $DNSEXTLANG = EXTLANG ? eval 'Net::DNS::Extlang->new()->domain' : undef;
333
334sub _typespec { ## draft-levine-dnsextlang
335 eval <<'END' if EXTLANG && $DNSEXTLANG;
336 my ($node) = @_;
337
338 require Net::DNS::Resolver;
339 my $resolver = new Net::DNS::Resolver() || return;
340 my $response = $resolver->send( "$node.$DNSEXTLANG", 'TXT' ) || return;
341
342 foreach my $txt ( grep $_->type eq 'TXT', $response->answer ) {
343 my @stanza = $txt->txtdata;
344 my ( $tag, $identifier, @attribute ) = @stanza;
345 next unless defined($tag) && $tag =~ /^RRTYPE=\d+$/;
346 register( $1, $2 ) if $identifier =~ /^(\w+):(\d+)\W*/;
347 return unless defined wantarray;
348
349 my $extobj = new Net::DNS::Extlang();
350 my $recipe = $extobj->xlstorerecord( $identifier, @attribute );
351 my @source = split /\n/, $extobj->compilerr($recipe);
352 return sub { defined( $_ = shift @source ) };
353 }
354 return;
355END
356}
357
358
3591125µs1;
360__END__
 
# spent 672µs within Net::DNS::Parameters::CORE:match which was called 274 times, avg 2µs/call: # 170 times (388µs+0s) by Net::DNS::RR::BEGIN@41 at line 134, avg 2µs/call # 42 times (124µs+0s) by Net::DNS::RR::BEGIN@41 at line 176, avg 3µs/call # 28 times (68µs+0s) by Net::DNS::RR::BEGIN@41 at line 198, avg 2µs/call # 12 times (33µs+0s) by Net::DNS::RR::BEGIN@41 at line 211, avg 3µs/call # 10 times (32µs+0s) by Net::DNS::RR::BEGIN@41 at line 41, avg 3µs/call # 10 times (22µs+0s) by Net::DNS::RR::BEGIN@41 at line 147, avg 2µs/call # 2 times (5µs+0s) by Net::DNS::RR::BEGIN@41 at line 219, avg 2µs/call
sub Net::DNS::Parameters::CORE:match; # opcode