← Index
NYTProf Performance Profile   « line view »
For starman worker -M FindBin --max-requests 50 --workers 2 --user=kohadev-koha --group kohadev-koha --pid /var/run/koha/kohadev/plack.pid --daemonize --access-log /var/log/koha/kohadev/plack.log --error-log /var/log/koha/kohadev/plack-error.log -E deployment --socket /var/run/koha/kohadev/plack.sock /etc/koha/sites/kohadev/plack.psgi
  Run on Fri Jan 8 14:31:06 2016
Reported on Fri Jan 8 14:33:30 2016

Filename/home/vagrant/kohaclone/Koha/Template/Plugin/Branches.pm
StatementsExecuted 4 statements in 58µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
822113µs187µsKoha::Template::Plugin::Branches::::GetLoggedInBranchcodeKoha::Template::Plugin::Branches::GetLoggedInBranchcode
11128µs117µsKoha::Template::Plugin::Branches::::BEGIN@21Koha::Template::Plugin::Branches::BEGIN@21
11119µs280µsKoha::Template::Plugin::Branches::::BEGIN@26Koha::Template::Plugin::Branches::BEGIN@26
11114µs17µsKoha::Template::Plugin::Branches::::BEGIN@27Koha::Template::Plugin::Branches::BEGIN@27
11113µs13µsKoha::Template::Plugin::Branches::::BEGIN@23Koha::Template::Plugin::Branches::BEGIN@23
11113µs66µsKoha::Template::Plugin::Branches::::BEGIN@24Koha::Template::Plugin::Branches::BEGIN@24
0000s0sKoha::Template::Plugin::Branches::::GetNameKoha::Template::Plugin::Branches::GetName
0000s0sKoha::Template::Plugin::Branches::::GetURLKoha::Template::Plugin::Branches::GetURL
0000s0sKoha::Template::Plugin::Branches::::allKoha::Template::Plugin::Branches::all
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Koha::Template::Plugin::Branches;
2
3# Copyright ByWater Solutions 2012
4# Copyright BibLibre 2014
5
6# This file is part of Koha.
7#
8# Koha is free software; you can redistribute it and/or modify it
9# under the terms of the GNU General Public License as published by
10# the Free Software Foundation; either version 3 of the License, or
11# (at your option) any later version.
12#
13# Koha is distributed in the hope that it will be useful, but
14# WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with Koha; if not, see <http://www.gnu.org/licenses>.
20
212206µs
# spent 117µs (28+89) within Koha::Template::Plugin::Branches::BEGIN@21 which was called: # once (28µs+89µs) by Template::Plugins::_load at line 21
use Modern::Perl;
# spent 117µs making 1 call to Koha::Template::Plugin::Branches::BEGIN@21 # spent 89µs making 1 call to Modern::Perl::import
22
23113µs
# spent 13µs within Koha::Template::Plugin::Branches::BEGIN@23 which was called: # once (13µs+0s) by Template::Plugins::_load at line 23
use Template::Plugin;
# spent 13µs making 1 call to Koha::Template::Plugin::Branches::BEGIN@23
242120µs
# spent 66µs (13+54) within Koha::Template::Plugin::Branches::BEGIN@24 which was called: # once (13µs+54µs) by Template::Plugins::_load at line 24
use base qw( Template::Plugin );
# spent 66µs making 1 call to Koha::Template::Plugin::Branches::BEGIN@24 # spent 54µs making 1 call to base::import
25
262541µs
# spent 280µs (19+261) within Koha::Template::Plugin::Branches::BEGIN@26 which was called: # once (19µs+261µs) by Template::Plugins::_load at line 26
use C4::Koha;
# spent 280µs making 1 call to Koha::Template::Plugin::Branches::BEGIN@26 # spent 261µs making 1 call to Exporter::import
27220µs
# spent 17µs (14+3) within Koha::Template::Plugin::Branches::BEGIN@27 which was called: # once (14µs+3µs) by Template::Plugins::_load at line 27
use C4::Context;
# spent 17µs making 1 call to Koha::Template::Plugin::Branches::BEGIN@27 # spent 3µs making 1 call to C4::Context::import
28
29sub GetName {
30 my ( $self, $branchcode ) = @_;
31
32 my $query = "SELECT branchname FROM branches WHERE branchcode = ?";
33 my $sth = C4::Context->dbh->prepare($query);
34 $sth->execute($branchcode);
35 my $b = $sth->fetchrow_hashref();
36 return $b ? $b->{'branchname'} : q{};
37}
38
39
# spent 187µs (113+73) within Koha::Template::Plugin::Branches::GetLoggedInBranchcode which was called 8 times, avg 23µs/call: # 4 times (59µs+42µs) by Template::Stash::XS::get at line 58 of koha-tmpl/intranet-tmpl/prog/en/includes/header.inc, avg 25µs/call # 4 times (54µs+31µs) by Template::Stash::XS::get at line 31 of koha-tmpl/intranet-tmpl/prog/en/includes/patron-search-box.inc, avg 21µs/call
sub GetLoggedInBranchcode {
4021µs my ($self) = @_;
41
42257µs1673µs return C4::Context->userenv ?
# spent 73µs making 16 calls to C4::Context::userenv, avg 5µs/call
43 C4::Context->userenv->{'branch'} :
44 '';
45}
46
47sub GetURL {
48 my ( $self, $branchcode ) = @_;
49
50 my $query = "SELECT branchurl FROM branches WHERE branchcode = ?";
51 my $sth = C4::Context->dbh->prepare($query);
52 $sth->execute($branchcode);
53 my $b = $sth->fetchrow_hashref();
54 return $b->{branchurl};
55}
56
57sub all {
58 my ( $self, $params ) = @_;
59 my $selected = $params->{selected};
60 my $dbh = C4::Context->dbh;
61 my @params;
62 my $query = q|
63 SELECT branchcode, branchname
64 FROM branches
65 |;
66 if ( C4::Branch::onlymine
67 and C4::Context->userenv
68 and C4::Context->userenv->{branch} )
69 {
70 $query .= q| WHERE branchcode = ? |;
71 push @params, C4::Context->userenv->{branch};
72 }
73 $query .= q| ORDER BY branchname|;
74 my $branches = $dbh->selectall_arrayref( $query, { Slice => {} }, @params );
75
76 if ( $selected ) {
77 for my $branch ( @$branches ) {
78 if ( $branch->{branchcode} eq $selected ) {
79 $branch->{selected} = 1;
80 }
81 }
82 }
83 return $branches;
84}
85
861;