[Koha-cvs] koha/misc benchmark.pl [rel_3_0]

paul poulain paul at koha-fr.org
Mon Dec 18 19:00:47 CET 2006


CVSROOT:	/sources/koha
Module name:	koha
Branch:		rel_3_0
Changes by:	paul poulain <tipaul>	06/12/18 18:00:47

Added files:
	misc           : benchmark.pl 

Log message:
	NEW SCRIPT : benchmarking tool.
	
	Set insecure=1 and run this script. You'll get : 
	200 calls to each (mainpage, biblio MARC detail, member detail,issues, returns), then 200 calls to all of them at once.
	
	While running, the results are printed. here are mine (P4 2.6Ghz, 10kRPM SCSI disk, 1GB RAM, benchmark & Koha on the same computer)
	
	mainpage (no mySQL)     38335ms 5.21716447110995 pages/sec
	biblio (MARC detail)    70243ms 2.84725880158877 biblios/sec
	borrower detail         53378ms 3.74686200307243 borrowers/sec
	Issues detail           65759ms 3.04140878054715 issues/sec
	Returns detail          209324ms        0.955456612715217 returns/sec
	Benchmarking everything 212767ms        4.69997697011285 operations/sec
	
	The return speed is slow : zebraop is NOT commented, the returns update zebra. I'll retry the benchmark with zebraop commented.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/misc/benchmark.pl?cvsroot=koha&only_with_tag=rel_3_0&rev=1.1.2.1

Patches:
Index: benchmark.pl
===================================================================
RCS file: benchmark.pl
diff -N benchmark.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ benchmark.pl	18 Dec 2006 18:00:47 -0000	1.1.2.1
@@ -0,0 +1,164 @@
+#!/usr/bin/perl
+
+use HTTPD::Bench::ApacheBench;
+use C4::Context;
+use strict;
+
+# 1st, find some maximal values
+my $dbh=C4::Context->dbh();
+my $sth = $dbh->prepare("select max(borrowernumber) from borrowers");
+$sth->execute;
+my ($borrowernumber_max) = $sth->fetchrow;
+
+$sth = $dbh->prepare("select max(biblionumber) from biblio");
+$sth->execute;
+my ($biblionumber_max) = $sth->fetchrow;
+
+$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 $max_tries = 200;
+my $concurrency = 5;
+
+$|=1;
+#
+# the global benchmark we do at the end...
+#
+my $b = HTTPD::Bench::ApacheBench->new;
+$b->concurrency( $concurrency );
+#
+# mainpage : (very) low mySQL dependancy
+#
+my $b0 = HTTPD::Bench::ApacheBench->new;
+$b0->concurrency( $concurrency );
+
+my @mainpage;
+print "--------------\n";
+print "Koha benchmark\n";
+print "--------------\n";
+print "benchmarking with $max_tries occurences of each operation\n";
+print "mainpage (no mySQL) ";
+for (my $i=1;$i<=$max_tries;$i++) {
+    push @mainpage,"$baseurl/mainpage.pl";
+}
+my $run0 = HTTPD::Bench::ApacheBench::Run->new
+    ({ urls => \@mainpage,
+    });
+$b0->add_run($run0);
+$b->add_run($run0);
+
+# send HTTP request sequences to server and time responses
+my $ro = $b0->execute;
+# calculate hits/sec
+print ("\t".$b0->total_time."ms\t".(1000*$b0->total_requests/$b0->total_time)." pages/sec\n");
+print "ALERT : ".$b0->total_responses_failed." failures\n" if $b0->total_responses_failed;
+
+#
+# biblios
+#
+my $b1 = HTTPD::Bench::ApacheBench->new;
+$b1->concurrency( $concurrency );
+
+my @biblios;
+print "biblio (MARC detail)";
+for (my $i=1;$i<=$max_tries;$i++) {
+    my $rand_biblionumber = int(rand($biblionumber_max)+1);
+    push @biblios,"$baseurl/catalogue/MARCdetail.pl?biblionumber=$rand_biblionumber";
+}
+my $run1 = HTTPD::Bench::ApacheBench::Run->new
+    ({ urls => \@biblios,
+    });
+$b1->add_run($run1);
+$b->add_run($run1);
+
+# send HTTP request sequences to server and time responses
+my $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;
+
+#
+# borrowers
+#
+my $b2 = HTTPD::Bench::ApacheBench->new;
+$b2->concurrency( $concurrency );
+
+my @borrowers;
+print "borrower detail        ";
+for (my $i=1;$i<=$max_tries;$i++) {
+    my $rand_borrowernumber = int(rand($borrowernumber_max)+1);
+#     print "$baseurl/members/moremember.pl?borrowernumber=$rand_borrowernumber\n";
+    push @borrowers,"$baseurl/members/moremember.pl?borrowernumber=$rand_borrowernumber";
+}
+my $run2 = HTTPD::Bench::ApacheBench::Run->new
+    ({ urls => \@borrowers,
+    });
+$b2->add_run($run2);
+$b->add_run($run2);
+
+# send HTTP request sequences to server and time responses
+my $ro = $b2->execute;
+# calculate hits/sec
+print ("\t".$b2->total_time."ms\t".(1000*$b2->total_requests/$b2->total_time)." borrowers/sec\n");
+
+
+#
+# issue (& then return) books
+#
+my $b3 = HTTPD::Bench::ApacheBench->new;
+$b3->concurrency( $concurrency );
+my $b4 = HTTPD::Bench::ApacheBench->new;
+$b4->concurrency( $concurrency );
+
+my @issues;
+my @returns;
+print "Issues detail          ";
+my $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;
+    # check that the borrowernumber exist
+    until ($rand_borrowernumber) {
+        $rand_borrowernumber = int(rand($borrowernumber_max)+1);
+        $sth2->execute($rand_borrowernumber);
+        ($rand_borrowernumber) = $sth2->fetchrow;
+    }
+    # find a barcode & check it exists
+    my $rand_barcode;
+    until ($rand_barcode) {
+        my $rand_itemnumber = int(rand($itemnumber_max)+1);
+        $sth->execute($rand_itemnumber);
+        ($rand_barcode) = $sth->fetchrow();
+#         print "$baseurl/circ/circulation.pl?borrowernumber=$rand_borrowernumber&barcode=$rand_barcode&issueconfirmed=1&year=2010&month=01&day=01\n";
+    }
+    push @issues,"$baseurl/circ/circulation.pl?borrowernumber=$rand_borrowernumber&barcode=$rand_barcode&issueconfirmed=1";
+    push @returns,"$baseurl/circ/returns.pl?barcode=$rand_barcode";
+}
+my $run3 = HTTPD::Bench::ApacheBench::Run->new
+    ({ urls => \@issues,
+    });
+$b3->add_run($run3);
+$b->add_run($run3);
+
+# send HTTP request sequences to server and time responses
+my $ro = $b3->execute;
+# calculate hits/sec
+print ("\t".$b3->total_time."ms\t".(1000*$b3->total_requests/$b3->total_time)." issues/sec\n");
+
+print "Returns detail         ";
+my $run4 = HTTPD::Bench::ApacheBench::Run->new
+    ({ urls => \@returns,
+    });
+$b4->add_run($run4);
+$b->add_run($run4);
+
+# send HTTP request sequences to server and time responses
+my $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;
+print ("\t".$b->total_time."ms\t".(1000*$b->total_requests/$b->total_time)." operations/sec\n");





More information about the Koha-cvs mailing list