Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of github.com:shafiev/AnyEvent-HTTPBenchmark

Conflicts:
	benchmark.pl
  • Loading branch information...
commit 69cbce36af5d3c2a71aba845f4a18c5d24b6e849 2 parents d8871f4 + 7e8db1c
@shafiev authored
Showing with 18 additions and 4 deletions.
  1. +18 −4 benchmark.pl
View
22 benchmark.pl
@@ -27,22 +27,35 @@
$AnyEvent::HTTP::set_proxy = $proxy;
$AnyEvent::HTTP::USERAGENT = $useragent;
+
+=for 1
# Caching results of AnyEvent::DNS::a
# really hack code.will rewrited in nearest future
my $orig_anyeventdnsa = \&AnyEvent::DNS::a;
-my %cache;
+my %result_cache;
+my %callback_cache;
*AnyEvent::DNS::a = sub($$) {
my ($domain, $cb) = @_;
- if ($cache{$domain}) {
- $cb->( @{ $cache{$domain} } );
+ if ($result_cache{$domain}) {
+ $cb->( @{ $result_cache{$domain} } );
return;
}
+ if ($callback_cache{$domain}) {
+ push @{ $callback_cache{$domain} }, $cb;
+ return;
+ }
+
+ $callback_cache{$domain} = [];
+
$orig_anyeventdnsa->( $domain,
sub {
- $cache{$domain} = [ @_ ];
+ $result_cache{$domain} = [ @_ ];
$cb->( @_ );
+ while ( my $cached_cb = shift @{ $callback_cache{$domain} } ) {
+ $cached_cb->( @_ );
+ }
}
);
@@ -50,6 +63,7 @@
};
# End of caching
# End of MegaKostil'
+=cut
#on ctrl-c break run the end_bench sub.
$SIG{'INT'} = 'end_bench';
Please sign in to comment.
Something went wrong with that request. Please try again.