#!/usr/bin/perl
-
+# This is an example script for how to benchmark various
+# parts of your Koha system. It's useful for measuring the
+# impact of mod_perl on performance.
use strict;
BEGIN {
# find Koha's Perl modules
use HTTPD::Bench::ApacheBench;
use C4::Context;
-# 1st, find some maximal values
+# 1st, find some max values
my $dbh=C4::Context->dbh();
my $sth = $dbh->prepare("select max(borrowernumber) from borrowers");
$sth->execute;
$sth->execute;
my ($itemnumber_max) = $sth->fetchrow;
-my $baseurl= "http://i17.bureau.paulpoulain.com/cgi-bin/koha";
+my $baseurl= C4::Context->preference("staffClientBaseURL")."/cgi-bin/koha/";
my $max_tries = 200;
my $concurrency = 5;
my $b = HTTPD::Bench::ApacheBench->new;
$b->concurrency( $concurrency );
#
-# mainpage : (very) low mySQL dependancy
+# mainpage : (very) low RDBMS dependency
#
my $b0 = HTTPD::Bench::ApacheBench->new;
$b0->concurrency( $concurrency );
print "Koha benchmark\n";
print "--------------\n";
print "benchmarking with $max_tries occurences of each operation\n";
-print "mainpage (no mySQL) ";
+print "mainpage (low RDBMS dependency) ";
for (my $i=1;$i<=$max_tries;$i++) {
push @mainpage,"$baseurl/mainpage.pl";
}
$b->add_run($run1);
# send HTTP request sequences to server and time responses
-my $ro = $b1->execute;
+$ro = $b1->execute;
# calculate hits/sec
print ("\t".$b1->total_time."ms\t".(1000*$b1->total_requests/$b1->total_time)." biblios/sec\n");
print "ALERT : ".$b1->total_responses_failed." failures\n" if $b1->total_responses_failed;
$b->add_run($run2);
# send HTTP request sequences to server and time responses
-my $ro = $b2->execute;
+$ro = $b2->execute;
# calculate hits/sec
print ("\t".$b2->total_time."ms\t".(1000*$b2->total_requests/$b2->total_time)." borrowers/sec\n");
my @issues;
my @returns;
print "Issues detail ";
-my $sth = $dbh->prepare("SELECT barcode FROM items WHERE itemnumber=?");
+$sth = $dbh->prepare("SELECT barcode FROM items WHERE itemnumber=?");
my $sth2 = $dbh->prepare("SELECT borrowernumber FROM borrowers WHERE borrowernumber=?");
for (my $i=1;$i<=$max_tries;$i++) {
my $rand_borrowernumber;
$b->add_run($run3);
# send HTTP request sequences to server and time responses
-my $ro = $b3->execute;
+$ro = $b3->execute;
# calculate hits/sec
print ("\t".$b3->total_time."ms\t".(1000*$b3->total_requests/$b3->total_time)." issues/sec\n");
$b->add_run($run4);
# send HTTP request sequences to server and time responses
-my $ro = $b4->execute;
+$ro = $b4->execute;
# calculate hits/sec
print ("\t".$b4->total_time."ms\t".(1000*$b4->total_requests/$b4->total_time)." returns/sec\n");
print "Benchmarking everything";
-my $ro = $b->execute;
+$ro = $b->execute;
print ("\t".$b->total_time."ms\t".(1000*$b->total_requests/$b->total_time)." operations/sec\n");