← 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 11:58:52 2013
Reported on Tue Oct 15 12:01:17 2013

Filename/usr/lib/perl5/Template/Base.pm
StatementsExecuted 71 statements in 1.04ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1111.79ms3.49msTemplate::Base::::BEGIN@24Template::Base::BEGIN@24
662240µs19.9msTemplate::Base::::newTemplate::Base::new (recurses: max depth 3, inclusive time 35.0ms)
11120µs34µsTemplate::Base::::BEGIN@137Template::Base::BEGIN@137
11117µs21µsTemplate::Base::::BEGIN@22Template::Base::BEGIN@22
11115µs38µsTemplate::Base::::BEGIN@44Template::Base::BEGIN@44
11114µs30µsTemplate::Base::::BEGIN@85Template::Base::BEGIN@85
11113µs42µsTemplate::Base::::BEGIN@45Template::Base::BEGIN@45
1119µs22µsTemplate::Base::::BEGIN@23Template::Base::BEGIN@23
0000s0sTemplate::Base::::_initTemplate::Base::_init
0000s0sTemplate::Base::::debugTemplate::Base::debug
0000s0sTemplate::Base::::errorTemplate::Base::error
0000s0sTemplate::Base::::module_versionTemplate::Base::module_version
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::Base
4#
5# DESCRIPTION
6# Base class module implementing common functionality for various other
7# Template Toolkit modules.
8#
9# AUTHOR
10# Andy Wardley <abw@wardley.org>
11#
12# COPYRIGHT
13# Copyright (C) 1996-2007 Andy Wardley. All Rights Reserved.
14#
15# This module is free software; you can redistribute it and/or
16# modify it under the same terms as Perl itself.
17#
18#========================================================================
19
20package Template::Base;
21
22328µs225µs
# spent 21µs (17+4) within Template::Base::BEGIN@22 which was called: # once (17µs+4µs) by base::import at line 22
use strict;
# spent 21µs making 1 call to Template::Base::BEGIN@22 # spent 4µs making 1 call to strict::import
23325µs234µs
# spent 22µs (9+12) within Template::Base::BEGIN@23 which was called: # once (9µs+12µs) by base::import at line 23
use warnings;
# spent 22µs making 1 call to Template::Base::BEGIN@23 # spent 12µs making 1 call to warnings::import
243178µs23.53ms
# spent 3.49ms (1.79+1.70) within Template::Base::BEGIN@24 which was called: # once (1.79ms+1.70ms) by base::import at line 24
use Template::Constants;
# spent 3.49ms making 1 call to Template::Base::BEGIN@24 # spent 44µs making 1 call to Exporter::import
25
261500nsour $VERSION = 2.78;
27
28
29#------------------------------------------------------------------------
30# new(\%params)
31#
32# General purpose constructor method which expects a hash reference of
33# configuration parameters, or a list of name => value pairs which are
34# folded into a hash. Blesses a hash into an object and calls its
35# _init() method, passing the parameter hash reference. Returns a new
36# object derived from Template::Base, or undef on error.
37#------------------------------------------------------------------------
38
39
# spent 19.9ms (240µs+19.7) within Template::Base::new which was called 6 times, avg 3.32ms/call: # once (47µs+19.9ms) by C4::Templates::new at line 62 of /usr/share/koha/lib/C4/Templates.pm # once (54µs+-54µs) by Template::Config::filters at line 159 of Template/Config.pm # once (51µs+-51µs) by Template::Config::service at line 231 of Template/Config.pm # once (33µs+-33µs) by Template::Config::context at line 213 of Template/Config.pm # once (30µs+-30µs) by Template::Config::plugins at line 140 of Template/Config.pm # once (25µs+-25µs) by Template::Config::provider at line 121 of Template/Config.pm
sub new {
4042197µs my $class = shift;
41 my ($argnames, @args, $arg, $cfg);
42# $class->error(''); # always clear package $ERROR var?
43
44333µs260µs
# spent 38µs (15+23) within Template::Base::BEGIN@44 which was called: # once (15µs+23µs) by base::import at line 44
{ no strict 'refs';
# spent 38µs making 1 call to Template::Base::BEGIN@44 # spent 23µs making 1 call to strict::unimport
453250µs270µs
# spent 42µs (13+29) within Template::Base::BEGIN@45 which was called: # once (13µs+29µs) by base::import at line 45
no warnings 'once';
# spent 42µs making 1 call to Template::Base::BEGIN@45 # spent 29µs making 1 call to warnings::unimport
46631µs $argnames = \@{"$class\::BASEARGS"} || [ ];
47 }
48
49 # shift off all mandatory args, returning error if undefined or null
50 foreach $arg (@$argnames) {
51 return $class->error("no $arg specified")
52 unless ($cfg = shift);
53 push(@args, $cfg);
54 }
55
56 # fold all remaining args into a hash, or use provided hash ref
57 $cfg = defined $_[0] && ref($_[0]) eq 'HASH' ? shift : { @_ };
58
59 my $self = bless {
60 (map { ($_ => shift @args) } @$argnames),
61 _ERROR => '',
62 DEBUG => 0,
63 }, $class;
64
65654.7ms return $self->_init($cfg) ? $self : $class->error($self->error);
# spent 19.9ms making 1 call to Template::_init # spent 19.7ms making 1 call to Template::Service::_init # spent 15.1ms making 1 call to Template::Context::_init # spent 44µs making 1 call to Template::Provider::_init # spent 25µs making 1 call to Template::Plugins::_init # spent 16µs making 1 call to Template::Filters::_init
66}
67
68
69#------------------------------------------------------------------------
70# error()
71# error($msg, ...)
72#
73# May be called as a class or object method to set or retrieve the
74# package variable $ERROR (class method) or internal member
75# $self->{ _ERROR } (object method). The presence of parameters indicates
76# that the error value should be set. Undef is then returned. In the
77# abscence of parameters, the current error value is returned.
78#------------------------------------------------------------------------
79
80sub error {
81 my $self = shift;
82 my $errvar;
83
84 {
853237µs245µs
# spent 30µs (14+16) within Template::Base::BEGIN@85 which was called: # once (14µs+16µs) by base::import at line 85
no strict qw( refs );
# spent 30µs making 1 call to Template::Base::BEGIN@85 # spent 16µs making 1 call to strict::unimport
86 $errvar = ref $self ? \$self->{ _ERROR } : \${"$self\::ERROR"};
87 }
88 if (@_) {
89 $$errvar = ref($_[0]) ? shift : join('', @_);
90 return undef;
91 }
92 else {
93 return $$errvar;
94 }
95}
96
97
98#------------------------------------------------------------------------
99# _init()
100#
101# Initialisation method called by the new() constructor and passing a
102# reference to a hash array containing any configuration items specified
103# as constructor arguments. Should return $self on success or undef on
104# error, via a call to the error() method to set the error message.
105#------------------------------------------------------------------------
106
107sub _init {
108 my ($self, $config) = @_;
109 return $self;
110}
111
112
113sub debug {
114 my $self = shift;
115 my $msg = join('', @_);
116 my ($pkg, $file, $line) = caller();
117
118 unless ($msg =~ /\n$/) {
119 $msg .= ($self->{ DEBUG } & Template::Constants::DEBUG_CALLER)
120 ? " at $file line $line\n"
121 : "\n";
122 }
123
124 print STDERR "[$pkg] $msg";
125}
126
127
128#------------------------------------------------------------------------
129# module_version()
130#
131# Returns the current version number.
132#------------------------------------------------------------------------
133
134sub module_version {
135 my $self = shift;
136 my $class = ref $self || $self;
137356µs247µs
# spent 34µs (20+14) within Template::Base::BEGIN@137 which was called: # once (20µs+14µs) by base::import at line 137
no strict 'refs';
# spent 34µs making 1 call to Template::Base::BEGIN@137 # spent 14µs making 1 call to strict::unimport
138 return ${"${class}::VERSION"};
139}
140
141
14213µs1;
143
144__END__