zebraqueue daemon - implement exiting if >100 postponed index updates
[koha-ffzg.git] / misc / benchmark.pl
index 5d76084..6ba2c38 100755 (executable)
@@ -1,5 +1,7 @@
 #!/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
@@ -10,7 +12,7 @@ BEGIN {
 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;
@@ -24,7 +26,7 @@ $sth = $dbh->prepare("select max(itemnumber) from items");
 $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;
 
@@ -35,7 +37,7 @@ $|=1;
 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 );
@@ -45,7 +47,7 @@ print "--------------\n";
 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";
 }
@@ -80,7 +82,7 @@ $b1->add_run($run1);
 $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;
@@ -105,7 +107,7 @@ $b2->add_run($run2);
 $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");
 
@@ -121,7 +123,7 @@ $b4->concurrency( $concurrency );
 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;
@@ -149,7 +151,7 @@ $b3->add_run($run3);
 $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");
 
@@ -161,10 +163,10 @@ $b4->add_run($run4);
 $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");