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

(-)a/t/db_dependent/Koha/IssuingRules.t (-2 / +52 lines)
Lines 21-26 use Modern::Perl; Link Here
21
21
22
use Test::More tests => 1;
22
use Test::More tests => 1;
23
23
24
use Benchmark;
25
24
use Koha::IssuingRules;
26
use Koha::IssuingRules;
25
27
26
use t::lib::TestBuilder;
28
use t::lib::TestBuilder;
Lines 31-37 $schema->storage->txn_begin; Link Here
31
my $builder      = t::lib::TestBuilder->new;
33
my $builder      = t::lib::TestBuilder->new;
32
34
33
subtest 'get_effective_issuing_rule' => sub {
35
subtest 'get_effective_issuing_rule' => sub {
34
    plan tests => 1;
36
    plan tests => 2;
35
37
36
    my $patron       = $builder->build({ source => 'Borrower' });
38
    my $patron       = $builder->build({ source => 'Borrower' });
37
    my $item     = $builder->build({ source => 'Item' });
39
    my $item     = $builder->build({ source => 'Item' });
Lines 158-163 subtest 'get_effective_issuing_rule' => sub { Link Here
158
        ok(_row_match($rule, $branchcode, $categorycode, $itemtype), 'When I attempt to get effective issuing rule,'
160
        ok(_row_match($rule, $branchcode, $categorycode, $itemtype), 'When I attempt to get effective issuing rule,'
159
           .' then the above one is returned.');
161
           .' then the above one is returned.');
160
    };
162
    };
163
164
    subtest 'Performance' => sub {
165
        plan tests => 4;
166
167
        my $worst_case = timethis(500,
168
                    sub { Koha::IssuingRules->get_effective_issuing_rule({
169
                            branchcode   => 'nonexistent',
170
                            categorycode => 'nonexistent',
171
                            itemtype     => 'nonexistent',
172
                        });
173
                    }
174
                );
175
        my $mid_case = timethis(500,
176
                    sub { Koha::IssuingRules->get_effective_issuing_rule({
177
                            branchcode   => $branchcode,
178
                            categorycode => 'nonexistent',
179
                            itemtype     => 'nonexistent',
180
                        });
181
                    }
182
                );
183
        my $sec_best_case = timethis(500,
184
                    sub { Koha::IssuingRules->get_effective_issuing_rule({
185
                            branchcode   => $branchcode,
186
                            categorycode => $categorycode,
187
                            itemtype     => 'nonexistent',
188
                        });
189
                    }
190
                );
191
        my $best_case = timethis(500,
192
                    sub { Koha::IssuingRules->get_effective_issuing_rule({
193
                            branchcode   => $branchcode,
194
                            categorycode => $categorycode,
195
                            itemtype     => $itemtype,
196
                        });
197
                    }
198
                );
199
        ok($worst_case, 'In worst case, get_effective_issuing_rule finds matching'
200
           .' rule '.sprintf('%.2f', $worst_case->iters/$worst_case->cpu_a)
201
           .' times per second.');
202
        ok($mid_case, 'In mid case, get_effective_issuing_rule finds matching'
203
           .' rule '.sprintf('%.2f', $mid_case->iters/$mid_case->cpu_a)
204
           .' times per second.');
205
        ok($sec_best_case, 'In second best case, get_effective_issuing_rule finds matching'
206
           .' rule '.sprintf('%.2f', $sec_best_case->iters/$sec_best_case->cpu_a)
207
           .' times per second.');
208
        ok($best_case, 'In best case, get_effective_issuing_rule finds matching'
209
           .' rule '.sprintf('%.2f', $best_case->iters/$best_case->cpu_a)
210
           .' times per second.');
211
    };
161
};
212
};
162
213
163
sub _row_match {
214
sub _row_match {
164
- 

Return to bug 17783