← Index
NYTProf Performance Profile   « block view • line view • sub view »
For /usr/share/koha/opac/cgi-bin/opac/opac-search.pl
  Run on Tue Oct 15 17:10:45 2013
Reported on Tue Oct 15 17:12:25 2013

Filename/usr/lib/perl5/Template/Config.pm
StatementsExecuted 217 statements in 3.10ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
198116.6ms58.1msTemplate::Config::::load Template::Config::load
1274242µs2.73msTemplate::Config::::iterator Template::Config::iterator
1911182µs182µsTemplate::Config::::CORE:subst Template::Config::CORE:subst (opcode)
11164µs33.7msTemplate::Config::::parser Template::Config::parser
11153µs23.3msTemplate::Config::::context Template::Config::context
11142µs4.14msTemplate::Config::::filters Template::Config::filters
11140µs1.87msTemplate::Config::::plugins Template::Config::plugins
11132µs12.0msTemplate::Config::::stash Template::Config::stash
11125µs124µsTemplate::Config::::provider Template::Config::provider
11125µs23.4msTemplate::Config::::service Template::Config::service
11123µs28µsTemplate::Config::::BEGIN@21 Template::Config::BEGIN@21
11112µs258µsTemplate::Config::::BEGIN@24 Template::Config::BEGIN@24
11111µs28µsTemplate::Config::::BEGIN@22 Template::Config::BEGIN@22
11110µs70µsTemplate::Config::::BEGIN@23 Template::Config::BEGIN@23
0000s0sTemplate::Config::::constants Template::Config::constants
0000s0sTemplate::Config::::instdir Template::Config::instdir
0000s0sTemplate::Config::::preload Template::Config::preload
0000s0sTemplate::TieString::::PRINTTemplate::TieString::PRINT
0000s0sTemplate::TieString::::TIEHANDLETemplate::TieString::TIEHANDLE
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1#============================================================= -*-perl-*-
2#
3# Template::Config
4#
5# DESCRIPTION
6# Template Toolkit configuration module.
7#
8# AUTHOR
9# Andy Wardley <abw@wardley.org>
10#
11# COPYRIGHT
12# Copyright (C) 1996-2007 Andy Wardley. All Rights Reserved.
13#
14# This module is free software; you can redistribute it and/or
15# modify it under the same terms as Perl itself.
16#
17#========================================================================
18
19package Template::Config;
20
21329µs233µs
# spent 28µs (23+5) within Template::Config::BEGIN@21 which was called: # once (23µs+5µs) by Template::BEGIN@27 at line 21
use strict;
# spent 28µs making 1 call to Template::Config::BEGIN@21 # spent 5µs making 1 call to strict::import
22333µs245µs
# spent 28µs (11+17) within Template::Config::BEGIN@22 which was called: # once (11µs+17µs) by Template::BEGIN@27 at line 22
use warnings;
# spent 28µs making 1 call to Template::Config::BEGIN@22 # spent 17µs making 1 call to warnings::import
23349µs2130µs
# spent 70µs (10+60) within Template::Config::BEGIN@23 which was called: # once (10µs+60µs) by Template::BEGIN@27 at line 23
use base 'Template::Base';
# spent 70µs making 1 call to Template::Config::BEGIN@23 # spent 60µs making 1 call to base::import
24110µs1247µs
# spent 258µs (12+247) within Template::Config::BEGIN@24 which was called: # once (12µs+247µs) by Template::BEGIN@27 at line 27
use vars qw( $VERSION $DEBUG $ERROR $INSTDIR
# spent 247µs making 1 call to vars::import
25 $PARSER $PROVIDER $PLUGINS $FILTERS $ITERATOR
26 $LATEX_PATH $PDFLATEX_PATH $DVIPS_PATH
2721.03ms1258µs $STASH $SERVICE $CONTEXT $CONSTANTS @PRELOAD );
# spent 258µs making 1 call to Template::Config::BEGIN@24
28
291500ns$VERSION = 2.75;
301600ns$DEBUG = 0 unless defined $DEBUG;
311400ns$ERROR = '';
321300ns$CONTEXT = 'Template::Context';
331300ns$FILTERS = 'Template::Filters';
341300ns$ITERATOR = 'Template::Iterator';
351300ns$PARSER = 'Template::Parser';
361200ns$PLUGINS = 'Template::Plugins';
371300ns$PROVIDER = 'Template::Provider';
381300ns$SERVICE = 'Template::Service';
391400ns$STASH = 'Template::Stash::XS';
401300ns$CONSTANTS = 'Template::Namespace::Constants';
41
4212µs@PRELOAD = ( $CONTEXT, $FILTERS, $ITERATOR, $PARSER,
43 $PLUGINS, $PROVIDER, $SERVICE, $STASH );
44
45# the following is set at installation time by the Makefile.PL
461400ns$INSTDIR = '';
47
48
49#========================================================================
50# --- CLASS METHODS ---
51#========================================================================
52
53#------------------------------------------------------------------------
54# preload($module, $module, ...)
55#
56# Preloads all the standard TT modules that are likely to be used, along
57# with any other passed as arguments.
58#------------------------------------------------------------------------
59
60sub preload {
61 my $class = shift;
62
63 foreach my $module (@PRELOAD, @_) {
64 $class->load($module) || return;
65 };
66 return 1;
67}
68
69
70#------------------------------------------------------------------------
71# load($module)
72#
73# Load a module via require(). Any occurences of '::' in the module name
74# are be converted to '/' and '.pm' is appended. Returns 1 on success
75# or undef on error. Use $class->error() to examine the error string.
76#------------------------------------------------------------------------
77
78
# spent 58.1ms (16.6+41.5) within Template::Config::load which was called 19 times, avg 3.06ms/call: # 12 times (1.43ms+576µs) by Template::Config::iterator at line 176, avg 168µs/call # once (5.46ms+28.0ms) by Template::Config::parser at line 102 # once (469µs+11.5ms) by Template::Config::stash at line 194 # once (4.18ms+703µs) by Template::Config::context at line 212 # once (3.55ms+488µs) by Template::Config::filters at line 158 # once (1.50ms+246µs) by Template::Config::plugins at line 139 # once (18µs+10µs) by Template::Config::service at line 230 # once (11µs+13µs) by Template::Config::provider at line 120
sub load {
791930µs my ($class, $module) = @_;
8019267µs19182µs $module =~ s[::][/]g;
# spent 182µs making 19 calls to Template::Config::CORE:subst, avg 10µs/call
811911µs $module .= '.pm';
8238977µs eval { require $module; };
8319190µs return $@ ? $class->error("failed to load $module: $@") : 1;
84}
85
86
87#------------------------------------------------------------------------
88# parser(\%params)
89#
90# Instantiate a new parser object of the class whose name is denoted by
91# the package variable $PARSER (default: Template::Parser). Returns
92# a reference to a newly instantiated parser object or undef on error.
93# The class error() method can be called without arguments to examine
94# the error message generated by this failure.
95#------------------------------------------------------------------------
96
97
# spent 33.7ms (64µs+33.7) within Template::Config::parser which was called: # once (64µs+33.7ms) by Template::Provider::_compile at line 838 of Template/Provider.pm
sub parser {
981800ns my $class = shift;
9913µs my $params = defined($_[0]) && ref($_[0]) eq 'HASH'
100 ? shift : { @_ };
101
10214µs133.4ms return undef unless $class->load($PARSER);
# spent 33.4ms making 1 call to Template::Config::load
103118µs1254µs return $PARSER->new($params)
# spent 254µs making 1 call to Template::Parser::new
104 || $class->error("failed to create parser: ", $PARSER->error);
105}
106
107
108#------------------------------------------------------------------------
109# provider(\%params)
110#
111# Instantiate a new template provider object (default: Template::Provider).
112# Returns an object reference or undef on error, as above.
113#------------------------------------------------------------------------
114
115
# spent 124µs (25+98) within Template::Config::provider which was called: # once (25µs+98µs) by Template::Context::_init at line 837 of Template/Context.pm
sub provider {
1161800ns my $class = shift;
11712µs my $params = defined($_[0]) && ref($_[0]) eq 'HASH'
118 ? shift : { @_ };
119
12013µs125µs return undef unless $class->load($PROVIDER);
# spent 25µs making 1 call to Template::Config::load
121116µs10s return $PROVIDER->new($params)
# spent 74µs making 1 call to Template::Base::new, recursion: max depth 3, sum of overlapping time 74µs
122 || $class->error("failed to create template provider: ",
123 $PROVIDER->error);
124}
125
126
127#------------------------------------------------------------------------
128# plugins(\%params)
129#
130# Instantiate a new plugins provider object (default: Template::Plugins).
131# Returns an object reference or undef on error, as above.
132#------------------------------------------------------------------------
133
134
# spent 1.87ms (40µs+1.83) within Template::Config::plugins which was called: # once (40µs+1.83ms) by Template::Context::_init at line 837 of Template/Context.pm
sub plugins {
1351700ns my $class = shift;
13612µs my $params = defined($_[0]) && ref($_[0]) eq 'HASH'
137 ? shift : { @_ };
138
13912µs11.75ms return undef unless $class->load($PLUGINS);
# spent 1.75ms making 1 call to Template::Config::load
140125µs10s return $PLUGINS->new($params)
# spent 77µs making 1 call to Template::Base::new, recursion: max depth 3, sum of overlapping time 77µs
141 || $class->error("failed to create plugin provider: ",
142 $PLUGINS->error);
143}
144
145
146#------------------------------------------------------------------------
147# filters(\%params)
148#
149# Instantiate a new filters provider object (default: Template::Filters).
150# Returns an object reference or undef on error, as above.
151#------------------------------------------------------------------------
152
153
# spent 4.14ms (42µs+4.10) within Template::Config::filters which was called: # once (42µs+4.10ms) by Template::Context::_init at line 837 of Template/Context.pm
sub filters {
15411µs my $class = shift;
15512µs my $params = defined($_[0]) && ref($_[0]) eq 'HASH'
156 ? shift : { @_ };
157
15813µs14.04ms return undef unless $class->load($FILTERS);
# spent 4.04ms making 1 call to Template::Config::load
159121µs10s return $FILTERS->new($params)
# spent 54µs making 1 call to Template::Base::new, recursion: max depth 3, sum of overlapping time 54µs
160 || $class->error("failed to create filter provider: ",
161 $FILTERS->error);
162}
163
164
165#------------------------------------------------------------------------
166# iterator(\@list)
167#
168# Instantiate a new Template::Iterator object (default: Template::Iterator).
169# Returns an object reference or undef on error, as above.
170#------------------------------------------------------------------------
171
172
# spent 2.73ms (242µs+2.49) within Template::Config::iterator which was called 12 times, avg 228µs/call: # 5 times (87µs+250µs) by Template::Document::__ANON__[/usr/share/koha/opac/htdocs/opac-tmpl/prog/en-NZ/includes/opac-facets.inc:32] at line 16 of /usr/share/koha/opac/htdocs/opac-tmpl/prog/en-NZ/includes/opac-facets.inc, avg 67µs/call # 2 times (36µs+88µs) by Template::Document::__ANON__[/usr/share/koha/opac/htdocs/opac-tmpl/prog/en-NZ/includes/page-numbers.inc:31] at line 10 of /usr/share/koha/opac/htdocs/opac-tmpl/prog/en-NZ/includes/page-numbers.inc, avg 62µs/call # once (50µs+1.78ms) by Template::Document::__ANON__[/usr/share/koha/opac/htdocs/opac-tmpl/prog/en-NZ/includes/masthead.inc:111] at line 76 of /usr/share/koha/opac/htdocs/opac-tmpl/prog/en-NZ/includes/masthead.inc # once (31µs+229µs) by Template::Document::__ANON__[/usr/share/koha/opac/htdocs/opac-tmpl/prog/en-NZ/includes/opac-facets.inc:32] at line 18 of /usr/share/koha/opac/htdocs/opac-tmpl/prog/en-NZ/includes/opac-facets.inc # once (10µs+77µs) by Template::Document::__ANON__[/usr/share/koha/opac/htdocs/opac-tmpl/prog/en-NZ/modules/opac-results.tt:541] at line 389 of /usr/share/koha/opac/htdocs/opac-tmpl/prog/en-NZ/modules/opac-results.tt # once (19µs+45µs) by Template::Document::__ANON__[/usr/share/koha/opac/htdocs/opac-tmpl/prog/en-NZ/modules/opac-results.tt:541] at line 518 of /usr/share/koha/opac/htdocs/opac-tmpl/prog/en-NZ/modules/opac-results.tt # once (8µs+21µs) by Template::Document::__ANON__[/usr/share/koha/opac/htdocs/opac-tmpl/prog/en-NZ/modules/opac-results.tt:541] at line 390 of /usr/share/koha/opac/htdocs/opac-tmpl/prog/en-NZ/modules/opac-results.tt
sub iterator {
1731218µs my $class = shift;
1741237µs my $list = shift;
175
1761254µs122.01ms return undef unless $class->load($ITERATOR);
# spent 2.01ms making 12 calls to Template::Config::load, avg 168µs/call
17712161µs12482µs return $ITERATOR->new($list, @_)
# spent 482µs making 12 calls to Template::Iterator::new, avg 40µs/call
178 || $class->error("failed to create iterator: ", $ITERATOR->error);
179}
180
181
182#------------------------------------------------------------------------
183# stash(\%vars)
184#
185# Instantiate a new template variable stash object (default:
186# Template::Stash). Returns object or undef, as above.
187#------------------------------------------------------------------------
188
189
# spent 12.0ms (32µs+12.0) within Template::Config::stash which was called: # once (32µs+12.0ms) by Template::Context::_init at line 863 of Template/Context.pm
sub stash {
1901900ns my $class = shift;
19112µs my $params = defined($_[0]) && ref($_[0]) eq 'HASH'
192 ? shift : { @_ };
193
19413µs112.0ms return undef unless $class->load($STASH);
# spent 12.0ms making 1 call to Template::Config::load
195119µs123µs return $STASH->new($params)
# spent 23µs making 1 call to Template::Stash::new
196 || $class->error("failed to create stash: ", $STASH->error);
197}
198
199
200#------------------------------------------------------------------------
201# context(\%params)
202#
203# Instantiate a new template context object (default: Template::Context).
204# Returns object or undef, as above.
205#------------------------------------------------------------------------
206
207
# spent 23.3ms (53µs+23.2) within Template::Config::context which was called: # once (53µs+23.2ms) by Template::Service::_init at line 177 of Template/Service.pm
sub context {
20811µs my $class = shift;
20912µs my $params = defined($_[0]) && ref($_[0]) eq 'HASH'
210 ? shift : { @_ };
211
21213µs14.88ms return undef unless $class->load($CONTEXT);
# spent 4.88ms making 1 call to Template::Config::load
213134µs10s return $CONTEXT->new($params)
# spent 18.3ms making 1 call to Template::Base::new, recursion: max depth 2, sum of overlapping time 18.3ms
214 || $class->error("failed to create context: ", $CONTEXT->error);
215}
216
217
218#------------------------------------------------------------------------
219# service(\%params)
220#
221# Instantiate a new template context object (default: Template::Service).
222# Returns object or undef, as above.
223#------------------------------------------------------------------------
224
225
# spent 23.4ms (25µs+23.4) within Template::Config::service which was called: # once (25µs+23.4ms) by Template::_init at line 138 of Template.pm
sub service {
2261700ns my $class = shift;
22712µs my $params = defined($_[0]) && ref($_[0]) eq 'HASH'
228 ? shift : { @_ };
229
23014µs129µs return undef unless $class->load($SERVICE);
# spent 29µs making 1 call to Template::Config::load
231119µs10s return $SERVICE->new($params)
# spent 23.4ms making 1 call to Template::Base::new, recursion: max depth 1, sum of overlapping time 23.4ms
232 || $class->error("failed to create context: ", $SERVICE->error);
233}
234
235
236#------------------------------------------------------------------------
237# constants(\%params)
238#
239# Instantiate a new namespace handler for compile time constant folding
240# (default: Template::Namespace::Constants).
241# Returns object or undef, as above.
242#------------------------------------------------------------------------
243
244sub constants {
245 my $class = shift;
246 my $params = defined($_[0]) && ref($_[0]) eq 'HASH'
247 ? shift : { @_ };
248
249 return undef unless $class->load($CONSTANTS);
250 return $CONSTANTS->new($params)
251 || $class->error("failed to create constants namespace: ",
252 $CONSTANTS->error);
253}
254
255
256#------------------------------------------------------------------------
257# instdir($dir)
258#
259# Returns the root installation directory appended with any local
260# component directory passed as an argument.
261#------------------------------------------------------------------------
262
263sub instdir {
264 my ($class, $dir) = @_;
265 my $inst = $INSTDIR
266 || return $class->error("no installation directory");
267 $inst =~ s[/$][]g;
268 $inst .= "/$dir" if $dir;
269 return $inst;
270}
271
272
273#========================================================================
274# This should probably be moved somewhere else in the long term, but for
275# now it ensures that Template::TieString is available even if the
276# Template::Directive module hasn't been loaded, as is the case when
277# using compiled templates and Template::Parser hasn't yet been loaded
278# on demand.
279#========================================================================
280
281#------------------------------------------------------------------------
282# simple package for tying $output variable to STDOUT, used by perl()
283#------------------------------------------------------------------------
284
285package Template::TieString;
286
287sub TIEHANDLE {
288 my ($class, $textref) = @_;
289 bless $textref, $class;
290}
291sub PRINT {
292 my $self = shift;
293 $$self .= join('', @_);
294}
295
- -
29818µs1;
299
300__END__
 
# spent 182µs within Template::Config::CORE:subst which was called 19 times, avg 10µs/call: # 19 times (182µs+0s) by Template::Config::load at line 80, avg 10µs/call
sub Template::Config::CORE:subst; # opcode