From a990bc4de293141e3a955e5a0e8efce41b69147c Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Tue, 20 Apr 2021 09:11:53 +0200 Subject: [PATCH] Bug 28172: [DO NOT PUSH] Test script for GetPlugins --- test_getplugins.pl | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 test_getplugins.pl diff --git a/test_getplugins.pl b/test_getplugins.pl new file mode 100755 index 0000000000..ecb65c8483 --- /dev/null +++ b/test_getplugins.pl @@ -0,0 +1,41 @@ +#!/usr/bin/perl + +use Modern::Perl; + +use Koha::Plugins; +use Time::HiRes qw(gettimeofday tv_interval); +use Data::Dumper; + +my $plugins = Koha::Plugins->new; + +sub test { + my ($description, $sub) = @_; + my $t0 = [gettimeofday]; + $sub->(); + my $elapsed = tv_interval($t0); + say sprintf('%s: %.3fs', $description, $elapsed); +} + +test('First 2 calls to GetPlugins', sub { + my @all_plugins = $plugins->GetPlugins({ all => 1 }); + my @enabled_plugins = $plugins->GetPlugins(); + say sprintf('%d plugins detected, %d enabled', scalar @all_plugins, scalar @enabled_plugins); +}); + +test('1000 calls to GetPlugins', sub { + for (1..1000) { + my @plugins = $plugins->GetPlugins({ method => 'get_metadata' }); + } +}); + +test('1000 calls to GetPlugins with method = "unknown_method"', sub { + for (1..1000) { + my @plugins = $plugins->GetPlugins({ method => 'unknown_method' }); + } +}); + +test('1000 calls to GetPlugins with all = 1', sub { + for (1..1000) { + my @plugins = $plugins->GetPlugins({ all => 1 }); + } +}); -- 2.30.2