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

(-)a/misc/tests/_dbix_test_search_performance_all_sysprefs.pl (-1 / +56 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
use Modern::Perl;
4
use Koha::Config::SysPrefs;
5
6
my $results;
7
8
for (1..1000) {
9
    $results = sysprefs_from_mysql(); ## 1.82 msec
10
    ## $results = sysprefs_dbix_hashref_inflator(); ## 12.5 msec
11
    ## $results = sysprefs_dbix_unblessed(); ## 17.6 msec
12
    
13
    ## Note: numbers above are results for current master (08/07/2016)
14
    ## on Wheezy (DBIx::Class version 0.08196), i7-3770 CPU @ 3.40GHz.
15
    ##
16
    ## For 3.22.x on Jessie (DBIx 0.082810, i7-930 CPU @ 2.80GHz)
17
    ## there is a huge difference:
18
    ##
19
    ##     $results = sysprefs_from_mysql(); ## 2.52 msec
20
    ##     $results = sysprefs_dbix_hashref_inflator(); ## 3.51 msec
21
    ##     $results = sysprefs_dbix_unblessed(); ## 7.9 msec
22
    ##
23
    ## DBIx search with DBIx::Class::ResultClass::HashRefInflator
24
    ## attribute is (almost) as fast as plain DBI search.
25
}
26
27
print "Got ".scalar(@$results)." sysprefs\n";
28
29
sub sysprefs_dbix_unblessed {
30
    my $all_prefs = Koha::Config::SysPrefs->search(
31
        undef,
32
        { columns => [qw/value variable/] }
33
    )->unblessed();
34
35
    $all_prefs;
36
}
37
38
sub sysprefs_dbix_hashref_inflator {
39
    my $all_prefs = Koha::Config::SysPrefs->search_all_unblessed(
40
        undef,
41
        { columns => [qw/value variable/] }
42
    );
43
44
    $all_prefs;
45
}
46
47
sub sysprefs_from_mysql {
48
    my $dbh = C4::Context->dbh();
49
    my $sql = 'SELECT variable, value FROM systempreferences';
50
        
51
    my $sth = $dbh->prepare($sql);
52
    $sth->execute;
53
    my $result = $sth->fetchall_arrayref({});
54
55
    $result;
56
}

Return to bug 16076