View | Details | Raw Unified | Return to bug 6015
Collapse All | Expand All

(-)a/misc/load_testing/benchmark_circulation.pl (-5 / +34 lines)
Lines 16-28 use LWP::UserAgent; Link Here
16
use Data::Dumper;
16
use Data::Dumper;
17
use HTTP::Cookies;
17
use HTTP::Cookies;
18
use C4::Context;
18
use C4::Context;
19
use C4::Debug;
19
20
20
my $baseurl= C4::Context->preference("staffClientBaseURL")."/cgi-bin/koha/";
21
my $baseurl= $ARGV[0] || "http://am123/cgi-bin/koha/";
21
my $max_tries = 200;
22
my $max_tries = 200;
22
my $concurrency = 10;
23
my $concurrency = 30;
23
my $debug;
24
my $user = $ARGV[1] ||'hdl';
24
my $user = 'kados';
25
my $password = $ARGV[2] || 'hdl';
25
my $password = 'kados';
26
26
27
# Authenticate via our handy dandy RESTful services
27
# Authenticate via our handy dandy RESTful services
28
# and grab a cookie
28
# and grab a cookie
Lines 37-42 if( $resp->is_success ) { Link Here
37
    print "Authentication successful\n";
37
    print "Authentication successful\n";
38
    print "Auth:\n $resp->content" if $debug;
38
    print "Auth:\n $resp->content" if $debug;
39
}
39
}
40
40
# remove some unnecessary garbage from the cookie
41
# remove some unnecessary garbage from the cookie
41
$cookie =~ s/ path_spec; discard; version=0//;
42
$cookie =~ s/ path_spec; discard; version=0//;
42
$cookie =~ s/Set-Cookie3: //;
43
$cookie =~ s/Set-Cookie3: //;
Lines 138-144 $ro = $b2->execute; Link Here
138
# calculate hits/sec
139
# calculate hits/sec
139
print ("\t".$b2->total_time."ms\t".(1000*$b2->total_requests/$b2->total_time)." borrowers/sec\n");
140
print ("\t".$b2->total_time."ms\t".(1000*$b2->total_requests/$b2->total_time)." borrowers/sec\n");
140
141
142
my $b2 = HTTPD::Bench::ApacheBench->new;
143
$b2->concurrency( $concurrency );
144
print "Load testing patron search page";
145
for (my $i=1;$i<=$max_tries;$i++) {
146
#     print "$baseurl/members/moremember.pl?borrowernumber=$rand_borrowernumber\n";
147
    push @borrowers,"$baseurl/members/member.pl?member=jean";
148
}
149
$b2->add_run($run2);
150
$b->add_run($run2);
151
152
# send HTTP request sequences to server and time responses
153
$ro = $b2->execute;
154
155
print ("\t".$b2->total_time."ms\t".(1000*$b2->total_requests/$b2->total_time)." borrowers/sec\n");
141
156
157
my $b2 = HTTPD::Bench::ApacheBench->new;
158
$b2->concurrency( $concurrency );
159
160
print "Load testing patron search page";
161
for (my $i=1;$i<=$max_tries;$i++) {
162
#     print "$baseurl/members/moremember.pl?borrowernumber=$rand_borrowernumber\n";
163
    push @borrowers,"$baseurl/members/member.pl?quicksearch=1&surname=A";
164
}
165
$b2->add_run($run2);
166
$b->add_run($run2);
167
168
# send HTTP request sequences to server and time responses
169
$ro = $b2->execute;
170
print ("\t".$b2->total_time."ms\t".(1000*$b2->total_requests/$b2->total_time)." borrowers/sec\n");
142
#
171
#
143
# issue (& then return) books
172
# issue (& then return) books
144
#
173
#
(-)a/misc/load_testing/benchmark_opac.pl (-1 / +128 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
# This script implements a basic benchmarking and regression testing
3
# utility for Koha
4
5
use strict;
6
use warnings;
7
BEGIN {
8
    # find Koha's Perl modules
9
    # test carefully before changing this
10
    use FindBin;
11
    eval { require "$FindBin::Bin/kohalib.pl" };
12
}
13
14
use HTTPD::Bench::ApacheBench;
15
use LWP::UserAgent;
16
use Data::Dumper;
17
use HTTP::Cookies;
18
use C4::Context;
19
use C4::Debug;
20
21
my $baseurl= $ARGV[0] || "http://am123/cgi-bin/koha/";
22
my $max_tries = 200;
23
my $concurrency = 30;
24
my $user = $ARGV[1] ||'hdl';
25
my $password = $ARGV[2] || 'hdl';
26
27
# Authenticate via our handy dandy RESTful services
28
# and grab a cookie
29
my $ua = LWP::UserAgent->new();
30
# Get some data to work with
31
my $dbh=C4::Context->dbh();
32
my $sth = $dbh->prepare("select max(borrowernumber) from borrowers");
33
$sth->execute;
34
my ($borrowernumber_max) = $sth->fetchrow;
35
36
$sth = $dbh->prepare("select max(biblionumber) from biblio");
37
$sth->execute;
38
my ($biblionumber_max) = $sth->fetchrow;
39
40
$sth = $dbh->prepare("select max(itemnumber) from items");
41
$sth->execute;
42
my ($itemnumber_max) = $sth->fetchrow;
43
44
$|=1;
45
#
46
# the global benchmark we do at the end...
47
#
48
my $b = HTTPD::Bench::ApacheBench->new;
49
$b->concurrency( $concurrency );
50
#
51
# mainpage : (very) low RDBMS dependency
52
#
53
my $b0 = HTTPD::Bench::ApacheBench->new;
54
$b0->concurrency( $concurrency );
55
56
my @mainpage;
57
print "--------------\n";
58
print "Koha circulation benchmarking utility\n";
59
print "--------------\n";
60
print "Benchmarking with $max_tries occurences of each operation and $concurrency concurrent sessions \n";
61
print "Load testing opac client main page";
62
for (my $i=1;$i<=$max_tries;$i++) {
63
    push @mainpage,"$baseurl/opac-main.pl";
64
}
65
my $run0 = HTTPD::Bench::ApacheBench::Run->new
66
    ({ urls => \@mainpage,
67
    });
68
$b0->add_run($run0);
69
$b->add_run($run0);
70
71
# send HTTP request sequences to server and time responses
72
my $ro = $b0->execute;
73
# calculate hits/sec
74
print ("\t".$b0->total_time."ms\t".(1000*$b0->total_requests/$b0->total_time)." pages/sec\n");
75
print "ALERT : ".$b0->total_responses_failed." failures\n" if $b0->total_responses_failed;
76
77
#
78
# biblios
79
#
80
my $b1 = HTTPD::Bench::ApacheBench->new;
81
$b1->concurrency( $concurrency );
82
83
my @biblios;
84
print "Load testing catalog detail page";
85
for (my $i=1;$i<=$max_tries;$i++) {
86
    my $rand_biblionumber = int(rand($biblionumber_max)+1);
87
    push @biblios,"$baseurl/opac-detail.pl?biblionumber=$rand_biblionumber";
88
}
89
my $run1 = HTTPD::Bench::ApacheBench::Run->new
90
    ({ urls => \@biblios,
91
    });
92
$b1->add_run($run1);
93
$b->add_run($run1);
94
95
# send HTTP request sequences to server and time responses
96
$ro = $b1->execute;
97
# calculate hits/sec
98
print ("\t".$b1->total_time."ms\t".(1000*$b1->total_requests/$b1->total_time)." biblios/sec\n");
99
print "ALERT : ".$b1->total_responses_failed." failures\n" if $b1->total_responses_failed;
100
101
#
102
# borrowers
103
#
104
my $b2 = HTTPD::Bench::ApacheBench->new;
105
$b2->concurrency( $concurrency );
106
107
my @borrowers;
108
print "Load testing search page";
109
for (my $i=1;$i<=$max_tries;$i++) {
110
#     print "$baseurl/members/moremember.pl?borrowernumber=$rand_borrowernumber\n";
111
    push @borrowers,"$baseurl/opac-search.pl?idx=ti&q=Code";
112
    push @borrowers,"$baseurl/opac-search.pl?idx=au&q=Jean";
113
    push @borrowers,"$baseurl/opac-search.pl?idx=su&q=Droit";
114
}
115
my $run2 = HTTPD::Bench::ApacheBench::Run->new
116
    ({ urls => \@borrowers,
117
    });
118
$b2->add_run($run2);
119
$b->add_run($run2);
120
121
# send HTTP request sequences to server and time responses
122
$ro = $b2->execute;
123
# calculate hits/sec
124
print ("\t".$b2->total_time."ms\t".(1000*$b2->total_requests/$b2->total_time)." searches/sec\n");
125
126
print "Load testing all transactions at once";
127
$ro = $b->execute;
128
print ("\t".$b->total_time."ms\t".(1000*$b->total_requests/$b->total_time)." operations/sec\n");

Return to bug 6015