Bugzilla – Attachment 58310 Details for
Bug 17783
Optimize Koha::IssuingRules->get_effective_issuing_rule
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17783: Test to print performance of get_effective_issuing_rule
Bug-17783-Test-to-print-performance-of-geteffectiv.patch (text/plain), 4.14 KB, created by
Jonathan Druart
on 2016-12-20 17:08:09 UTC
(
hide
)
Description:
Bug 17783: Test to print performance of get_effective_issuing_rule
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2016-12-20 17:08:09 UTC
Size:
4.14 KB
patch
obsolete
>From 64e731e466f12c3e79b201b5721b37ceec999d15 Mon Sep 17 00:00:00 2001 >From: Lari Taskula <lari.taskula@jns.fi> >Date: Thu, 15 Dec 2016 18:35:13 +0200 >Subject: [PATCH] Bug 17783: Test to print performance of > get_effective_issuing_rule > >This test prints the amount of issuing rule matches per second for >1. worst case, when non-existent branchcode, categorycode and itemtype is > being searched (currently 8 queries) >2. mid case (rule found on 4th query) >3. 2nd best case (rule found on 2nd query) >4. best case, when an issuing rule is defined for exactly those branchcode, > categorycode and itemtype (currently 1 query) > >To test: >1. Run t/db_dependent/Koha/IssuingRules.t >2. Write down the per-second amount to compare with next patch > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> > >Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com> >--- > t/db_dependent/Koha/IssuingRules.t | 53 +++++++++++++++++++++++++++++++++++++- > 1 file changed, 52 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/IssuingRules.t b/t/db_dependent/Koha/IssuingRules.t >index 1d48fff..158e3cf 100644 >--- a/t/db_dependent/Koha/IssuingRules.t >+++ b/t/db_dependent/Koha/IssuingRules.t >@@ -21,6 +21,8 @@ use Modern::Perl; > > use Test::More tests => 1; > >+use Benchmark; >+ > use Koha::IssuingRules; > > use t::lib::TestBuilder; >@@ -31,7 +33,7 @@ $schema->storage->txn_begin; > my $builder = t::lib::TestBuilder->new; > > subtest 'get_effective_issuing_rule' => sub { >- plan tests => 1; >+ plan tests => 2; > > my $patron = $builder->build({ source => 'Borrower' }); > my $item = $builder->build({ source => 'Item' }); >@@ -158,6 +160,55 @@ subtest 'get_effective_issuing_rule' => sub { > ok(_row_match($rule, $branchcode, $categorycode, $itemtype), 'When I attempt to get effective issuing rule,' > .' then the above one is returned.'); > }; >+ >+ subtest 'Performance' => sub { >+ plan tests => 4; >+ >+ my $worst_case = timethis(500, >+ sub { Koha::IssuingRules->get_effective_issuing_rule({ >+ branchcode => 'nonexistent', >+ categorycode => 'nonexistent', >+ itemtype => 'nonexistent', >+ }); >+ } >+ ); >+ my $mid_case = timethis(500, >+ sub { Koha::IssuingRules->get_effective_issuing_rule({ >+ branchcode => $branchcode, >+ categorycode => 'nonexistent', >+ itemtype => 'nonexistent', >+ }); >+ } >+ ); >+ my $sec_best_case = timethis(500, >+ sub { Koha::IssuingRules->get_effective_issuing_rule({ >+ branchcode => $branchcode, >+ categorycode => $categorycode, >+ itemtype => 'nonexistent', >+ }); >+ } >+ ); >+ my $best_case = timethis(500, >+ sub { Koha::IssuingRules->get_effective_issuing_rule({ >+ branchcode => $branchcode, >+ categorycode => $categorycode, >+ itemtype => $itemtype, >+ }); >+ } >+ ); >+ ok($worst_case, 'In worst case, get_effective_issuing_rule finds matching' >+ .' rule '.sprintf('%.2f', $worst_case->iters/$worst_case->cpu_a) >+ .' times per second.'); >+ ok($mid_case, 'In mid case, get_effective_issuing_rule finds matching' >+ .' rule '.sprintf('%.2f', $mid_case->iters/$mid_case->cpu_a) >+ .' times per second.'); >+ ok($sec_best_case, 'In second best case, get_effective_issuing_rule finds matching' >+ .' rule '.sprintf('%.2f', $sec_best_case->iters/$sec_best_case->cpu_a) >+ .' times per second.'); >+ ok($best_case, 'In best case, get_effective_issuing_rule finds matching' >+ .' rule '.sprintf('%.2f', $best_case->iters/$best_case->cpu_a) >+ .' times per second.'); >+ }; > }; > > sub _row_match { >-- >2.9.3
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 17783
:
58228
|
58229
|
58230
|
58231
|
58268
|
58269
|
58270
|
58271
|
58300
|
58304
|
58309
| 58310 |
58311
|
58312
|
58313
|
58314