Filename | /usr/share/koha/lib/C4/XSLT.pm |
Statements | Executed 5870 statements in 36.4ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
25 | 1 | 1 | 10.7ms | 2.49s | transformMARCXML4XSLT | C4::XSLT::
25 | 1 | 1 | 7.79ms | 4.46s | XSLTParse4Display | C4::XSLT::
25 | 1 | 1 | 7.74ms | 1.74s | buildKohaItemsNamespace | C4::XSLT::
1 | 1 | 1 | 5.66ms | 8.60ms | BEGIN@35 | C4::XSLT::
100 | 4 | 1 | 1.55ms | 1.55ms | CORE:subst (opcode) | C4::XSLT::
25 | 1 | 1 | 695µs | 1.27ms | _get_best_default_xslt_filename | C4::XSLT::
25 | 1 | 1 | 581µs | 6.60ms | getAuthorisedValues4MARCSubfields | C4::XSLT::
25 | 1 | 1 | 572µs | 572µs | CORE:ftfile (opcode) | C4::XSLT::
51 | 3 | 1 | 201µs | 201µs | CORE:match (opcode) | C4::XSLT::
1 | 1 | 1 | 34µs | 34µs | BEGIN@40 | C4::XSLT::
1 | 1 | 1 | 33µs | 41µs | BEGIN@23 | C4::XSLT::
1 | 1 | 1 | 31µs | 886µs | BEGIN@31 | C4::XSLT::
1 | 1 | 1 | 31µs | 302µs | BEGIN@27 | C4::XSLT::
1 | 1 | 1 | 30µs | 579µs | BEGIN@28 | C4::XSLT::
1 | 1 | 1 | 29µs | 194µs | BEGIN@33 | C4::XSLT::
1 | 1 | 1 | 29µs | 144µs | BEGIN@235 | C4::XSLT::
1 | 1 | 1 | 28µs | 1.16ms | BEGIN@36 | C4::XSLT::
1 | 1 | 1 | 27µs | 501µs | BEGIN@34 | C4::XSLT::
1 | 1 | 1 | 26µs | 1.28ms | BEGIN@30 | C4::XSLT::
1 | 1 | 1 | 26µs | 65µs | BEGIN@24 | C4::XSLT::
1 | 1 | 1 | 26µs | 904µs | BEGIN@29 | C4::XSLT::
1 | 1 | 1 | 24µs | 31µs | BEGIN@26 | C4::XSLT::
1 | 1 | 1 | 24µs | 801µs | BEGIN@32 | C4::XSLT::
1 | 1 | 1 | 18µs | 128µs | BEGIN@38 | C4::XSLT::
0 | 0 | 0 | 0s | 0s | GetURI | C4::XSLT::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package C4::XSLT; | ||||
2 | # Copyright (C) 2006 LibLime | ||||
3 | # <jmf at liblime dot com> | ||||
4 | # Parts Copyright Katrin Fischer 2011 | ||||
5 | # Parts Copyright ByWater Solutions 2011 | ||||
6 | # Parts Copyright Biblibre 2012 | ||||
7 | # | ||||
8 | # This file is part of Koha. | ||||
9 | # | ||||
10 | # Koha is free software; you can redistribute it and/or modify it under the | ||||
11 | # terms of the GNU General Public License as published by the Free Software | ||||
12 | # Foundation; either version 2 of the License, or (at your option) any later | ||||
13 | # version. | ||||
14 | # | ||||
15 | # Koha is distributed in the hope that it will be useful, but WITHOUT ANY | ||||
16 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | ||||
17 | # A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||||
18 | # | ||||
19 | # You should have received a copy of the GNU General Public License along | ||||
20 | # with Koha; if not, write to the Free Software Foundation, Inc., | ||||
21 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
22 | |||||
23 | 3 | 60µs | 2 | 49µs | # spent 41µs (33+8) within C4::XSLT::BEGIN@23 which was called:
# once (33µs+8µs) by C4::Search::BEGIN@29 at line 23 # spent 41µs making 1 call to C4::XSLT::BEGIN@23
# spent 8µs making 1 call to strict::import |
24 | 3 | 59µs | 2 | 104µs | # spent 65µs (26+39) within C4::XSLT::BEGIN@24 which was called:
# once (26µs+39µs) by C4::Search::BEGIN@29 at line 24 # spent 65µs making 1 call to C4::XSLT::BEGIN@24
# spent 39µs making 1 call to warnings::import |
25 | |||||
26 | 3 | 67µs | 2 | 37µs | # spent 31µs (24+6) within C4::XSLT::BEGIN@26 which was called:
# once (24µs+6µs) by C4::Search::BEGIN@29 at line 26 # spent 31µs making 1 call to C4::XSLT::BEGIN@26
# spent 6µs making 1 call to C4::Context::import |
27 | 3 | 66µs | 2 | 572µs | # spent 302µs (31+270) within C4::XSLT::BEGIN@27 which was called:
# once (31µs+270µs) by C4::Search::BEGIN@29 at line 27 # spent 302µs making 1 call to C4::XSLT::BEGIN@27
# spent 270µs making 1 call to Exporter::import |
28 | 3 | 62µs | 2 | 1.13ms | # spent 579µs (30+549) within C4::XSLT::BEGIN@28 which was called:
# once (30µs+549µs) by C4::Search::BEGIN@29 at line 28 # spent 579µs making 1 call to C4::XSLT::BEGIN@28
# spent 549µs making 1 call to Exporter::import |
29 | 3 | 80µs | 2 | 1.78ms | # spent 904µs (26+878) within C4::XSLT::BEGIN@29 which was called:
# once (26µs+878µs) by C4::Search::BEGIN@29 at line 29 # spent 904µs making 1 call to C4::XSLT::BEGIN@29
# spent 878µs making 1 call to Exporter::import |
30 | 3 | 68µs | 2 | 2.53ms | # spent 1.28ms (26µs+1.25) within C4::XSLT::BEGIN@30 which was called:
# once (26µs+1.25ms) by C4::Search::BEGIN@29 at line 30 # spent 1.28ms making 1 call to C4::XSLT::BEGIN@30
# spent 1.25ms making 1 call to Exporter::import |
31 | 3 | 63µs | 2 | 1.74ms | # spent 886µs (31+855) within C4::XSLT::BEGIN@31 which was called:
# once (31µs+855µs) by C4::Search::BEGIN@29 at line 31 # spent 886µs making 1 call to C4::XSLT::BEGIN@31
# spent 855µs making 1 call to Exporter::import |
32 | 3 | 63µs | 2 | 1.58ms | # spent 801µs (24+777) within C4::XSLT::BEGIN@32 which was called:
# once (24µs+777µs) by C4::Search::BEGIN@29 at line 32 # spent 801µs making 1 call to C4::XSLT::BEGIN@32
# spent 777µs making 1 call to Exporter::import |
33 | 3 | 68µs | 2 | 360µs | # spent 194µs (29+165) within C4::XSLT::BEGIN@33 which was called:
# once (29µs+165µs) by C4::Search::BEGIN@29 at line 33 # spent 194µs making 1 call to C4::XSLT::BEGIN@33
# spent 165µs making 1 call to Exporter::import |
34 | 3 | 65µs | 2 | 975µs | # spent 501µs (27+474) within C4::XSLT::BEGIN@34 which was called:
# once (27µs+474µs) by C4::Search::BEGIN@29 at line 34 # spent 501µs making 1 call to C4::XSLT::BEGIN@34
# spent 474µs making 1 call to XML::LibXML::import |
35 | 3 | 293µs | 2 | 8.61ms | # spent 8.60ms (5.66+2.94) within C4::XSLT::BEGIN@35 which was called:
# once (5.66ms+2.94ms) by C4::Search::BEGIN@29 at line 35 # spent 8.60ms making 1 call to C4::XSLT::BEGIN@35
# spent 6µs making 1 call to UNIVERSAL::import |
36 | 3 | 77µs | 2 | 2.30ms | # spent 1.16ms (28µs+1.13) within C4::XSLT::BEGIN@36 which was called:
# once (28µs+1.13ms) by C4::Search::BEGIN@29 at line 36 # spent 1.16ms making 1 call to C4::XSLT::BEGIN@36
# spent 1.13ms making 1 call to LWP::Simple::import |
37 | |||||
38 | 3 | 111µs | 2 | 238µs | # spent 128µs (18+110) within C4::XSLT::BEGIN@38 which was called:
# once (18µs+110µs) by C4::Search::BEGIN@29 at line 38 # spent 128µs making 1 call to C4::XSLT::BEGIN@38
# spent 110µs making 1 call to vars::import |
39 | |||||
40 | # spent 34µs within C4::XSLT::BEGIN@40 which was called:
# once (34µs+0s) by C4::Search::BEGIN@29 at line 48 | ||||
41 | 1 | 1µs | require Exporter; | ||
42 | 1 | 2µs | $VERSION = 3.07.00.049; | ||
43 | 1 | 17µs | @ISA = qw(Exporter); | ||
44 | 1 | 13µs | @EXPORT = qw( | ||
45 | &XSLTParse4Display | ||||
46 | &GetURI | ||||
47 | ); | ||||
48 | 1 | 1.59ms | 1 | 34µs | } # spent 34µs making 1 call to C4::XSLT::BEGIN@40 |
49 | |||||
50 | =head1 NAME | ||||
51 | |||||
- - | |||||
62 | sub GetURI { | ||||
63 | my ($uri) = @_; | ||||
64 | my $string; | ||||
65 | $string = get $uri ; | ||||
66 | return $string; | ||||
67 | } | ||||
68 | |||||
69 | =head2 transformMARCXML4XSLT | ||||
70 | |||||
- - | |||||
75 | # spent 2.49s (10.7ms+2.47) within C4::XSLT::transformMARCXML4XSLT which was called 25 times, avg 99.4ms/call:
# 25 times (10.7ms+2.47s) by C4::XSLT::XSLTParse4Display at line 197, avg 99.4ms/call | ||||
76 | 25 | 49µs | my ($biblionumber, $record) = @_; | ||
77 | 25 | 198µs | 100 | 55.3ms | my $frameworkcode = GetFrameworkCode($biblionumber) || ''; # spent 54.9ms making 25 calls to C4::Biblio::GetFrameworkCode, avg 2.19ms/call
# spent 319µs making 50 calls to DBI::common::DESTROY, avg 6µs/call
# spent 80µs making 25 calls to DBD::_mem::common::DESTROY, avg 3µs/call |
78 | 25 | 274µs | 25 | 1.60s | my $tagslib = &GetMarcStructure(1,$frameworkcode); # spent 1.60s making 25 calls to Memoize::__ANON__[(eval 1015)[Memoize.pm:73]:1], avg 64.1ms/call |
79 | 25 | 21µs | my @fields; | ||
80 | # FIXME: wish there was a better way to handle exceptions | ||||
81 | 25 | 68µs | eval { | ||
82 | 25 | 300µs | 25 | 435µs | @fields = $record->fields(); # spent 435µs making 25 calls to MARC::Record::fields, avg 17µs/call |
83 | }; | ||||
84 | 25 | 13µs | if ($@) { warn "PROBLEM WITH RECORD"; next; } | ||
85 | 25 | 134µs | 25 | 6.60ms | my $av = getAuthorisedValues4MARCSubfields($frameworkcode); # spent 6.60ms making 25 calls to C4::XSLT::getAuthorisedValues4MARCSubfields, avg 264µs/call |
86 | 25 | 116µs | foreach my $tag ( keys %$av ) { | ||
87 | 50 | 468µs | 50 | 15.9ms | foreach my $field ( $record->field( $tag ) ) { # spent 15.9ms making 50 calls to MARC::Record::field, avg 317µs/call |
88 | 57 | 405µs | if ( $av->{ $tag } ) { | ||
89 | 57 | 58µs | my @new_subfields = (); | ||
90 | 57 | 1.04ms | 57 | 2.48ms | for my $subfield ( $field->subfields() ) { # spent 2.48ms making 57 calls to MARC::Field::subfields, avg 44µs/call |
91 | 636 | 950µs | my ( $letter, $value ) = @$subfield; | ||
92 | 636 | 2.52ms | 817 | 784ms | $value = GetAuthorisedValueDesc( $tag, $letter, $value, '', $tagslib ) # spent 782ms making 295 calls to C4::Biblio::GetAuthorisedValueDesc, avg 2.65ms/call
# spent 1.84ms making 348 calls to DBI::common::DESTROY, avg 5µs/call
# spent 453µs making 174 calls to DBD::_mem::common::DESTROY, avg 3µs/call |
93 | if $av->{ $tag }->{ $letter }; | ||||
94 | 636 | 1.79ms | push( @new_subfields, $letter, $value ); | ||
95 | } | ||||
96 | 57 | 1.34ms | 228 | 9.07ms | $field ->replace_with( MARC::Field->new( # spent 5.25ms making 57 calls to MARC::Field::new, avg 92µs/call
# spent 1.93ms making 114 calls to MARC::Field::indicator, avg 17µs/call
# spent 1.88ms making 57 calls to MARC::Field::replace_with, avg 33µs/call |
97 | $tag, | ||||
98 | $field->indicator(1), | ||||
99 | $field->indicator(2), | ||||
100 | @new_subfields | ||||
101 | ) ); | ||||
102 | } | ||||
103 | } | ||||
104 | } | ||||
105 | 25 | 356µs | return $record; | ||
106 | } | ||||
107 | |||||
108 | =head2 getAuthorisedValues4MARCSubfields | ||||
109 | |||||
- - | |||||
114 | # Cache for tagfield-tagsubfield to decode per framework. | ||||
115 | # Should be preferably be placed in Koha-core... | ||||
116 | 1 | 600ns | my %authval_per_framework; | ||
117 | |||||
118 | # spent 6.60ms (581µs+6.02) within C4::XSLT::getAuthorisedValues4MARCSubfields which was called 25 times, avg 264µs/call:
# 25 times (581µs+6.02ms) by C4::XSLT::transformMARCXML4XSLT at line 85, avg 264µs/call | ||||
119 | 25 | 37µs | my ($frameworkcode) = @_; | ||
120 | 25 | 46µs | 9 | 57µs | unless ( $authval_per_framework{ $frameworkcode } ) { # spent 44µs making 6 calls to DBI::common::DESTROY, avg 7µs/call
# spent 14µs making 3 calls to DBD::_mem::common::DESTROY, avg 5µs/call |
121 | 3 | 21µs | 3 | 3.10ms | my $dbh = C4::Context->dbh; # spent 3.10ms making 3 calls to C4::Context::dbh, avg 1.03ms/call |
122 | 3 | 71µs | 6 | 727µs | my $sth = $dbh->prepare("SELECT DISTINCT tagfield, tagsubfield # spent 391µs making 3 calls to DBI::db::prepare, avg 130µs/call
# spent 336µs making 3 calls to DBD::mysql::db::prepare, avg 112µs/call |
123 | FROM marc_subfield_structure | ||||
124 | WHERE authorised_value IS NOT NULL | ||||
125 | AND authorised_value!='' | ||||
126 | AND frameworkcode=?"); | ||||
127 | 3 | 2.31ms | 3 | 2.27ms | $sth->execute( $frameworkcode ); # spent 2.27ms making 3 calls to DBI::st::execute, avg 756µs/call |
128 | 3 | 5µs | my $av = { }; | ||
129 | 3 | 394µs | 44 | 207µs | while ( my ( $tag, $letter ) = $sth->fetchrow() ) { # spent 207µs making 44 calls to DBI::st::fetchrow, avg 5µs/call |
130 | $av->{ $tag }->{ $letter } = 1; | ||||
131 | } | ||||
132 | 3 | 150µs | $authval_per_framework{ $frameworkcode } = $av; | ||
133 | } | ||||
134 | 25 | 119µs | return $authval_per_framework{ $frameworkcode }; | ||
135 | } | ||||
136 | |||||
137 | 1 | 400ns | my $stylesheet; | ||
138 | |||||
139 | # spent 1.27ms (695µs+572µs) within C4::XSLT::_get_best_default_xslt_filename which was called 25 times, avg 51µs/call:
# 25 times (695µs+572µs) by C4::XSLT::XSLTParse4Display at line 188, avg 51µs/call | ||||
140 | 25 | 52µs | my ($htdocs, $theme, $lang, $base_xslfile) = @_; | ||
141 | |||||
142 | 25 | 266µs | my @candidates = ( | ||
143 | "$htdocs/$theme/$lang/xslt/${base_xslfile}", # exact match | ||||
144 | "$htdocs/$theme/en/xslt/${base_xslfile}", # if not, preferred theme in English | ||||
145 | "$htdocs/prog/$lang/xslt/${base_xslfile}", # if not, 'prog' theme in preferred language | ||||
146 | "$htdocs/prog/en/xslt/${base_xslfile}", # otherwise, prog theme in English; should always | ||||
147 | # exist | ||||
148 | ); | ||||
149 | 25 | 14µs | my $xslfilename; | ||
150 | 25 | 37µs | foreach my $filename (@candidates) { | ||
151 | 25 | 20µs | $xslfilename = $filename; | ||
152 | 25 | 703µs | 25 | 572µs | if (-f $filename) { # spent 572µs making 25 calls to C4::XSLT::CORE:ftfile, avg 23µs/call |
153 | 25 | 47µs | last; # we have a winner! | ||
154 | } | ||||
155 | } | ||||
156 | 25 | 129µs | return $xslfilename; | ||
157 | } | ||||
158 | |||||
159 | # spent 4.46s (7.79ms+4.45) within C4::XSLT::XSLTParse4Display which was called 25 times, avg 178ms/call:
# 25 times (7.79ms+4.45s) by C4::Search::searchResults at line 2014 of /usr/share/koha/lib/C4/Search.pm, avg 178ms/call | ||||
160 | 25 | 62µs | my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items ) = @_; | ||
161 | 25 | 87µs | 25 | 88µs | my $xslfilename = C4::Context->preference($xslsyspref); # spent 88µs making 25 calls to C4::Context::preference, avg 4µs/call |
162 | 25 | 241µs | 25 | 132µs | if ( $xslfilename =~ /^\s*"?default"?\s*$/i ) { # spent 132µs making 25 calls to C4::XSLT::CORE:match, avg 5µs/call |
163 | 25 | 12µs | my $htdocs; | ||
164 | 25 | 9µs | my $theme; | ||
165 | 25 | 165µs | 25 | 163µs | my $lang = C4::Templates::_current_language(); # spent 163µs making 25 calls to C4::Templates::_current_language, avg 7µs/call |
166 | 25 | 11µs | my $xslfile; | ||
167 | 25 | 136µs | if ($xslsyspref eq "XSLTDetailsDisplay") { | ||
168 | $htdocs = C4::Context->config('intrahtdocs'); | ||||
169 | $theme = C4::Context->preference("template"); | ||||
170 | $xslfile = C4::Context->preference('marcflavour') . | ||||
171 | "slim2intranetDetail.xsl"; | ||||
172 | } elsif ($xslsyspref eq "XSLTResultsDisplay") { | ||||
173 | $htdocs = C4::Context->config('intrahtdocs'); | ||||
174 | $theme = C4::Context->preference("template"); | ||||
175 | $xslfile = C4::Context->preference('marcflavour') . | ||||
176 | "slim2intranetResults.xsl"; | ||||
177 | } elsif ($xslsyspref eq "OPACXSLTDetailsDisplay") { | ||||
178 | $htdocs = C4::Context->config('opachtdocs'); | ||||
179 | $theme = C4::Context->preference("opacthemes"); | ||||
180 | $xslfile = C4::Context->preference('marcflavour') . | ||||
181 | "slim2OPACDetail.xsl"; | ||||
182 | } elsif ($xslsyspref eq "OPACXSLTResultsDisplay") { | ||||
183 | 25 | 138µs | 25 | 569µs | $htdocs = C4::Context->config('opachtdocs'); # spent 569µs making 25 calls to C4::Context::config, avg 23µs/call |
184 | 25 | 87µs | 25 | 117µs | $theme = C4::Context->preference("opacthemes"); # spent 117µs making 25 calls to C4::Context::preference, avg 5µs/call |
185 | 25 | 102µs | 25 | 161µs | $xslfile = C4::Context->preference('marcflavour') . # spent 161µs making 25 calls to C4::Context::preference, avg 6µs/call |
186 | "slim2OPACResults.xsl"; | ||||
187 | } | ||||
188 | 25 | 127µs | 25 | 1.27ms | $xslfilename = _get_best_default_xslt_filename($htdocs, $theme, $lang, $xslfile); # spent 1.27ms making 25 calls to C4::XSLT::_get_best_default_xslt_filename, avg 51µs/call |
189 | } | ||||
190 | |||||
191 | 25 | 139µs | 25 | 65µs | if ( $xslfilename =~ m/\{langcode\}/ ) { # spent 65µs making 25 calls to C4::XSLT::CORE:match, avg 3µs/call |
192 | my $lang = C4::Templates::_current_language(); | ||||
193 | $xslfilename =~ s/\{langcode\}/$lang/; | ||||
194 | } | ||||
195 | |||||
196 | # grab the XML, run it through our stylesheet, push it out to the browser | ||||
197 | 25 | 214µs | 25 | 2.49s | my $record = transformMARCXML4XSLT($biblionumber, $orig_record); # spent 2.49s making 25 calls to C4::XSLT::transformMARCXML4XSLT, avg 99.4ms/call |
198 | #return $record->as_formatted(); | ||||
199 | 25 | 189µs | 25 | 1.74s | my $itemsxml = buildKohaItemsNamespace($biblionumber, $hidden_items); # spent 1.74s making 25 calls to C4::XSLT::buildKohaItemsNamespace, avg 69.7ms/call |
200 | 25 | 481µs | 50 | 105ms | my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour')); # spent 105ms making 25 calls to MARC::Record::as_xml, avg 4.19ms/call
# spent 416µs making 25 calls to C4::Context::preference, avg 17µs/call |
201 | 25 | 28µs | my $sysxml = "<sysprefs>\n"; | ||
202 | 25 | 101µs | foreach my $syspref ( qw/ hidelostitems OPACURLOpenInNewWindow | ||
203 | DisplayOPACiconsXSLT URLLinkText viewISBD | ||||
204 | OPACBaseURL TraceCompleteSubfields UseICU | ||||
205 | UseAuthoritiesForTracings TraceSubjectSubdivisions | ||||
206 | Display856uAsImage OPACDisplay856uAsImage | ||||
207 | UseControlNumber IntranetBiblioDefaultView BiblioDefaultView | ||||
208 | singleBranchMode OPACItemLocation DisplayIconsXSLT | ||||
209 | AlternateHoldingsField AlternateHoldingsSeparator | ||||
210 | TrackClicks OpacResultsItemtypeImage/ ) | ||||
211 | { | ||||
212 | 550 | 1.51ms | 550 | 37.5ms | my $sp = C4::Context->preference( $syspref ); # spent 37.5ms making 550 calls to C4::Context::preference, avg 68µs/call |
213 | 550 | 182µs | next unless defined($sp); | ||
214 | 525 | 824µs | $sysxml .= "<syspref name=\"$syspref\">$sp</syspref>\n"; | ||
215 | } | ||||
216 | 25 | 25µs | $sysxml .= "</sysprefs>\n"; | ||
217 | 25 | 829µs | 25 | 629µs | $xmlrecord =~ s/\<\/record\>/$itemsxml$sysxml\<\/record\>/; # spent 629µs making 25 calls to C4::XSLT::CORE:subst, avg 25µs/call |
218 | 25 | 34µs | if ($fixamps) { # We need to correct the ampersand entities that Zebra outputs | ||
219 | 25 | 322µs | 25 | 242µs | $xmlrecord =~ s/\&amp;/\&/g; # spent 242µs making 25 calls to C4::XSLT::CORE:subst, avg 10µs/call |
220 | } | ||||
221 | 25 | 472µs | 25 | 409µs | $xmlrecord =~ s/\& /\&\; /; # spent 409µs making 25 calls to C4::XSLT::CORE:subst, avg 16µs/call |
222 | 25 | 332µs | 25 | 272µs | $xmlrecord =~ s/\&\;amp\; /\&\; /; # spent 272µs making 25 calls to C4::XSLT::CORE:subst, avg 11µs/call |
223 | |||||
224 | 25 | 190µs | 25 | 498µs | my $parser = XML::LibXML->new(); # spent 498µs making 25 calls to XML::LibXML::new, avg 20µs/call |
225 | # don't die when you find &, >, etc | ||||
226 | 25 | 141µs | 25 | 1.11ms | $parser->recover_silently(0); # spent 1.11ms making 25 calls to XML::LibXML::recover_silently, avg 44µs/call |
227 | 25 | 146µs | 25 | 12.7ms | my $source = $parser->parse_string($xmlrecord); # spent 12.7ms making 25 calls to XML::LibXML::parse_string, avg 506µs/call |
228 | 25 | 79µs | 2 | 490µs | unless ( $stylesheet->{$xslfilename} ) { # spent 246µs making 1 call to AutoLoader::AUTOLOAD
# spent 245µs making 1 call to XML::LibXML::Node::DESTROY |
229 | 1 | 12µs | 1 | 27µs | my $xslt = XML::LibXSLT->new(); # spent 27µs making 1 call to XML::LibXSLT::new |
230 | 1 | 500ns | my $style_doc; | ||
231 | 1 | 14µs | 1 | 5µs | if ( $xslfilename =~ /^https?:\/\// ) { # spent 5µs making 1 call to C4::XSLT::CORE:match |
232 | my $xsltstring = GetURI($xslfilename); | ||||
233 | $style_doc = $parser->parse_string($xsltstring); | ||||
234 | } else { | ||||
235 | 3 | 950µs | 2 | 259µs | # spent 144µs (29+115) within C4::XSLT::BEGIN@235 which was called:
# once (29µs+115µs) by C4::Search::BEGIN@29 at line 235 # spent 144µs making 1 call to C4::XSLT::BEGIN@235
# spent 115µs making 1 call to Exporter::import |
236 | 1 | 6µs | 1 | 1.87ms | $style_doc = $parser->parse_file($xslfilename); # spent 1.87ms making 1 call to XML::LibXML::parse_file |
237 | } | ||||
238 | 1 | 283µs | 1 | 10.3ms | $stylesheet->{$xslfilename} = $xslt->parse_stylesheet($style_doc); # spent 10.3ms making 1 call to XML::LibXSLT::parse_stylesheet |
239 | } | ||||
240 | 25 | 207µs | 25 | 47.5ms | my $results = $stylesheet->{$xslfilename}->transform($source); # spent 47.5ms making 25 calls to XML::LibXSLT::StylesheetWrapper::transform, avg 1.90ms/call |
241 | 25 | 174µs | 25 | 1.79ms | my $newxmlrecord = $stylesheet->{$xslfilename}->output_string($results); # spent 1.79ms making 25 calls to XML::LibXSLT::StylesheetWrapper::output_string, avg 72µs/call |
242 | 25 | 2.22ms | return $newxmlrecord; | ||
243 | } | ||||
244 | |||||
245 | # spent 1.74s (7.74ms+1.74) within C4::XSLT::buildKohaItemsNamespace which was called 25 times, avg 69.7ms/call:
# 25 times (7.74ms+1.74s) by C4::XSLT::XSLTParse4Display at line 199, avg 69.7ms/call | ||||
246 | 25 | 48µs | my ($biblionumber, $hidden_items) = @_; | ||
247 | |||||
248 | 25 | 248µs | 250 | 840ms | my @items = C4::Items::GetItemsInfo($biblionumber); # spent 839ms making 25 calls to C4::Items::GetItemsInfo, avg 33.5ms/call
# spent 1.36ms making 150 calls to DBI::common::DESTROY, avg 9µs/call
# spent 380µs making 75 calls to DBD::_mem::common::DESTROY, avg 5µs/call |
249 | 25 | 62µs | if ($hidden_items && @$hidden_items) { | ||
250 | my %hi = map {$_ => 1} @$hidden_items; | ||||
251 | @items = grep { !$hi{$_->{itemnumber}} } @items; | ||||
252 | } | ||||
253 | |||||
254 | 25 | 406µs | 200 | 171ms | my $shelflocations = GetKohaAuthorisedValues('items.location',GetFrameworkCode($biblionumber), 'opac'); # spent 117ms making 25 calls to C4::Koha::GetKohaAuthorisedValues, avg 4.70ms/call
# spent 52.4ms making 25 calls to C4::Biblio::GetFrameworkCode, avg 2.10ms/call
# spent 528µs making 100 calls to DBI::common::DESTROY, avg 5µs/call
# spent 154µs making 50 calls to DBD::_mem::common::DESTROY, avg 3µs/call |
255 | 25 | 315µs | 200 | 172ms | my $ccodes = GetKohaAuthorisedValues('items.ccode',GetFrameworkCode($biblionumber), 'opac'); # spent 118ms making 25 calls to C4::Koha::GetKohaAuthorisedValues, avg 4.73ms/call
# spent 52.5ms making 25 calls to C4::Biblio::GetFrameworkCode, avg 2.10ms/call
# spent 672µs making 100 calls to DBI::common::DESTROY, avg 7µs/call
# spent 154µs making 50 calls to DBD::_mem::common::DESTROY, avg 3µs/call |
256 | |||||
257 | 25 | 207µs | 175 | 341ms | my $branches = GetBranches(); # spent 340ms making 25 calls to C4::Branch::GetBranches, avg 13.6ms/call
# spent 661µs making 100 calls to DBI::common::DESTROY, avg 7µs/call
# spent 210µs making 50 calls to DBD::_mem::common::DESTROY, avg 4µs/call |
258 | 25 | 194µs | 100 | 78.1ms | my $itemtypes = GetItemTypes(); # spent 77.7ms making 25 calls to C4::Koha::GetItemTypes, avg 3.11ms/call
# spent 251µs making 50 calls to DBI::common::DESTROY, avg 5µs/call
# spent 118µs making 25 calls to DBD::_mem::common::DESTROY, avg 5µs/call |
259 | 25 | 37µs | my $location = ""; | ||
260 | 25 | 19µs | my $ccode = ""; | ||
261 | 25 | 18µs | my $xml = ''; | ||
262 | 25 | 80µs | for my $item (@items) { | ||
263 | 32 | 11µs | my $status; | ||
264 | |||||
265 | 32 | 309µs | 128 | 70.3ms | my ( $transfertwhen, $transfertfrom, $transfertto ) = C4::Circulation::GetTransfers($item->{itemnumber}); # spent 69.9ms making 32 calls to C4::Circulation::GetTransfers, avg 2.18ms/call
# spent 305µs making 64 calls to DBI::common::DESTROY, avg 5µs/call
# spent 96µs making 32 calls to DBD::_mem::common::DESTROY, avg 3µs/call |
266 | |||||
267 | 32 | 359µs | 128 | 67.3ms | my $reservestatus = C4::Reserves::GetReserveStatus( $item->{itemnumber} ); # spent 67.0ms making 32 calls to C4::Reserves::GetReserveStatus, avg 2.09ms/call
# spent 289µs making 64 calls to DBI::common::DESTROY, avg 5µs/call
# spent 71µs making 32 calls to DBD::_mem::common::DESTROY, avg 2µs/call |
268 | |||||
269 | 32 | 404µs | if ( $itemtypes->{ $item->{itype} }->{notforloan} || $item->{notforloan} || $item->{onloan} || $item->{wthdrawn} || $item->{itemlost} || $item->{damaged} || | ||
270 | (defined $transfertwhen && $transfertwhen ne '') || $item->{itemnotforloan} || (defined $reservestatus && $reservestatus eq "Waiting") ){ | ||||
271 | 1 | 13µs | if ( $item->{notforloan} < 0) { | ||
272 | $status = "On order"; | ||||
273 | } | ||||
274 | 1 | 8µs | if ( $item->{itemnotforloan} > 0 || $item->{notforloan} > 0 || $itemtypes->{ $item->{itype} }->{notforloan} == 1 ) { | ||
275 | $status = "reference"; | ||||
276 | } | ||||
277 | 1 | 2µs | if ($item->{onloan}) { | ||
278 | $status = "Checked out"; | ||||
279 | } | ||||
280 | 1 | 2µs | if ( $item->{wthdrawn}) { | ||
281 | $status = "Withdrawn"; | ||||
282 | } | ||||
283 | 1 | 2µs | if ($item->{itemlost}) { | ||
284 | $status = "Lost"; | ||||
285 | } | ||||
286 | 1 | 1µs | if ($item->{damaged}) { | ||
287 | $status = "Damaged"; | ||||
288 | } | ||||
289 | 1 | 900ns | if (defined $transfertwhen && $transfertwhen ne '') { | ||
290 | $status = 'In transit'; | ||||
291 | } | ||||
292 | 1 | 2µs | if (defined $reservestatus && $reservestatus eq "Waiting") { | ||
293 | $status = 'Waiting'; | ||||
294 | } | ||||
295 | } else { | ||||
296 | 31 | 39µs | $status = "available"; | ||
297 | } | ||||
298 | 32 | 338µs | 32 | 994µs | my $homebranch = $item->{homebranch}? xml_escape($branches->{$item->{homebranch}}->{'branchname'}):''; # spent 994µs making 32 calls to C4::Koha::xml_escape, avg 31µs/call |
299 | 32 | 157µs | 32 | 478µs | my $holdingbranch = $item->{holdingbranch}? xml_escape($branches->{$item->{holdingbranch}}->{'branchname'}):''; # spent 478µs making 32 calls to C4::Koha::xml_escape, avg 15µs/call |
300 | 32 | 159µs | 17 | 237µs | $location = $item->{location}? xml_escape($shelflocations->{$item->{location}}||$item->{location}):''; # spent 237µs making 17 calls to C4::Koha::xml_escape, avg 14µs/call |
301 | 32 | 66µs | 1 | 22µs | $ccode = $item->{ccode}? xml_escape($ccodes->{$item->{ccode}}||$item->{ccode}):''; # spent 22µs making 1 call to C4::Koha::xml_escape |
302 | 32 | 113µs | 32 | 359µs | my $itemcallnumber = xml_escape($item->{itemcallnumber}); # spent 359µs making 32 calls to C4::Koha::xml_escape, avg 11µs/call |
303 | 32 | 326µs | $xml.= "<item><homebranch>$homebranch</homebranch>". | ||
304 | "<holdingbranch>$holdingbranch</holdingbranch>". | ||||
305 | "<location>$location</location>". | ||||
306 | "<ccode>$ccode</ccode>". | ||||
307 | "<status>$status</status>". | ||||
308 | "<itemcallnumber>".$itemcallnumber."</itemcallnumber>" | ||||
309 | . "</item>"; | ||||
310 | |||||
311 | } | ||||
312 | 25 | 47µs | $xml = "<items xmlns=\"http://www.koha-community.org/items\">".$xml."</items>"; | ||
313 | 25 | 3.75ms | return $xml; | ||
314 | } | ||||
315 | |||||
- - | |||||
318 | 1 | 7µs | 1; | ||
319 | __END__ | ||||
# spent 572µs within C4::XSLT::CORE:ftfile which was called 25 times, avg 23µs/call:
# 25 times (572µs+0s) by C4::XSLT::_get_best_default_xslt_filename at line 152, avg 23µs/call | |||||
sub C4::XSLT::CORE:match; # opcode | |||||
# spent 1.55ms within C4::XSLT::CORE:subst which was called 100 times, avg 16µs/call:
# 25 times (629µs+0s) by C4::XSLT::XSLTParse4Display at line 217, avg 25µs/call
# 25 times (409µs+0s) by C4::XSLT::XSLTParse4Display at line 221, avg 16µs/call
# 25 times (272µs+0s) by C4::XSLT::XSLTParse4Display at line 222, avg 11µs/call
# 25 times (242µs+0s) by C4::XSLT::XSLTParse4Display at line 219, avg 10µs/call |