| Filename | /Users/marcus/perl5/perlbrew/perls/perl-5.10.1/lib/5.10.1/darwin-2level/IO/Socket/INET.pm |
| Statements | Executed 27123 statements in 61.8ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1002 | 3 | 2 | 11.6ms | 102ms | IO::Socket::INET::new |
| 1000 | 1 | 1 | 9.20ms | 30.0ms | IO::Socket::INET::sockaddr |
| 1000 | 1 | 1 | 9.14ms | 42.6ms | IO::Socket::INET::sockhost |
| 1000 | 1 | 1 | 8.47ms | 23.0ms | IO::Socket::INET::peeraddr |
| 1000 | 1 | 1 | 8.26ms | 32.7ms | IO::Socket::INET::peerhost |
| 1000 | 1 | 1 | 8.09ms | 13.2ms | IO::Socket::INET::peerport |
| 1000 | 1 | 1 | 7.79ms | 16.0ms | IO::Socket::INET::sockport |
| 2 | 1 | 1 | 104µs | 373µs | IO::Socket::INET::configure |
| 2 | 1 | 1 | 38µs | 50µs | IO::Socket::INET::_sock_info |
| 2 | 1 | 1 | 29µs | 64µs | IO::Socket::INET::bind |
| 1 | 1 | 1 | 22µs | 822µs | IO::Socket::INET::BEGIN@12 |
| 1 | 1 | 1 | 16µs | 19µs | IO::Socket::INET::BEGIN@9 |
| 2 | 2 | 1 | 11µs | 11µs | IO::Socket::INET::_get_proto_number |
| 1 | 1 | 1 | 8µs | 39µs | IO::Socket::INET::BEGIN@13 |
| 1 | 1 | 1 | 7µs | 20µs | IO::Socket::INET::BEGIN@14 |
| 1 | 1 | 1 | 7µs | 2.16ms | IO::Socket::INET::BEGIN@11 |
| 1 | 1 | 1 | 7µs | 24µs | IO::Socket::INET::BEGIN@15 |
| 1 | 1 | 1 | 5µs | 5µs | IO::Socket::INET::_get_proto_name |
| 3 | 3 | 1 | 5µs | 5µs | IO::Socket::INET::CORE:match (opcode) |
| 2 | 2 | 1 | 1µs | 1µs | IO::Socket::INET::CORE:subst (opcode) |
| 0 | 0 | 0 | 0s | 0s | IO::Socket::INET::_cache_proto |
| 0 | 0 | 0 | 0s | 0s | IO::Socket::INET::_error |
| 0 | 0 | 0 | 0s | 0s | IO::Socket::INET::_get_addr |
| 0 | 0 | 0 | 0s | 0s | IO::Socket::INET::connect |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | # IO::Socket::INET.pm | ||||
| 2 | # | ||||
| 3 | # Copyright (c) 1997-8 Graham Barr <gbarr@pobox.com>. All rights reserved. | ||||
| 4 | # This program is free software; you can redistribute it and/or | ||||
| 5 | # modify it under the same terms as Perl itself. | ||||
| 6 | |||||
| 7 | package IO::Socket::INET; | ||||
| 8 | |||||
| 9 | 3 | 33µs | 2 | 22µs | # spent 19µs (16+3) within IO::Socket::INET::BEGIN@9 which was called:
# once (16µs+3µs) by Mojo::IOLoop::BEGIN@9 at line 9 # spent 19µs making 1 call to IO::Socket::INET::BEGIN@9
# spent 3µs making 1 call to strict::import |
| 10 | 1 | 300ns | our(@ISA, $VERSION); | ||
| 11 | 3 | 27µs | 2 | 4.32ms | # spent 2.16ms (7µs+2.16) within IO::Socket::INET::BEGIN@11 which was called:
# once (7µs+2.16ms) by Mojo::IOLoop::BEGIN@9 at line 11 # spent 2.16ms making 1 call to IO::Socket::INET::BEGIN@11
# spent 2.16ms making 1 call to IO::Socket::import |
| 12 | 3 | 24µs | 2 | 1.62ms | # spent 822µs (22+800) within IO::Socket::INET::BEGIN@12 which was called:
# once (22µs+800µs) by Mojo::IOLoop::BEGIN@9 at line 12 # spent 822µs making 1 call to IO::Socket::INET::BEGIN@12
# spent 800µs making 1 call to Exporter::import |
| 13 | 3 | 22µs | 2 | 70µs | # spent 39µs (8+31) within IO::Socket::INET::BEGIN@13 which was called:
# once (8µs+31µs) by Mojo::IOLoop::BEGIN@9 at line 13 # spent 39µs making 1 call to IO::Socket::INET::BEGIN@13
# spent 31µs making 1 call to Exporter::import |
| 14 | 3 | 19µs | 2 | 32µs | # spent 20µs (7+12) within IO::Socket::INET::BEGIN@14 which was called:
# once (7µs+12µs) by Mojo::IOLoop::BEGIN@9 at line 14 # spent 20µs making 1 call to IO::Socket::INET::BEGIN@14
# spent 12µs making 1 call to Exporter::import |
| 15 | 3 | 1.37ms | 2 | 42µs | # spent 24µs (7+17) within IO::Socket::INET::BEGIN@15 which was called:
# once (7µs+17µs) by Mojo::IOLoop::BEGIN@9 at line 15 # spent 24µs making 1 call to IO::Socket::INET::BEGIN@15
# spent 17µs making 1 call to Exporter::import |
| 16 | |||||
| 17 | 1 | 8µs | @ISA = qw(IO::Socket); | ||
| 18 | 1 | 300ns | $VERSION = "1.31"; | ||
| 19 | |||||
| 20 | 1 | 600ns | my $EINVAL = exists(&Errno::EINVAL) ? Errno::EINVAL() : 1; | ||
| 21 | |||||
| 22 | 1 | 4µs | 1 | 3µs | IO::Socket::INET->register_domain( AF_INET ); # spent 3µs making 1 call to IO::Socket::register_domain |
| 23 | |||||
| 24 | 1 | 1µs | my %socket_type = ( tcp => SOCK_STREAM, | ||
| 25 | udp => SOCK_DGRAM, | ||||
| 26 | icmp => SOCK_RAW | ||||
| 27 | ); | ||||
| 28 | 1 | 100ns | my %proto_number; | ||
| 29 | 1 | 600ns | $proto_number{tcp} = Socket::IPPROTO_TCP() if defined &Socket::IPPROTO_TCP; | ||
| 30 | 1 | 200ns | $proto_number{udp} = Socket::IPPROTO_UDP() if defined &Socket::IPPROTO_UDP; | ||
| 31 | 1 | 200ns | $proto_number{icmp} = Socket::IPPROTO_ICMP() if defined &Socket::IPPROTO_ICMP; | ||
| 32 | 1 | 4µs | my %proto_name = reverse %proto_number; | ||
| 33 | |||||
| 34 | # spent 102ms (11.6+90.3) within IO::Socket::INET::new which was called 1002 times, avg 102µs/call:
# 1000 times (11.6ms+89.7ms) by IO::Socket::accept at line 222 of IO/Socket.pm, avg 101µs/call
# once (25µs+382µs) by Mojo::IOLoop::listen at line 338 of Mojo/IOLoop.pm
# once (10µs+201µs) by Mojo::IOLoop::_prepare_loop at line 1358 of Mojo/IOLoop.pm | ||||
| 35 | 3006 | 10.5ms | my $class = shift; | ||
| 36 | unshift(@_, "PeerAddr") if @_ == 1; | ||||
| 37 | 1002 | 90.3ms | return $class->SUPER::new(@_); # spent 90.3ms making 1002 calls to IO::Socket::new, avg 90µs/call | ||
| 38 | } | ||||
| 39 | |||||
| 40 | sub _cache_proto { | ||||
| 41 | my @proto = @_; | ||||
| 42 | for (map lc($_), $proto[0], split(' ', $proto[1])) { | ||||
| 43 | $proto_number{$_} = $proto[2]; | ||||
| 44 | } | ||||
| 45 | $proto_name{$proto[2]} = $proto[0]; | ||||
| 46 | } | ||||
| 47 | |||||
| 48 | sub _get_proto_number { | ||||
| 49 | 6 | 13µs | my $name = lc(shift); | ||
| 50 | return undef unless defined $name; | ||||
| 51 | return $proto_number{$name} if exists $proto_number{$name}; | ||||
| 52 | |||||
| 53 | my @proto = getprotobyname($name); | ||||
| 54 | return undef unless @proto; | ||||
| 55 | _cache_proto(@proto); | ||||
| 56 | |||||
| 57 | return $proto[2]; | ||||
| 58 | } | ||||
| 59 | |||||
| 60 | # spent 5µs within IO::Socket::INET::_get_proto_name which was called:
# once (5µs+0s) by IO::Socket::INET::configure at line 168 | ||||
| 61 | 3 | 6µs | my $num = shift; | ||
| 62 | return undef unless defined $num; | ||||
| 63 | return $proto_name{$num} if exists $proto_name{$num}; | ||||
| 64 | |||||
| 65 | my @proto = getprotobynumber($num); | ||||
| 66 | return undef unless @proto; | ||||
| 67 | _cache_proto(@proto); | ||||
| 68 | |||||
| 69 | return $proto[0]; | ||||
| 70 | } | ||||
| 71 | |||||
| 72 | # spent 50µs (38+13) within IO::Socket::INET::_sock_info which was called 2 times, avg 25µs/call:
# 2 times (38µs+13µs) by IO::Socket::INET::configure at line 145, avg 25µs/call | ||||
| 73 | 23 | 42µs | my($addr,$port,$proto) = @_; | ||
| 74 | my $origport = $port; | ||||
| 75 | my @serv = (); | ||||
| 76 | |||||
| 77 | 1 | 700ns | $port = $1 # spent 700ns making 1 call to IO::Socket::INET::CORE:subst | ||
| 78 | if(defined $addr && $addr =~ s,:([\w\(\)/]+)$,,); | ||||
| 79 | |||||
| 80 | 1 | 2µs | if(defined $proto && $proto =~ /\D/) { # spent 2µs making 1 call to IO::Socket::INET::CORE:match | ||
| 81 | 1 | 7µs | my $num = _get_proto_number($proto); # spent 7µs making 1 call to IO::Socket::INET::_get_proto_number | ||
| 82 | unless (defined $num) { | ||||
| 83 | $@ = "Bad protocol '$proto'"; | ||||
| 84 | return; | ||||
| 85 | } | ||||
| 86 | $proto = $num; | ||||
| 87 | } | ||||
| 88 | |||||
| 89 | if(defined $port) { | ||||
| 90 | 1 | 600ns | my $defport = ($port =~ s,\((\d+)\)$,,) ? $1 : undef; # spent 600ns making 1 call to IO::Socket::INET::CORE:subst | ||
| 91 | 1 | 2µs | my $pnum = ($port =~ m,^(\d+)$,)[0]; # spent 2µs making 1 call to IO::Socket::INET::CORE:match | ||
| 92 | |||||
| 93 | 1 | 500ns | @serv = getservbyname($port, _get_proto_name($proto) || "") # spent 500ns making 1 call to IO::Socket::INET::CORE:match | ||
| 94 | if ($port =~ m,\D,); | ||||
| 95 | |||||
| 96 | $port = $serv[2] || $defport || $pnum; | ||||
| 97 | unless (defined $port) { | ||||
| 98 | $@ = "Bad service '$origport'"; | ||||
| 99 | return; | ||||
| 100 | } | ||||
| 101 | |||||
| 102 | $proto = _get_proto_number($serv[3]) if @serv && !$proto; | ||||
| 103 | } | ||||
| 104 | |||||
| 105 | return ($addr || undef, | ||||
| 106 | $port || undef, | ||||
| 107 | $proto || undef | ||||
| 108 | ); | ||||
| 109 | } | ||||
| 110 | |||||
| 111 | sub _error { | ||||
| 112 | my $sock = shift; | ||||
| 113 | my $err = shift; | ||||
| 114 | { | ||||
| 115 | local($!); | ||||
| 116 | my $title = ref($sock).": "; | ||||
| 117 | $@ = join("", $_[0] =~ /^$title/ ? "" : $title, @_); | ||||
| 118 | $sock->close() | ||||
| 119 | if(defined fileno($sock)); | ||||
| 120 | } | ||||
| 121 | $! = $err; | ||||
| 122 | return undef; | ||||
| 123 | } | ||||
| 124 | |||||
| 125 | sub _get_addr { | ||||
| 126 | my($sock,$addr_str, $multi) = @_; | ||||
| 127 | my @addr; | ||||
| 128 | if ($multi && $addr_str !~ /^\d+(?:\.\d+){3}$/) { | ||||
| 129 | (undef, undef, undef, undef, @addr) = gethostbyname($addr_str); | ||||
| 130 | } else { | ||||
| 131 | my $h = inet_aton($addr_str); | ||||
| 132 | push(@addr, $h) if defined $h; | ||||
| 133 | } | ||||
| 134 | @addr; | ||||
| 135 | } | ||||
| 136 | |||||
| 137 | # spent 373µs (104+269) within IO::Socket::INET::configure which was called 2 times, avg 187µs/call:
# 2 times (104µs+269µs) by IO::Socket::new at line 48 of IO/Socket.pm, avg 187µs/call | ||||
| 138 | 49 | 95µs | my($sock,$arg) = @_; | ||
| 139 | my($lport,$rport,$laddr,$raddr,$proto,$type); | ||||
| 140 | |||||
| 141 | |||||
| 142 | $arg->{LocalAddr} = $arg->{LocalHost} | ||||
| 143 | if exists $arg->{LocalHost} && !exists $arg->{LocalAddr}; | ||||
| 144 | |||||
| 145 | 2 | 50µs | ($laddr,$lport,$proto) = _sock_info($arg->{LocalAddr}, # spent 50µs making 2 calls to IO::Socket::INET::_sock_info, avg 25µs/call | ||
| 146 | $arg->{LocalPort}, | ||||
| 147 | $arg->{Proto}) | ||||
| 148 | or return _error($sock, $!, $@); | ||||
| 149 | |||||
| 150 | 1 | 8µs | $laddr = defined $laddr ? inet_aton($laddr) # spent 8µs making 1 call to Socket::inet_aton | ||
| 151 | : INADDR_ANY; | ||||
| 152 | |||||
| 153 | return _error($sock, $EINVAL, "Bad hostname '",$arg->{LocalAddr},"'") | ||||
| 154 | unless(defined $laddr); | ||||
| 155 | |||||
| 156 | $arg->{PeerAddr} = $arg->{PeerHost} | ||||
| 157 | if exists $arg->{PeerHost} && !exists $arg->{PeerAddr}; | ||||
| 158 | |||||
| 159 | unless(exists $arg->{Listen}) { | ||||
| 160 | ($raddr,$rport,$proto) = _sock_info($arg->{PeerAddr}, | ||||
| 161 | $arg->{PeerPort}, | ||||
| 162 | $proto) | ||||
| 163 | or return _error($sock, $!, $@); | ||||
| 164 | } | ||||
| 165 | |||||
| 166 | 1 | 4µs | $proto ||= _get_proto_number('tcp'); # spent 4µs making 1 call to IO::Socket::INET::_get_proto_number | ||
| 167 | |||||
| 168 | 1 | 5µs | $type = $arg->{Type} || $socket_type{lc _get_proto_name($proto)}; # spent 5µs making 1 call to IO::Socket::INET::_get_proto_name | ||
| 169 | |||||
| 170 | my @raddr = (); | ||||
| 171 | |||||
| 172 | if(defined $raddr) { | ||||
| 173 | @raddr = $sock->_get_addr($raddr, $arg->{MultiHomed}); | ||||
| 174 | return _error($sock, $EINVAL, "Bad hostname '",$arg->{PeerAddr},"'") | ||||
| 175 | unless @raddr; | ||||
| 176 | } | ||||
| 177 | |||||
| 178 | while(1) { | ||||
| 179 | |||||
| 180 | 2 | 83µs | $sock->socket(AF_INET, $type, $proto) or # spent 83µs making 2 calls to IO::Socket::socket, avg 42µs/call | ||
| 181 | return _error($sock, $!, "$!"); | ||||
| 182 | |||||
| 183 | if (defined $arg->{Blocking}) { | ||||
| 184 | defined $sock->blocking($arg->{Blocking}) | ||||
| 185 | or return _error($sock, $!, "$!"); | ||||
| 186 | } | ||||
| 187 | |||||
| 188 | if ($arg->{Reuse} || $arg->{ReuseAddr}) { | ||||
| 189 | 1 | 30µs | $sock->sockopt(SO_REUSEADDR,1) or # spent 30µs making 1 call to IO::Socket::sockopt | ||
| 190 | return _error($sock, $!, "$!"); | ||||
| 191 | } | ||||
| 192 | |||||
| 193 | if ($arg->{ReusePort}) { | ||||
| 194 | $sock->sockopt(SO_REUSEPORT,1) or | ||||
| 195 | return _error($sock, $!, "$!"); | ||||
| 196 | } | ||||
| 197 | |||||
| 198 | if ($arg->{Broadcast}) { | ||||
| 199 | $sock->sockopt(SO_BROADCAST,1) or | ||||
| 200 | return _error($sock, $!, "$!"); | ||||
| 201 | } | ||||
| 202 | |||||
| 203 | if($lport || ($laddr ne INADDR_ANY) || exists $arg->{Listen}) { | ||||
| 204 | 2 | 64µs | $sock->bind($lport || 0, $laddr) or # spent 64µs making 2 calls to IO::Socket::INET::bind, avg 32µs/call | ||
| 205 | return _error($sock, $!, "$!"); | ||||
| 206 | } | ||||
| 207 | |||||
| 208 | if(exists $arg->{Listen}) { | ||||
| 209 | 2 | 25µs | $sock->listen($arg->{Listen} || 5) or # spent 25µs making 2 calls to IO::Socket::listen, avg 12µs/call | ||
| 210 | return _error($sock, $!, "$!"); | ||||
| 211 | last; | ||||
| 212 | } | ||||
| 213 | |||||
| 214 | # don't try to connect unless we're given a PeerAddr | ||||
| 215 | last unless exists($arg->{PeerAddr}); | ||||
| 216 | |||||
| 217 | $raddr = shift @raddr; | ||||
| 218 | |||||
| 219 | return _error($sock, $EINVAL, 'Cannot determine remote port') | ||||
| 220 | unless($rport || $type == SOCK_DGRAM || $type == SOCK_RAW); | ||||
| 221 | |||||
| 222 | last | ||||
| 223 | unless($type == SOCK_STREAM || defined $raddr); | ||||
| 224 | |||||
| 225 | return _error($sock, $EINVAL, "Bad hostname '",$arg->{PeerAddr},"'") | ||||
| 226 | unless defined $raddr; | ||||
| 227 | |||||
| 228 | # my $timeout = ${*$sock}{'io_socket_timeout'}; | ||||
| 229 | # my $before = time() if $timeout; | ||||
| 230 | |||||
| 231 | undef $@; | ||||
| 232 | if ($sock->connect(pack_sockaddr_in($rport, $raddr))) { | ||||
| 233 | # ${*$sock}{'io_socket_timeout'} = $timeout; | ||||
| 234 | return $sock; | ||||
| 235 | } | ||||
| 236 | |||||
| 237 | return _error($sock, $!, $@ || "Timeout") | ||||
| 238 | unless @raddr; | ||||
| 239 | |||||
| 240 | # if ($timeout) { | ||||
| 241 | # my $new_timeout = $timeout - (time() - $before); | ||||
| 242 | # return _error($sock, | ||||
| 243 | # (exists(&Errno::ETIMEDOUT) ? Errno::ETIMEDOUT() : $EINVAL), | ||||
| 244 | # "Timeout") if $new_timeout <= 0; | ||||
| 245 | # ${*$sock}{'io_socket_timeout'} = $new_timeout; | ||||
| 246 | # } | ||||
| 247 | |||||
| 248 | } | ||||
| 249 | |||||
| 250 | $sock; | ||||
| 251 | } | ||||
| 252 | |||||
| 253 | sub connect { | ||||
| 254 | @_ == 2 || @_ == 3 or | ||||
| 255 | croak 'usage: $sock->connect(NAME) or $sock->connect(PORT, ADDR)'; | ||||
| 256 | my $sock = shift; | ||||
| 257 | return $sock->SUPER::connect(@_ == 1 ? shift : pack_sockaddr_in(@_)); | ||||
| 258 | } | ||||
| 259 | |||||
| 260 | # spent 64µs (29+35) within IO::Socket::INET::bind which was called 2 times, avg 32µs/call:
# 2 times (29µs+35µs) by IO::Socket::INET::configure at line 204, avg 32µs/call | ||||
| 261 | 6 | 35µs | @_ == 2 || @_ == 3 or | ||
| 262 | croak 'usage: $sock->bind(NAME) or $sock->bind(PORT, ADDR)'; | ||||
| 263 | my $sock = shift; | ||||
| 264 | 4 | 35µs | return $sock->SUPER::bind(@_ == 1 ? shift : pack_sockaddr_in(@_)) # spent 28µs making 2 calls to IO::Socket::bind, avg 14µs/call
# spent 7µs making 2 calls to Socket::pack_sockaddr_in, avg 4µs/call | ||
| 265 | } | ||||
| 266 | |||||
| 267 | # spent 30.0ms (9.20+20.8) within IO::Socket::INET::sockaddr which was called 1000 times, avg 30µs/call:
# 1000 times (9.20ms+20.8ms) by IO::Socket::INET::sockhost at line 284, avg 30µs/call | ||||
| 268 | 4000 | 9.54ms | @_ == 1 or croak 'usage: $sock->sockaddr()'; | ||
| 269 | my($sock) = @_; | ||||
| 270 | 1000 | 10.0ms | my $name = $sock->sockname; # spent 10.0ms making 1000 calls to IO::Socket::sockname, avg 10µs/call | ||
| 271 | 1000 | 10.8ms | $name ? (sockaddr_in($name))[1] : undef; # spent 10.8ms making 1000 calls to Socket::sockaddr_in, avg 11µs/call | ||
| 272 | } | ||||
| 273 | |||||
| 274 | # spent 16.0ms (7.79+8.22) within IO::Socket::INET::sockport which was called 1000 times, avg 16µs/call:
# 1000 times (7.79ms+8.22ms) by Mojo::IOLoop::local_info at line 402 of Mojo/IOLoop.pm, avg 16µs/call | ||||
| 275 | 4000 | 6.06ms | @_ == 1 or croak 'usage: $sock->sockport()'; | ||
| 276 | my($sock) = @_; | ||||
| 277 | 1000 | 4.34ms | my $name = $sock->sockname; # spent 4.34ms making 1000 calls to IO::Socket::sockname, avg 4µs/call | ||
| 278 | 1000 | 3.87ms | $name ? (sockaddr_in($name))[0] : undef; # spent 3.87ms making 1000 calls to Socket::sockaddr_in, avg 4µs/call | ||
| 279 | } | ||||
| 280 | |||||
| 281 | # spent 42.6ms (9.14+33.4) within IO::Socket::INET::sockhost which was called 1000 times, avg 43µs/call:
# 1000 times (9.14ms+33.4ms) by Mojo::IOLoop::local_info at line 402 of Mojo/IOLoop.pm, avg 43µs/call | ||||
| 282 | 4000 | 11.8ms | @_ == 1 or croak 'usage: $sock->sockhost()'; | ||
| 283 | my($sock) = @_; | ||||
| 284 | 1000 | 30.0ms | my $addr = $sock->sockaddr; # spent 30.0ms making 1000 calls to IO::Socket::INET::sockaddr, avg 30µs/call | ||
| 285 | 1000 | 3.39ms | $addr ? inet_ntoa($addr) : undef; # spent 3.39ms making 1000 calls to Socket::inet_ntoa, avg 3µs/call | ||
| 286 | } | ||||
| 287 | |||||
| 288 | # spent 23.0ms (8.47+14.5) within IO::Socket::INET::peeraddr which was called 1000 times, avg 23µs/call:
# 1000 times (8.47ms+14.5ms) by IO::Socket::INET::peerhost at line 305, avg 23µs/call | ||||
| 289 | 4000 | 7.45ms | @_ == 1 or croak 'usage: $sock->peeraddr()'; | ||
| 290 | my($sock) = @_; | ||||
| 291 | 1000 | 10.4ms | my $name = $sock->peername; # spent 10.4ms making 1000 calls to IO::Socket::peername, avg 10µs/call | ||
| 292 | 1000 | 4.06ms | $name ? (sockaddr_in($name))[1] : undef; # spent 4.06ms making 1000 calls to Socket::sockaddr_in, avg 4µs/call | ||
| 293 | } | ||||
| 294 | |||||
| 295 | # spent 13.2ms (8.09+5.08) within IO::Socket::INET::peerport which was called 1000 times, avg 13µs/call:
# 1000 times (8.09ms+5.08ms) by Mojo::IOLoop::remote_info at line 577 of Mojo/IOLoop.pm, avg 13µs/call | ||||
| 296 | 4000 | 6.15ms | @_ == 1 or croak 'usage: $sock->peerport()'; | ||
| 297 | my($sock) = @_; | ||||
| 298 | 1000 | 1.52ms | my $name = $sock->peername; # spent 1.52ms making 1000 calls to IO::Socket::peername, avg 2µs/call | ||
| 299 | 1000 | 3.56ms | $name ? (sockaddr_in($name))[0] : undef; # spent 3.56ms making 1000 calls to Socket::sockaddr_in, avg 4µs/call | ||
| 300 | } | ||||
| 301 | |||||
| 302 | # spent 32.7ms (8.26+24.4) within IO::Socket::INET::peerhost which was called 1000 times, avg 33µs/call:
# 1000 times (8.26ms+24.4ms) by Mojo::IOLoop::remote_info at line 577 of Mojo/IOLoop.pm, avg 33µs/call | ||||
| 303 | 4000 | 8.69ms | @_ == 1 or croak 'usage: $sock->peerhost()'; | ||
| 304 | my($sock) = @_; | ||||
| 305 | 1000 | 23.0ms | my $addr = $sock->peeraddr; # spent 23.0ms making 1000 calls to IO::Socket::INET::peeraddr, avg 23µs/call | ||
| 306 | 1000 | 1.47ms | $addr ? inet_ntoa($addr) : undef; # spent 1.47ms making 1000 calls to Socket::inet_ntoa, avg 1µs/call | ||
| 307 | } | ||||
| 308 | |||||
| 309 | 1 | 16µs | 1; | ||
| 310 | |||||
| 311 | __END__ | ||||
sub IO::Socket::INET::CORE:match; # opcode | |||||
sub IO::Socket::INET::CORE:subst; # opcode |