Navigation Menu

Skip to content

Commit

Permalink
more doc updates
Browse files Browse the repository at this point in the history
  • Loading branch information
apocalypse committed Dec 13, 2008
1 parent b29d2ad commit 0fb6e7f
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Build.PL
Expand Up @@ -41,7 +41,7 @@ my $build = Module::Build->new(

'recommends' => {
# Test stuff
'Test::More' => 0,
'Test::More' => '0.86', # require latest for note() support in t/a_is_prereq_outdated.t

# our POE loops!
'POE::Loop::Event' => 0,
Expand Down
2 changes: 2 additions & 0 deletions Changes
Expand Up @@ -3,6 +3,8 @@ Revision history for Perl extension POE::Devel::Benchmarker
* 0.03

Added the loop option to benchmark(), thanks dngor!
More redocumentation
Bump Test::More version requirement because some people reported failures with note()

* 0.02

Expand Down
46 changes: 39 additions & 7 deletions lib/POE/Devel/Benchmarker.pm
Expand Up @@ -466,20 +466,50 @@ configurations. The current "tests" are:
=item posts
This tests how long it takes to post() N times
This tests how long it took to dispatch/deliver all the posts enqueued in the post() test
This tests how long it took to yield() between 2 states for N times
=item calls
=item alarm_adds
This tests how long it took to call() N times
=item alarms
This tests how long it took to add N alarms via alarm(), overwriting each other
This tests how long it took to add N alarms via alarm_add() and how long it took to delete them all
NOTE: alarm_add is not available on all versions of POE!
=item sessions
=item session creation
This tests how long it took to create N sessions, and how long it took to destroy them all
=item session destruction
=item filehandles
=item select_read toggles
This tests how long it took to toggle select_read N times on STDIN and a real filehandle via open()
=item select_write toggles
This tests how long it took to toggle select_write N times on STDIN and a real filehandle via open()
=item POE startup time
This tests how long it took to start + close N instances of a "virgin" POE without any sessions/etc
=item POE Loops
This is actually a "super" test where all of the specific tests is ran against various POE::Loop::XYZ/FOO for comparison
=item POE Assertions
This is actually a "super" test where all of the specific tests is ran against POE with/without assertions enabled
=item POE::XS::Queue::Array
This is actually a "super" test where all of the specific tests is ran against POE with XS goodness enabled/disabled
=back
=head1 DESCRIPTION
Expand Down Expand Up @@ -604,8 +634,8 @@ Automatically exports the benchmark() subroutine.
=item Perl version smoking
We should be able to run the benchmark over different Perl versions. This would require some fiddling with our
layout + logic. It's not that urgent because the workaround is to simply execute the smoke suite under a different
perl binary. It's smart enough to use $^X to be consistent across tests :)
layout + logic. It's not that urgent because the workaround is to simply execute the benchmarker under a different
perl binary. It's smart enough to use $^X to be consistent across tests/subprocesses :)
=item Select the EV backend
Expand Down Expand Up @@ -636,6 +666,8 @@ dngor said there was some benchmarks in the POE svn under trunk/queue...
I want a bench that actually tests socket traffic - stream 10MB of traffic over localhost, and time it?
LotR and Tapout contributed some samples, let's see if I can integrate them...
=item Add SQLite/DBI/etc support to the Analyzer
It would be nice if we could have a local SQLite db to dump our stats into. This would make arbitrary reports much easier than
Expand Down
5 changes: 4 additions & 1 deletion lib/POE/Devel/Benchmarker/GetInstalledLoops.pm
Expand Up @@ -18,6 +18,9 @@ BEGIN {
use POE qw( Session Filter::Line Wheel::Run );
use base 'POE::Session::AttributeBased';

# Get the utils
use POE::Devel::Benchmarker::Utils qw ( knownloops );

# analyzes the installed perl directory for available loops
sub getPOEloops {
my $quiet_mode = shift;
Expand All @@ -43,7 +46,7 @@ sub _start : State {
# XS::EPoll ( must be POE > 1.003 and weird way of loading )
# XS::Poll ( must be POE > 1.003 and weird way of loading )
if ( ! defined $_[HEAP]->{'loops'} ) {
$_[HEAP]->{'loops'} = [ qw( Event_Lib EV Glib Prima Gtk Wx Kqueue Tk Select IO_Poll ) ];
$_[HEAP]->{'loops'} = knownloops();
}

# First of all, we need to find out what loop libraries are installed
Expand Down
11 changes: 10 additions & 1 deletion lib/POE/Devel/Benchmarker/Utils.pm
Expand Up @@ -10,7 +10,7 @@ $VERSION = '0.02';
require Exporter;
use vars qw( @ISA @EXPORT_OK );
@ISA = qw(Exporter);
@EXPORT_OK = qw( poeloop2load loop2realversion beautify_times );
@EXPORT_OK = qw( poeloop2load loop2realversion beautify_times knownloops );

# returns the proper "load" stuff for a specific loop
sub poeloop2load {
Expand Down Expand Up @@ -115,6 +115,11 @@ sub beautify_times {
return $data;
}

# returns a list of "known" POE loops
sub knownloops {
return [ qw( Event_Lib EV Glib Prima Gtk Wx Kqueue Tk Select IO_Poll ) ];
}

1;
__END__
=head1 NAME
Expand All @@ -135,6 +140,10 @@ This package exports those subs via @EXPORT_OK:
=over 4
=item knownloops()
Returns an arrayref of the "known" POE loops as of this version of the Benchmarker
=item poeloop2load()
Returns the "parent" class to load for a specific loop. An example is:
Expand Down
75 changes: 75 additions & 0 deletions scripts/tapout_script
@@ -0,0 +1,75 @@
#!/usr/bin/perl
use strict;
use warnings;
use IO::Poll;
use POE qw( Component::Client::Keepalive Component::Client::HTTP );
use HTTP::Request;

my $url = "http://localhost/";

POE::Session->create (
inline_states => {
_start => \&start,
process => \&process,
response => \&response,
halt => \&halt,
},
);


POE::Kernel->run();

sub start {
my ($kernel,$heap) = @_[KERNEL,HEAP];
print "Starting\n";

$kernel->alias_set('master');

foreach (1..512) {

my $useragent = "ua_$_";

POE::Component::Client::HTTP->spawn (
Alias => $useragent,
Timeout => 30,
Agent => "Test",
);
$kernel->yield('process',$useragent);
}
$kernel->delay(halt=>30);
}

sub process {
my ($kernel,$heap,$useragent) = @_[KERNEL,HEAP,ARG0];

my $uri = HTTP::Request->new(GET => $url);

$kernel->post($useragent,'request','response',$uri,$useragent);
return;
}

sub response {
my ($kernel,$heap,$request_packet,$response_packet) = @_[KERNEL,HEAP,ARG0,ARG1];

my $request = $request_packet->[0];
my $response = $response_packet->[0];
my $useragent = $request_packet->[1]; ## this is passed with the request call
if ($response->is_success()) {
$heap->{responses}++;
} else {
$heap->{unsuccessful}++;
}
$kernel->yield('process', $useragent);
return;
}

sub halt {
my ($kernel,$heap) = @_[KERNEL,HEAP];

print "debug success($heap->{responses}) unsuccessful($heap->{unsuccessful}) ... " . $kernel->poe_kernel_loop() . "\n";
exit;

return;
}

1;

0 comments on commit 0fb6e7f

Please sign in to comment.