Skip to content

Commit

Permalink
adding more help.
Browse files Browse the repository at this point in the history
remove some not working code.
  • Loading branch information
shafiev committed Jun 19, 2010
1 parent 69cbce3 commit c98b5ed
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 56 deletions.
53 changes: 7 additions & 46 deletions benchmark.pl
Original file line number Original file line Diff line number Diff line change
@@ -1,21 +1,19 @@
#!/usr/bin/env perl #!/usr/bin/env perl
use common::sense; #new features in perl(not for 5.8.8 and older (; ) use common::sense; #new features in perl
use AnyEvent::HTTP; # main module
use Getopt::Long; # to command line parsing use Getopt::Long; # to command line parsing
use POSIX; use POSIX;
use Data::Dumper; # to see the date in debug use Data::Dumper; # to debug data
my $DEBUG = 0; #Debug mode. Default is false (0) my $DEBUG = 0; #Debug mode. Default is false (0)
my $verbose = 0; #to view the each connection result my $verbose = 0; #to view the each connection result
my $timeout = 60; my $timeout = 60;
my $count = 30000; #number of requests my $count = 30000; #number of requests
my $concurency = 20; # number of parralle requests my $concurency = 20; # number of parralle requests
my $done = 0; #number of done requests my $done = 0; #number of done requests
my $url; my $url; # the url to test
my $method = 'GET'; #http method my $method = 'GET'; #http method
my $proxy; # proxy server my $proxy; # proxy server
my $file; #scenario file(for future use);
my $max_recurse = 10; # the default recurse number; my $max_recurse = 10; # the default recurse number;
my $useragent = 'Mozilla/5.0 (compatible; U; AnyEvent::HTTPBenchmark/0.05; +http://github.com/shafiev/AnyEvent-HTTPBenchmark)'; my $useragent = 'Mozilla/5.0 (compatible; U; AnyEvent::HTTPBenchmark/0.06; +http://github.com/shafiev/AnyEvent-HTTPBenchmark)';


#arrays #arrays
my @reqs_time; # the times of requests my @reqs_time; # the times of requests
Expand All @@ -27,44 +25,6 @@
$AnyEvent::HTTP::set_proxy = $proxy; $AnyEvent::HTTP::set_proxy = $proxy;
$AnyEvent::HTTP::USERAGENT = $useragent; $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 %result_cache;
my %callback_cache;
*AnyEvent::DNS::a = sub($$) {
my ($domain, $cb) = @_;
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 {
$result_cache{$domain} = [ @_ ];
$cb->( @_ );
while ( my $cached_cb = shift @{ $callback_cache{$domain} } ) {
$cached_cb->( @_ );
}
}
);
return;
};
# End of caching
# End of MegaKostil'
=cut

#on ctrl-c break run the end_bench sub. #on ctrl-c break run the end_bench sub.
$SIG{'INT'} = 'end_bench'; $SIG{'INT'} = 'end_bench';


Expand Down Expand Up @@ -100,10 +60,10 @@ sub parse_command_line {
-useragent useragent string -useragent useragent string
Example : Example :
./benchmark.pl -url=http://myfavouritesite.com -n=number_of_requests -c=number_of_parrallel clients ./benchmark.pl -url http://myfavouritesite.com -n number_of_requests -c number_of_parrallel clients
Another example : Another example :
./benchmark.pl --url=http://example.com -n=100 -c=10 -v benchmark.pl --url http://example.com -n 100 -c 10 -v
HEREDOC HEREDOC
Expand All @@ -122,6 +82,7 @@ sub parse_command_line {
); );


if ($concurency > $count) { if ($concurency > $count) {
#the mini hack to prevoid stupid cases ;)
$concurency = $count; $concurency = $count;
} }


Expand Down
17 changes: 7 additions & 10 deletions lib/AnyEvent/HTTPBenchmark.pm
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -9,26 +9,23 @@ AnyEvent::HTTPBenchmark - The tool to make benchmark good and easy!
=head1 VERSION =head1 VERSION
Version 0.05 Version 0.06
=cut =cut


our $VERSION = '0.05'; our $VERSION = '0.06';




=head1 SYNOPSIS =head1 SYNOPSIS
The apache benchmark (ab) , siege, jmeter and etc, are sometimes awesome to make http-load testing. But if
you want make some non-traditional test they are not good decision.This module try to help you in this case.
Currently implemented just test utility , not a library .
Quick summary of what the module does. benchmark.pl --url http://example.com -n 100 -c 10 -v
Perhaps a little code snippet.
use AnyEvent::HTTPBenchmark;
=head1 EXPORT =head1 EXPORT
A list of functions that can be exported. You can delete this section Currently no export functions are implemented.
if you don't export anything, such as for a purely object-oriented module.
=head1 SUBROUTINES/METHODS =head1 SUBROUTINES/METHODS
Expand Down

0 comments on commit c98b5ed

Please sign in to comment.