#!/usr/bin/perl # Copyright 2013 BibLibre # # This is free software; you can redistribute it and/or modify it under the # terms of the GNU General Public License as published by the Free Software # Foundation; either version 2 of the License, or (at your option) any later # version. # # This is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR # A PARTICULAR PURPOSE. See the GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along with # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, # Suite 330, Boston, MA 02111-1307 USA # use Modern::Perl; use utf8; use WWW::Mechanize; use Data::Dumper; use XML::Simple; use Time::Progress; use Getopt::Long; my ( $max, $help ); GetOptions( "max:s" => \$max, ); $max //= 10; my $koha_conf = $ENV{KOHA_CONF}; my $xml = XMLin($koha_conf); use C4::Context; my $user = $ENV{KOHA_USER} || $xml->{config}->{user}; my $password = $ENV{KOHA_PASS} || $xml->{config}->{pass}; my $intranet = $ENV{KOHA_INTRANET_URL}; BAIL_OUT("You must set the environment variable KOHA_INTRANET_URL to ". "point this test to your staff client. If you do not have ". "KOHA_CONF set, you must also set KOHA_USER and KOHA_PASS for ". "your username and password") unless $intranet; $intranet =~ s#/$##; my $agent = WWW::Mechanize->new(); $agent->get( "$intranet/cgi-bin/koha/mainpage.pl" ); $agent->form_name('loginform'); $agent->field( 'password', $password ); $agent->field( 'userid', $user ); $agent->field( 'branch', '' ); $agent->click( '', 'login to staff client' ); $agent->get( "$intranet/cgi-bin/koha/mainpage.pl" ); my $cumul_time = 0; for my $i ( 1 .. 5 ) { print "$i "; $cumul_time += launch ( "$intranet/cgi-bin/koha/admin/preferences.pl", $max ); } print "\n"; say $cumul_time / 5; $cumul_time = 0; for my $i ( 1 .. 5 ) { print "$i "; $cumul_time += launch ( "$intranet/cgi-bin/koha/catalogue/search.pl?q=d", $max ); } print "\n"; say $cumul_time / 5 . " s"; sub launch { my ( $url, $max ) = @_; my $p = new Time::Progress; $p->restart; for my $cpt ( 1 .. $max ) { my $pid; next if $pid = fork; die "fork failed: $!" unless defined $pid; $agent->get( $url ); exit; } 1 while (wait() != -1); $p->stop; return $p->report("%l"); }