AnyEvent
view release on metacpan or search on metacpan
but it is a benchmark nevertheless.
name runtime
Lambda/select 0.330 sec
+ optimized 0.122 sec
Lambda/AnyEvent 0.327 sec
+ optimized 0.138 sec
Raw sockets/select 0.077 sec
POE/select, components 0.662 sec
POE/select, raw sockets 0.226 sec
POE/select, optimized 0.404 sec
AnyEvent/select/nb 0.085 sec
AnyEvent/EV/nb 0.068 sec
+state machine 0.134 sec
The benchmark is also a bit unfair (my fault): the IO::Lambda/POE
benchmarks actually make blocking connects and use 100% blocking I/O,
defeating the purpose of an event-based solution. All of the newly
written AnyEvent benchmarks use 100% non-blocking connects (using
AnyEvent::Socket::tcp_connect and the asynchronous pure perl DNS
lib/AnyEvent.pm view on Meta::CPAN
benchmark nevertheless.
name runtime
Lambda/select 0.330 sec
+ optimized 0.122 sec
Lambda/AnyEvent 0.327 sec
+ optimized 0.138 sec
Raw sockets/select 0.077 sec
POE/select, components 0.662 sec
POE/select, raw sockets 0.226 sec
POE/select, optimized 0.404 sec
AnyEvent/select/nb 0.085 sec
AnyEvent/EV/nb 0.068 sec
+state machine 0.134 sec
The benchmark is also a bit unfair (my fault): the IO::Lambda/POE
benchmarks actually make blocking connects and use 100% blocking I/O,
defeating the purpose of an event-based solution. All of the newly
written AnyEvent benchmarks use 100% non-blocking connects (using
AnyEvent::Socket::tcp_connect and the asynchronous pure perl DNS
lib/AnyEvent/DNS.pm view on Meta::CPAN
{
my $prep = sub {
$_ = $_->[rand @$_] for @_;
push @_, splice @_, rand $_, 1 for reverse 1..@_; # shuffle
$_ = pack "H*", $_ for @_;
\@_
};
my $ipv4 = $prep->(
["08080808", "08080404"], # 8.8.8.8, 8.8.4.4 - google public dns
["01010101", "01000001"], # 1.1.1.1, 1.0.0.1 - cloudflare public dns
["50505050", "50505151"], # 80.80.80.80, 80.80.81.81 - freenom.world
## ["d1f40003", "d1f30004"], # v209.244.0.3/4 - resolver1/2.level3.net - status unknown
## ["04020201", "04020203", "04020204", "04020205", "04020206"], # v4.2.2.1/3/4/5/6 - vnsc-pri.sys.gtei.net - effectively public
## ["cdd22ad2", "4044c8c8"], # 205.210.42.205, 64.68.200.200 - cache1/2.dnsresolvers.com - verified public
# ["8d010101"], # 141.1.1.1 - cable&wireless, now vodafone - status unknown
# 84.200.69.80 # dns.watch
# 84.200.70.40 # dns.watch
# 37.235.1.174 # freedns.zone
# 37.235.1.177 # freedns.zone
# 213.73.91.35 # dnscache.berlin.ccc.de
# 194.150.168.168 # dns.as250.net; Berlin/Frankfurt
# 85.214.20.141 # FoeBud (digitalcourage.de)
# 77.109.148.136 # privacyfoundation.ch
# 77.109.148.137 # privacyfoundation.ch
lib/AnyEvent/Intro.pod view on Meta::CPAN
Again, let's try it out with C<telnet> (I condensed the output a bit - if
you want to see the full response, do it yourself).
# telnet www.google.com 80
Trying 209.85.135.99...
Connected to www.google.com (209.85.135.99).
Escape character is '^]'.
GET /test HTTP/1.0
HTTP/1.0 404 Not Found
Date: Mon, 02 Jun 2008 07:05:54 GMT
Content-Type: text/html; charset=UTF-8
<html><head>
[...]
Connection closed by foreign host.
The C<GET ...> and the empty line were entered manually, the rest of the
telnet output is google's response, in this case a C<404 not found> one.
So, here is how you would do it with C<AnyEvent::Handle>:
sub http_get {
my ($host, $uri, $cb) = @_;
# store results here
my ($response, $header, $body);
my $handle; $handle = new AnyEvent::Handle
( run in 0.798 second using v1.01-cache-2.11-cpan-39bf76dae61 )