App-livehttperf
view release on metacpan or search on metacpan
lib/App/livehttperf.pm view on Meta::CPAN
my @recs;
my %stats;
my @concurrency;
my $total_delays = 0;
my $total_urls = 0;
my $test_started;
my $elapsed_time;
my %ua_opts;
# xlsx output
my ($xls, $xls_summary, $xls_urls, $bold);
my $xls_s_row = 0;
my $xls_u_row = 0;
my %OPTS = (
input => undef,
reuse_cookies => 0,
concurrency => [ 1 ],
concurrency_max => 0,
response_match_type => [],
concurrency_step => 5,
lib/App/livehttperf.pm view on Meta::CPAN
if ( my $xlsx_file = $OPTS{output} ) {
require Excel::Writer::XLSX;
$xls = Excel::Writer::XLSX->new( $xlsx_file );
$xls->set_optimization();
$xls->set_properties(
title => 'Performance tests',
comments => "Generated by App::livehttperf/$App::livehttperf::VERSION",
);
$bold = $xls->add_format();
$bold->set_bold();
$xls_summary = $xls->add_worksheet('Summary');
$xls_urls = $xls->add_worksheet('URLs');
}
}
sub parse_livehttp_log {
local $/ = "----------------------------------------------------------\r\n";
lib/App/livehttperf.pm view on Meta::CPAN
print " URLs tested: ", $total_urls, "\n";
print " Total delays (per run): ", ($total_delays ? elapsed($total_delays) : '0'), "\n";
print " Requests sent: ", $reqs_sent, "\n";
print " Test elapsed time: ", ($elapsed_time < 1 ? '< 1 sec' : elapsed($elapsed_time)), "\n";
print "\n";
if ( $xls ) {
my @columns = ('Test run at', 'URLs tested', 'Total delays (per run)', 'Requests sent', 'Test elapsed time');
$xls_summary->write_row($xls_s_row++, 0, xlsx_row(@columns), $bold);
$xls_summary->write_row($xls_s_row++, 0, xlsx_row(
$test_run_at,
$total_urls,
$total_delays,
$reqs_sent,
$elapsed_time
));
$xls_s_row++;
}
lib/App/livehttperf.pm view on Meta::CPAN
$t->add('Compare headers', join("\n", @{ $OPTS{response_match_type} }));
print "Configuration:\n";
print $t->render, "\n";
print "\n";
}
{
my @columns = ('Concurrency', 'Started', 'Total', 'Min', 'Max', 'Avg', 'StdDev', 'Median');
$xls_summary->write_row($xls_s_row++, 0, xlsx_row(@columns), $bold)
if $xls;
my $t = Text::TabularDisplay->new(@columns);
for my $c ( @concurrency ) {
my @row = get_concurrency_time_stats($c);
$t->add( @row );
$xls_summary->write_row($xls_s_row++, 0, xlsx_row(@row)) if $xls;
lib/App/livehttperf.pm view on Meta::CPAN
$xls_s_row++;
print "Times (in seconds):\n";
print $t->render, "\n";
print "\n";
}
{
my @columns = ('Concurrency', 'Successful', 'Failed', '1xx', '2xx', '3xx', '4xx', '5xx');
$xls_summary->write_row($xls_s_row++, 0, xlsx_row(@columns), $bold) if $xls;
my $t = Text::TabularDisplay->new(@columns);
for my $c ( @concurrency ) {
my @row = get_concurrency_res_stats($c);
$t->add( @row );
$xls_summary->write_row($xls_s_row++, 0, xlsx_row(@row)) if $xls;
lib/App/livehttperf.pm view on Meta::CPAN
$xls_s_row++;
print "Responses:\n";
print $t->render, "\n";
print "\n";
}
{
my @columns = ('Concurrency', 'Data sent', 'Data received');
$xls_summary->write_row($xls_s_row++, 0, xlsx_row(@columns), $bold) if $xls;
my $t = Text::TabularDisplay->new(@columns);
for my $c ( @concurrency ) {
my $counts = $stats{$c}->{counts};
$t->add(
$c,
( map { format_bytes( $counts->{$_} ) } qw( bytes_sent bytes_recv ) ),
lib/App/livehttperf.pm view on Meta::CPAN
$xls_s_row++;
print "Data transfers:\n";
print $t->render, "\n";
print "\n";
}
{
my @columns = ('Concurrency', 'URL', 'Min', 'Max', 'Avg', 'StdDev', 'Median', 'Errors');
$xls_urls->write_row($xls_u_row++, 0, xlsx_row(@columns), $bold) if $xls;
my $t = Text::TabularDisplay->new(@columns);
for (my $rec_no = 1; $rec_no <= @recs; $rec_no++) {
next unless ref $recs[$rec_no-1];
for my $concurrency ( @concurrency ) {
my $rec_stats = $stats{$concurrency}->{recs};
my $rec_errors = $stats{$concurrency}->{errors}->{recs};
my $url = $recs[$rec_no-1]->{req}->uri;
( run in 1.752 second using v1.01-cache-2.11-cpan-39bf76dae61 )