@@ -, +, @@ --- .../_dbix_test_search_performance_all_sysprefs.pl | 56 ++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100755 misc/tests/_dbix_test_search_performance_all_sysprefs.pl --- a/misc/tests/_dbix_test_search_performance_all_sysprefs.pl +++ a/misc/tests/_dbix_test_search_performance_all_sysprefs.pl @@ -0,0 +1,56 @@ +#!/usr/bin/perl + +use Modern::Perl; +use Koha::Config::SysPrefs; + +my $results; + +for (1..1000) { + $results = sysprefs_from_mysql(); ## 1.82 msec + ## $results = sysprefs_dbix_hashref_inflator(); ## 12.5 msec + ## $results = sysprefs_dbix_unblessed(); ## 17.6 msec + + ## Note: numbers above are results for current master (08/07/2016) + ## on Wheezy (DBIx::Class version 0.08196), i7-3770 CPU @ 3.40GHz. + ## + ## For 3.22.x on Jessie (DBIx 0.082810, i7-930 CPU @ 2.80GHz) + ## there is a huge difference: + ## + ## $results = sysprefs_from_mysql(); ## 2.52 msec + ## $results = sysprefs_dbix_hashref_inflator(); ## 3.51 msec + ## $results = sysprefs_dbix_unblessed(); ## 7.9 msec + ## + ## DBIx search with DBIx::Class::ResultClass::HashRefInflator + ## attribute is (almost) as fast as plain DBI search. +} + +print "Got ".scalar(@$results)." sysprefs\n"; + +sub sysprefs_dbix_unblessed { + my $all_prefs = Koha::Config::SysPrefs->search( + undef, + { columns => [qw/value variable/] } + )->unblessed(); + + $all_prefs; +} + +sub sysprefs_dbix_hashref_inflator { + my $all_prefs = Koha::Config::SysPrefs->search_all_unblessed( + undef, + { columns => [qw/value variable/] } + ); + + $all_prefs; +} + +sub sysprefs_from_mysql { + my $dbh = C4::Context->dbh(); + my $sql = 'SELECT variable, value FROM systempreferences'; + + my $sth = $dbh->prepare($sql); + $sth->execute; + my $result = $sth->fetchall_arrayref({}); + + $result; +} --