Line 0
Link Here
|
0 |
- |
1 |
#!/usr/bin/perl |
|
|
2 |
|
3 |
use Modern::Perl; |
4 |
|
5 |
use Koha::Plugins; |
6 |
use Time::HiRes qw(gettimeofday tv_interval); |
7 |
use Data::Dumper; |
8 |
|
9 |
my $plugins = Koha::Plugins->new; |
10 |
|
11 |
sub test { |
12 |
my ($description, $sub) = @_; |
13 |
my $t0 = [gettimeofday]; |
14 |
$sub->(); |
15 |
my $elapsed = tv_interval($t0); |
16 |
say sprintf('%s: %.3fs', $description, $elapsed); |
17 |
} |
18 |
|
19 |
test('First 2 calls to GetPlugins', sub { |
20 |
my @all_plugins = $plugins->GetPlugins({ all => 1 }); |
21 |
my @enabled_plugins = $plugins->GetPlugins(); |
22 |
say sprintf('%d plugins detected, %d enabled', scalar @all_plugins, scalar @enabled_plugins); |
23 |
}); |
24 |
|
25 |
test('1000 calls to GetPlugins', sub { |
26 |
for (1..1000) { |
27 |
my @plugins = $plugins->GetPlugins({ method => 'get_metadata' }); |
28 |
} |
29 |
}); |
30 |
|
31 |
test('1000 calls to GetPlugins with method = "unknown_method"', sub { |
32 |
for (1..1000) { |
33 |
my @plugins = $plugins->GetPlugins({ method => 'unknown_method' }); |
34 |
} |
35 |
}); |
36 |
|
37 |
test('1000 calls to GetPlugins with all = 1', sub { |
38 |
for (1..1000) { |
39 |
my @plugins = $plugins->GetPlugins({ all => 1 }); |
40 |
} |
41 |
}); |