Filename | /usr/lib/x86_64-linux-gnu/perl5/5.28/Template/Base.pm |
Statements | Executed 21457032 statements in 33.0s |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
2682127 | 7 | 3 | 34.2s | 172s | new (recurses: max depth 3, inclusive time 305s) | Template::Base::
1 | 1 | 1 | 1.91ms | 3.04ms | BEGIN@24 | Template::Base::
1 | 1 | 1 | 17µs | 20µs | BEGIN@22 | Template::Base::
1 | 1 | 1 | 9µs | 17µs | BEGIN@85 | Template::Base::
1 | 1 | 1 | 8µs | 24µs | BEGIN@44 | Template::Base::
1 | 1 | 1 | 6µs | 14µs | BEGIN@137 | Template::Base::
1 | 1 | 1 | 6µs | 35µs | BEGIN@45 | Template::Base::
1 | 1 | 1 | 6µs | 22µs | BEGIN@23 | Template::Base::
0 | 0 | 0 | 0s | 0s | _init | Template::Base::
0 | 0 | 0 | 0s | 0s | debug | Template::Base::
0 | 0 | 0 | 0s | 0s | error | Template::Base::
0 | 0 | 0 | 0s | 0s | module_version | Template::Base::
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 | |||||
20 | package Template::Base; | ||||
21 | |||||
22 | 2 | 23µs | 2 | 22µs | # spent 20µs (17+2) within Template::Base::BEGIN@22 which was called:
# once (17µs+2µs) by base::import at line 22 # spent 20µs making 1 call to Template::Base::BEGIN@22
# spent 2µs making 1 call to strict::import |
23 | 2 | 20µs | 2 | 38µs | # spent 22µs (6+16) within Template::Base::BEGIN@23 which was called:
# once (6µs+16µs) by base::import at line 23 # spent 22µs making 1 call to Template::Base::BEGIN@23
# spent 16µs making 1 call to warnings::import |
24 | 2 | 659µs | 2 | 3.06ms | # spent 3.04ms (1.91+1.12) within Template::Base::BEGIN@24 which was called:
# once (1.91ms+1.12ms) by base::import at line 24 # spent 3.04ms making 1 call to Template::Base::BEGIN@24
# spent 25µs making 1 call to Exporter::import |
25 | |||||
26 | 1 | 300ns | our $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 172s (34.2+138) within Template::Base::new which was called 2682127 times, avg 64µs/call:
# 383161 times (7.56s+158s) by RBM::process_template at line 632 of /root/tor-browser-build/rbm/lib/RBM.pm, avg 431µs/call
# 383161 times (5.43s+1.65s) by Template::Parser::new at line 188 of Template/Parser.pm, avg 18µs/call
# 383161 times (4.04s+-4.04s) by Template::Config::service at line 231 of Template/Config.pm, avg 0s/call
# 383161 times (4.25s+-4.25s) by Template::Config::filters at line 159 of Template/Config.pm, avg 0s/call
# 383161 times (3.88s+-3.88s) by Template::Config::plugins at line 140 of Template/Config.pm, avg 0s/call
# 383161 times (4.51s+-4.51s) by Template::Config::provider at line 121 of Template/Config.pm, avg 0s/call
# 383161 times (4.55s+-4.55s) by Template::Config::context at line 213 of Template/Config.pm, avg 0s/call | ||||
40 | 2682127 | 851ms | my $class = shift; | ||
41 | 2682127 | 526ms | my ($argnames, @args, $arg, $cfg); | ||
42 | # $class->error(''); # always clear package $ERROR var? | ||||
43 | |||||
44 | 2682129 | 917ms | 2 | 40µs | # spent 24µs (8+16) within Template::Base::BEGIN@44 which was called:
# once (8µs+16µs) by base::import at line 44 # spent 24µs making 1 call to Template::Base::BEGIN@44
# spent 16µs making 1 call to strict::unimport |
45 | 2 | 158µs | 2 | 64µs | # spent 35µs (6+29) within Template::Base::BEGIN@45 which was called:
# once (6µs+29µs) by base::import at line 45 # spent 35µs making 1 call to Template::Base::BEGIN@45
# spent 29µs making 1 call to warnings::unimport |
46 | 2682127 | 5.10s | $argnames = \@{"$class\::BASEARGS"} || [ ]; | ||
47 | } | ||||
48 | |||||
49 | # shift off all mandatory args, returning error if undefined or null | ||||
50 | 2682127 | 1.35s | 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 | 2682127 | 2.85s | $cfg = defined $_[0] && ref($_[0]) eq 'HASH' ? shift : { @_ }; | ||
58 | |||||
59 | my $self = bless { | ||||
60 | 2682127 | 3.76s | (map { ($_ => shift @args) } @$argnames), | ||
61 | _ERROR => '', | ||||
62 | DEBUG => 0, | ||||
63 | }, $class; | ||||
64 | |||||
65 | 2682127 | 17.6s | 2682127 | 443s | return $self->_init($cfg) ? $self : $class->error($self->error); # spent 158s making 383161 calls to Template::_init, avg 411µs/call
# spent 135s making 383161 calls to Template::Service::_init, avg 353µs/call
# spent 112s making 383161 calls to Template::Context::_init, avg 293µs/call
# spent 17.7s making 383161 calls to Template::Provider::_init, avg 46µs/call
# spent 15.8s making 383161 calls to Template::Plugins::_init, avg 41µs/call
# spent 2.71s making 383161 calls to Template::Filters::_init, avg 7µs/call
# spent 1.65s making 383161 calls to Template::Directive::_init, avg 4µs/call |
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 | # absence of parameters, the current error value is returned. | ||||
78 | #------------------------------------------------------------------------ | ||||
79 | |||||
80 | sub error { | ||||
81 | my $self = shift; | ||||
82 | my $errvar; | ||||
83 | |||||
84 | { | ||||
85 | 2 | 215µs | 2 | 25µs | # spent 17µs (9+8) within Template::Base::BEGIN@85 which was called:
# once (9µs+8µs) by base::import at line 85 # spent 17µs making 1 call to Template::Base::BEGIN@85
# spent 8µ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 | |||||
107 | sub _init { | ||||
108 | my ($self, $config) = @_; | ||||
109 | return $self; | ||||
110 | } | ||||
111 | |||||
112 | |||||
113 | sub 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 | |||||
134 | sub module_version { | ||||
135 | my $self = shift; | ||||
136 | my $class = ref $self || $self; | ||||
137 | 2 | 42µs | 2 | 22µs | # spent 14µs (6+8) within Template::Base::BEGIN@137 which was called:
# once (6µs+8µs) by base::import at line 137 # spent 14µs making 1 call to Template::Base::BEGIN@137
# spent 8µs making 1 call to strict::unimport |
138 | return ${"${class}::VERSION"}; | ||||
139 | } | ||||
140 | |||||
141 | |||||
142 | 1 | 3µs | 1; | ||
143 | |||||
144 | __END__ |