← 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/usr/lib/x86_64-linux-gnu/perl5/5.20/Template/Plugin.pm
StatementsExecuted 16 statements in 40µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
211175µs75µsTemplate::Plugin::::newTemplate::Plugin::new
161141µs41µsTemplate::Plugin::::loadTemplate::Plugin::load
11118µs25µsTemplate::Plugin::::BEGIN@23Template::Plugin::BEGIN@23
1119µs54µsTemplate::Plugin::::BEGIN@25Template::Plugin::BEGIN@25
1119µs13µsTemplate::Plugin::::BEGIN@24Template::Plugin::BEGIN@24
0000s0sTemplate::Plugin::::OLD_AUTOLOADTemplate::Plugin::OLD_AUTOLOAD
0000s0sTemplate::Plugin::::failTemplate::Plugin::fail
0000s0sTemplate::Plugin::::old_newTemplate::Plugin::old_new
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::Plugin
4#
5# DESCRIPTION
6#
7# Module defining a base class for a plugin object which can be loaded
8# and instantiated via the USE directive.
9#
10# AUTHOR
11# Andy Wardley <abw@wardley.org>
12#
13# COPYRIGHT
14# Copyright (C) 1996-2007 Andy Wardley. All Rights Reserved.
15#
16# This module is free software; you can redistribute it an/or
17# modify it under the same terms as Perl itself.
18#
19#============================================================================
20
21package Template::Plugin;
22
23232µs
# spent 25µs (18+7) within Template::Plugin::BEGIN@23 which was called: # once (18µs+7µs) by base::import at line 23
use strict;
# spent 25µs making 1 call to Template::Plugin::BEGIN@23 # spent 7µs making 1 call to strict::import
24218µs
# spent 13µs (9+4) within Template::Plugin::BEGIN@24 which was called: # once (9µs+4µs) by base::import at line 24
use warnings;
# spent 13µs making 1 call to Template::Plugin::BEGIN@24 # spent 4µs making 1 call to warnings::import
25254µs
# spent 54µs (9+45) within Template::Plugin::BEGIN@25 which was called: # once (9µs+45µs) by base::import at line 25
use base 'Template::Base';
# spent 54µs making 1 call to Template::Plugin::BEGIN@25 # spent 45µs making 1 call to base::import, recursion: max depth 1, sum of overlapping time 45µs
26
27our $VERSION = 2.70;
28our $DEBUG = 0 unless defined $DEBUG;
29our $ERROR = '';
30our $AUTOLOAD;
31
32
33#========================================================================
34# ----- CLASS METHODS -----
35#========================================================================
36
37#------------------------------------------------------------------------
38# load()
39#
40# Class method called when the plugin module is first loaded. It
41# returns the name of a class (by default, its own class) or a prototype
42# object which will be used to instantiate new objects. The new()
43# method is then called against the class name (class method) or
44# prototype object (object method) to create a new instances of the
45# object.
46#------------------------------------------------------------------------
47
48
# spent 41µs within Template::Plugin::load which was called 16 times, avg 3µs/call: # 16 times (41µs+0s) by Template::Plugins::_load at line 217 of Template/Plugins.pm, avg 3µs/call
sub load {
49413µs return $_[0];
50}
51
52
53#------------------------------------------------------------------------
54# new($context, $delegate, @params)
55#
56# Object constructor which is called by the Template::Context to
57# instantiate a new Plugin object. This base class constructor is
58# used as a general mechanism to load and delegate to other Perl
59# modules. The context is passed as the first parameter, followed by
60# a reference to a delegate object or the name of the module which
61# should be loaded and instantiated. Any additional parameters passed
62# to the USE directive are forwarded to the new() constructor.
63#
64# A plugin object is returned which has an AUTOLOAD method to delegate
65# requests to the underlying object.
66#------------------------------------------------------------------------
67
68
# spent 75µs within Template::Plugin::new which was called 21 times, avg 4µs/call: # 21 times (75µs+0s) by Template::Plugins::fetch at line 120 of Template/Plugins.pm, avg 4µs/call
sub new {
6963µs my $class = shift;
70624µs bless {
71 }, $class;
72}
73
74sub old_new {
75 my ($class, $context, $delclass, @params) = @_;
76 my ($delegate, $delmod);
77
78 return $class->error("no context passed to $class constructor\n")
79 unless defined $context;
80
81 if (ref $delclass) {
82 # $delclass contains a reference to a delegate object
83 $delegate = $delclass;
84 }
85 else {
86 # delclass is the name of a module to load and instantiate
87 ($delmod = $delclass) =~ s|::|/|g;
88
89 eval {
90 require "$delmod.pm";
91 $delegate = $delclass->new(@params)
92 || die "failed to instantiate $delclass object\n";
93 };
94 return $class->error($@) if $@;
95 }
96
97 bless {
98 _CONTEXT => $context,
99 _DELEGATE => $delegate,
100 _PARAMS => \@params,
101 }, $class;
102}
103
104
105#------------------------------------------------------------------------
106# fail($error)
107#
108# Version 1 error reporting function, now replaced by error() inherited
109# from Template::Base. Raises a "deprecated function" warning and then
110# calls error().
111#------------------------------------------------------------------------
112
113sub fail {
114 my $class = shift;
115 my ($pkg, $file, $line) = caller();
116 warn "Template::Plugin::fail() is deprecated at $file line $line. Please use error()\n";
117 $class->error(@_);
118}
119
120
121#========================================================================
122# ----- OBJECT METHODS -----
123#========================================================================
124
125#------------------------------------------------------------------------
126# AUTOLOAD
127#
128# General catch-all method which delegates all calls to the _DELEGATE
129# object.
130#------------------------------------------------------------------------
131
132sub OLD_AUTOLOAD {
133 my $self = shift;
134 my $method = $AUTOLOAD;
135
136 $method =~ s/.*:://;
137 return if $method eq 'DESTROY';
138
139 if (ref $self eq 'HASH') {
140 my $delegate = $self->{ _DELEGATE } || return;
141 return $delegate->$method(@_);
142 }
143 my ($pkg, $file, $line) = caller();
144# warn "no such '$method' method called on $self at $file line $line\n";
145 return undef;
146}
147
148
1491;
150
151__END__