← Index
NYTProf Performance Profile   « line view »
For rbm/rbm
  Run on Wed Feb 12 03:38:15 2020
Reported on Wed Feb 12 04:56:35 2020

Filename/usr/lib/x86_64-linux-gnu/perl5/5.28/Template.pm
StatementsExecuted 9579053 statements in 18.7s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
383161119.83s2134sTemplate::::processTemplate::process (recurses: max depth 40, inclusive time 38571s)
383161116.73s158sTemplate::::_initTemplate::_init
383161112.69s2.69sTemplate::::_outputTemplate::_output
1116.12ms8.69msTemplate::::BEGIN@29Template::BEGIN@29
1113.34ms3.55msTemplate::::BEGIN@32Template::BEGIN@32
1111.78ms3.12msTemplate::::BEGIN@30Template::BEGIN@30
1111.61ms1.86msTemplate::::BEGIN@27Template::BEGIN@27
11115µs55µsTemplate::::BEGIN@31Template::BEGIN@31
11113µs16µsTemplate::::BEGIN@22Template::BEGIN@22
11112µs12µsTemplate::::BEGIN@24Template::BEGIN@24
1118µs5.08msTemplate::::BEGIN@25Template::BEGIN@25
1117µs30µsTemplate::::BEGIN@33Template::BEGIN@33
1117µs26µsTemplate::::BEGIN@28Template::BEGIN@28
1116µs26µsTemplate::::BEGIN@23Template::BEGIN@23
3313µs3µsTemplate::::__ANON__Template::__ANON__ (xsub)
0000s0sTemplate::::contextTemplate::context
0000s0sTemplate::::serviceTemplate::service
0000s0sTemplate::::templateTemplate::template
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
4#
5# DESCRIPTION
6# Module implementing a simple, user-oriented front-end to the Template
7# Toolkit.
8#
9# AUTHOR
10# Andy Wardley <abw@wardley.org>
11#
12# COPYRIGHT
13# Copyright (C) 1996-2014 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;
21
22222µs219µs
# spent 16µs (13+3) within Template::BEGIN@22 which was called: # once (13µs+3µs) by RBM::BEGIN@9 at line 22
use strict;
# spent 16µs making 1 call to Template::BEGIN@22 # spent 3µs making 1 call to strict::import
23218µs247µs
# spent 26µs (6+21) within Template::BEGIN@23 which was called: # once (6µs+21µs) by RBM::BEGIN@9 at line 23
use warnings;
# spent 26µs making 1 call to Template::BEGIN@23 # spent 21µs making 1 call to warnings::import
24274µs112µs
# spent 12µs within Template::BEGIN@24 which was called: # once (12µs+0s) by RBM::BEGIN@9 at line 24
use 5.006;
# spent 12µs making 1 call to Template::BEGIN@24
25233µs210.1ms
# spent 5.08ms (8µs+5.07) within Template::BEGIN@25 which was called: # once (8µs+5.07ms) by RBM::BEGIN@9 at line 25
use base 'Template::Base';
# spent 5.08ms making 1 call to Template::BEGIN@25 # spent 5.07ms making 1 call to base::import
26
272710µs21.86ms
# spent 1.86ms (1.61+241µs) within Template::BEGIN@27 which was called: # once (1.61ms+241µs) by RBM::BEGIN@9 at line 27
use Template::Config;
# spent 1.86ms making 1 call to Template::BEGIN@27 # spent 1µs making 1 call to Template::__ANON__
28220µs246µs
# spent 26µs (7+19) within Template::BEGIN@28 which was called: # once (7µs+19µs) by RBM::BEGIN@9 at line 28
use Template::Constants;
# spent 26µs making 1 call to Template::BEGIN@28 # spent 19µs making 1 call to Exporter::import
292708µs28.69ms
# spent 8.69ms (6.12+2.57) within Template::BEGIN@29 which was called: # once (6.12ms+2.57ms) by RBM::BEGIN@9 at line 29
use Template::Provider;
# spent 8.69ms making 1 call to Template::BEGIN@29 # spent 900ns making 1 call to Template::__ANON__
302686µs23.12ms
# spent 3.12ms (1.78+1.34) within Template::BEGIN@30 which was called: # once (1.78ms+1.34ms) by RBM::BEGIN@9 at line 30
use Template::Service;
# spent 3.12ms making 1 call to Template::BEGIN@30 # spent 1µs making 1 call to Template::__ANON__
31275µs294µs
# spent 55µs (15+39) within Template::BEGIN@31 which was called: # once (15µs+39µs) by RBM::BEGIN@9 at line 31
use File::Basename;
# spent 55µs making 1 call to Template::BEGIN@31 # spent 39µs making 1 call to Exporter::import
322144µs23.59ms
# spent 3.55ms (3.34+218µs) within Template::BEGIN@32 which was called: # once (3.34ms+218µs) by RBM::BEGIN@9 at line 32
use File::Path;
# spent 3.55ms making 1 call to Template::BEGIN@32 # spent 39µs making 1 call to Exporter::import
332779µs253µs
# spent 30µs (7+23) within Template::BEGIN@33 which was called: # once (7µs+23µs) by RBM::BEGIN@9 at line 33
use Scalar::Util qw(blessed);
# spent 30µs making 1 call to Template::BEGIN@33 # spent 23µs making 1 call to Exporter::import
34
351400nsour $VERSION = '2.27';
361200nsour $ERROR = '';
371100nsour $DEBUG = 0;
381200nsour $BINMODE = 0 unless defined $BINMODE;
39our $AUTOLOAD;
40
41# preload all modules if we're running under mod_perl
421800nsTemplate::Config->preload() if $ENV{ MOD_PERL };
43
44
45#------------------------------------------------------------------------
46# process($input, \%replace, $output)
47#
48# Main entry point for the Template Toolkit. The Template module
49# delegates most of the processing effort to the underlying SERVICE
50# object, an instance of the Template::Service class.
51#------------------------------------------------------------------------
52
53
# spent 2134s (9.83+2124) within Template::process which was called 383161 times, avg 5.57ms/call: # 383161 times (9.83s+2124s) by RBM::process_template at line 661 of /root/tor-browser-build/rbm/lib/RBM.pm, avg 5.57ms/call
sub process {
54383161385ms my ($self, $template, $vars, $outstream, @opts) = @_;
55383161120ms my ($output, $error);
56383161823ms my $options = (@opts == 1) && ref($opts[0]) eq 'HASH'
57 ? shift(@opts) : { @opts };
58
59 $options->{ binmode } = $BINMODE
60383161332ms unless defined $options->{ binmode };
61
62 # we're using this for testing in t/output.t and t/filter.t so
63 # don't remove it if you don't want tests to fail...
64383161354ms $self->DEBUG("set binmode\n") if $DEBUG && $options->{ binmode };
65
663831611.72s3831612134s $output = $self->{ SERVICE }->process($template, $vars);
# spent 40692s making 383161 calls to Template::Service::process, avg 106ms/call, recursion: max depth 40, sum of overlapping time 38558s
67
68383161223ms if (defined $output) {
69383161192ms $outstream ||= $self->{ OUTPUT };
70383161219ms unless (ref $outstream) {
71 my $outpath = $self->{ OUTPUT_PATH };
72 $outstream = "$outpath/$outstream" if $outpath;
73 }
74
75 # send processed template to output stream, checking for error
763831611.26s3831612.69s return ($self->error($error))
# spent 2.69s making 383161 calls to Template::_output, avg 7µs/call
77 if ($error = &_output($outstream, \$output, $options));
78
793831612.44s return 1;
80 }
81 else {
82 return $self->error($self->{ SERVICE }->error);
83 }
84}
85
86
87#------------------------------------------------------------------------
88# service()
89#
90# Returns a reference to the internal SERVICE object which handles
91# all requests for this Template object
92#------------------------------------------------------------------------
93
94sub service {
95 my $self = shift;
96 return $self->{ SERVICE };
97}
98
99
100#------------------------------------------------------------------------
101# context()
102#
103# Returns a reference to the CONTEXT object within the SERVICE
104# object.
105#------------------------------------------------------------------------
106
107sub context {
108 my $self = shift;
109 return $self->{ SERVICE }->{ CONTEXT };
110}
111
112sub template {
113 shift->context->template(@_);
114}
115
116
117#========================================================================
118# -- PRIVATE METHODS --
119#========================================================================
120
121#------------------------------------------------------------------------
122# _init(\%config)
123#------------------------------------------------------------------------
124
# spent 158s (6.73+151) within Template::_init which was called 383161 times, avg 411µs/call: # 383161 times (6.73s+151s) by Template::Base::new at line 65 of Template/Base.pm, avg 411µs/call
sub _init {
125383161247ms my ($self, $config) = @_;
126
127 # convert any textual DEBUG args to numerical form
128383161382ms my $debug = $config->{ DEBUG };
129383161253ms $config->{ DEBUG } = Template::Constants::debug_flags($self, $debug)
130 || return if defined $debug && $debug !~ /^\d+$/;
131
132 # prepare a namespace handler for any CONSTANTS definition
133383161320ms if (my $constants = $config->{ CONSTANTS }) {
134 my $ns = $config->{ NAMESPACE } ||= { };
135 my $cns = $config->{ CONSTANTS_NAMESPACE } || 'constants';
136 $constants = Template::Config->constants($constants)
137 || return $self->error(Template::Config->error);
138 $ns->{ $cns } = $constants;
139 }
140
141 $self->{ SERVICE } = $config->{ SERVICE }
1423831612.12s383161151s || Template::Config->service($config)
# spent 151s making 383161 calls to Template::Config::service, avg 394µs/call
143 || return $self->error(Template::Config->error);
144
145383161961ms $self->{ OUTPUT } = $config->{ OUTPUT } || \*STDOUT;
146383161483ms $self->{ OUTPUT_PATH } = $config->{ OUTPUT_PATH };
147
1483831611.85s return $self;
149}
150
151
152#------------------------------------------------------------------------
153# _output($where, $text)
154#------------------------------------------------------------------------
155
156
# spent 2.69s within Template::_output which was called 383161 times, avg 7µs/call: # 383161 times (2.69s+0s) by Template::process at line 76, avg 7µs/call
sub _output {
157383161271ms my ($where, $textref, $options) = @_;
15838316188.0ms my $reftype;
159383161188ms my $error = 0;
160
161 # call a CODE reference
162383161959ms if (($reftype = ref($where)) eq 'CODE') {
163 &$where($$textref);
164 }
165 # print to a glob (such as \*STDOUT)
166 elsif ($reftype eq 'GLOB') {
167 print $where $$textref;
168 }
169 # append output to a SCALAR ref
170 elsif ($reftype eq 'SCALAR') {
171383161346ms $$where .= $$textref;
172 }
173 # push onto ARRAY ref
174 elsif ($reftype eq 'ARRAY') {
175 push @$where, $$textref;
176 }
177 # call the print() method on an object that implements the method
178 # (e.g. IO::Handle, Apache::Request, etc)
179 elsif (blessed($where) && $where->can('print')) {
180 $where->print($$textref);
181 }
182 # a simple string is taken as a filename
183 elsif (! $reftype) {
184 local *FP;
185 # make destination directory if it doesn't exist
186 my $dir = dirname($where);
187 eval { mkpath($dir) unless -d $dir; };
188 if ($@) {
189 # strip file name and line number from error raised by die()
190 ($error = $@) =~ s/ at \S+ line \d+\n?$//;
191 }
192 elsif (open(FP, ">$where")) {
193 # binmode option can be 1 or a specific layer, e.g. :utf8
194 my $bm = $options->{ binmode };
195 if ($bm && $bm eq 1) {
196 binmode FP;
197 }
198 elsif ($bm){
199 binmode FP, $bm;
200 }
201 print FP $$textref;
202 close FP;
203 }
204 else {
205 $error = "$where: $!";
206 }
207 }
208 # give up, we've done our best
209 else {
210 $error = "output_handler() cannot determine target type ($where)\n";
211 }
212
2133831612.19s return $error;
214}
215
216
21716µs1;
218
219__END__
 
# spent 3µs within Template::__ANON__ which was called 3 times, avg 1µs/call: # once (1µs+0s) by Template::BEGIN@27 at line 27 # once (1µs+0s) by Template::BEGIN@30 at line 30 # once (900ns+0s) by Template::BEGIN@29 at line 29
sub Template::__ANON__; # xsub