← 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:31:39 2016

Filename/usr/lib/x86_64-linux-gnu/perl5/5.20/Template/Plugin.pm
StatementsExecuted 27 statements in 682µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
61122µs22µsTemplate::Plugin::::newTemplate::Plugin::new
11117µs24µsTemplate::Plugin::::BEGIN@23Template::Plugin::BEGIN@23
11110µs58µsTemplate::Plugin::::BEGIN@25Template::Plugin::BEGIN@25
1119µs14µsTemplate::Plugin::::BEGIN@24Template::Plugin::BEGIN@24
4118µs8µsTemplate::Plugin::::loadTemplate::Plugin::load
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
23240µs231µs
# spent 24µs (17+7) within Template::Plugin::BEGIN@23 which was called: # once (17µs+7µs) by base::import at line 23
use strict;
# spent 24µs making 1 call to Template::Plugin::BEGIN@23 # spent 7µs making 1 call to strict::import
24238µs218µs
# spent 14µs (9+5) within Template::Plugin::BEGIN@24 which was called: # once (9µs+5µs) by base::import at line 24
use warnings;
# spent 14µs making 1 call to Template::Plugin::BEGIN@24 # spent 5µs making 1 call to warnings::import
252550µs258µs
# spent 58µs (10+48) within Template::Plugin::BEGIN@25 which was called: # once (10µs+48µs) by base::import at line 25
use base 'Template::Base';
# spent 58µs making 1 call to Template::Plugin::BEGIN@25 # spent 48µs making 1 call to base::import, recursion: max depth 1, sum of overlapping time 48µs
26
271400nsour $VERSION = 2.70;
281300nsour $DEBUG = 0 unless defined $DEBUG;
291300nsour $ERROR = '';
301100nsour $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 8µs within Template::Plugin::load which was called 4 times, avg 2µs/call: # 4 times (8µs+0s) by Template::Plugins::_load at line 217 of Template/Plugins.pm, avg 2µs/call
sub load {
49418µ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 22µs within Template::Plugin::new which was called 6 times, avg 4µs/call: # 6 times (22µs+0s) by Template::Plugins::fetch at line 120 of Template/Plugins.pm, avg 4µs/call
sub new {
6962µs my $class = shift;
70628µ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
14914µs1;
150
151__END__