← Index
NYTProf Performance Profile   « line view »
For ./view
  Run on Fri Jul 31 18:42:36 2015
Reported on Fri Jul 31 18:48:13 2015

Filename/usr/share/perl5/vendor_perl/constant.pm
StatementsExecuted 2391 statements in 5.02ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
9797542.81ms3.07msconstant::::importconstant::import
11134µs34µsconstant::::BEGIN@24constant::BEGIN@24
11129µs29µsconstant::::BEGIN@2constant::BEGIN@2
42218µs18µsconstant::::__ANON__[:144]constant::__ANON__[:144]
11116µs37µsconstant::::BEGIN@28constant::BEGIN@28
11115µs35µsconstant::::BEGIN@116constant::BEGIN@116
11115µs55µsconstant::::BEGIN@6constant::BEGIN@6
11114µs49µsconstant::::BEGIN@3constant::BEGIN@3
11114µs136µsconstant::::BEGIN@4constant::BEGIN@4
11114µs33µsconstant::::BEGIN@54constant::BEGIN@54
0000s0sconstant::::__ANON__[:140]constant::__ANON__[:140]
0000s0sconstant::::__ANON__[:146]constant::__ANON__[:146]
0000s0sconstant::::__ANON__[:30]constant::__ANON__[:30]
0000s0sconstant::::__ANON__[:33]constant::__ANON__[:33]
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package constant;
2284µs129µs
# spent 29µs within constant::BEGIN@2 which was called: # once (29µs+0s) by Assert::BEGIN@16 at line 2
use 5.008;
# spent 29µs making 1 call to constant::BEGIN@2
3247µs283µs
# spent 49µs (14+34) within constant::BEGIN@3 which was called: # once (14µs+34µs) by Assert::BEGIN@16 at line 3
use strict;
# spent 49µs making 1 call to constant::BEGIN@3 # spent 34µs making 1 call to strict::import
4252µs2258µs
# spent 136µs (14+122) within constant::BEGIN@4 which was called: # once (14µs+122µs) by Assert::BEGIN@16 at line 4
use warnings::register;
# spent 136µs making 1 call to constant::BEGIN@4 # spent 122µs making 1 call to warnings::register::import
5
62232µs294µs
# spent 55µs (15+40) within constant::BEGIN@6 which was called: # once (15µs+40µs) by Assert::BEGIN@16 at line 6
use vars qw($VERSION %declared);
# spent 55µs making 1 call to constant::BEGIN@6 # spent 40µs making 1 call to vars::import
711µs$VERSION = '1.27';
8
9#=======================================================================
10
11# Some names are evil choices.
12111µsmy %keywords = map +($_, 1), qw{ BEGIN INIT CHECK END DESTROY AUTOLOAD };
1313µs$keywords{UNITCHECK}++ if $] > 5.009;
14
15110µsmy %forced_into_main = map +($_, 1),
16 qw{ STDIN STDOUT STDERR ARGV ARGVOUT ENV INC SIG };
17
18111µsmy %forbidden = (%keywords, %forced_into_main);
19
20110µsmy $normal_constant_name = qr/^_?[^\W_0-9]\w*\z/;
2112µsmy $tolerable = qr/^[A-Za-z_]\w*\z/;
2211µsmy $boolean = qr/^[01]?\z/;
23
24
# spent 34µs within constant::BEGIN@24 which was called: # once (34µs+0s) by Assert::BEGIN@16 at line 34
BEGIN {
25 # We'd like to do use constant _CAN_PCS => $] > 5.009002
26 # but that's a bit tricky before we load the constant module :-)
27 # By doing this, we save 1 run time check for *every* call to import.
282141µs258µs
# spent 37µs (16+21) within constant::BEGIN@28 which was called: # once (16µs+21µs) by Assert::BEGIN@16 at line 28
no strict 'refs';
# spent 37µs making 1 call to constant::BEGIN@28 # spent 21µs making 1 call to strict::unimport
2912µs my $const = $] > 5.009002;
30118µs *_CAN_PCS = sub () {$const};
31
3211µs my $downgrade = $] < 5.015004; # && $] >= 5.008
33114µs *_DOWNGRADE = sub () { $downgrade };
341112µs134µs}
# spent 34µs making 1 call to constant::BEGIN@24
35
36#=======================================================================
37# import() - import symbols into user's namespace
38#
39# What we actually do is define a function in the caller's namespace
40# which returns the value. The function we create will normally
41# be inlined as a constant, thereby avoiding further sub calling
42# overhead.
43#=======================================================================
44
# spent 3.07ms (2.81+253µs) within constant::import which was called 97 times, avg 32µs/call: # once (56µs+9µs) by Assert::BEGIN@16 at line 16 of /var/www/foswikidev/core/lib/Assert.pm # once (53µs+4µs) by Foswiki::Infix::Node::BEGIN@29 at line 30 of /var/www/foswikidev/core/lib/Foswiki/Infix/Node.pm # once (43µs+4µs) by CGI::Util::BEGIN@10 at line 10 of CGI/Util.pm # once (43µs+4µs) by Foswiki::Query::HoistREs::BEGIN@58 at line 58 of /var/www/foswikidev/core/lib/Foswiki/Query/HoistREs.pm # once (41µs+4µs) by MultipartBuffer::BEGIN@3908 at line 3908 of CGI.pm # once (39µs+4µs) by CGI::BEGIN@33 at line 33 of CGI.pm # once (38µs+4µs) by Foswiki::Contrib::JsonRpcContrib::Request::BEGIN@28 at line 28 of /var/www/foswikidev/core/lib/Foswiki/Contrib/JsonRpcContrib/Request.pm # once (38µs+4µs) by Encode::Alias::BEGIN@6 at line 6 of Encode/Alias.pm # once (38µs+3µs) by JSON::PP::BEGIN@21 at line 21 of JSON/PP.pm # once (37µs+3µs) by Encode::BEGIN@8 at line 8 of Encode.pm # once (34µs+4µs) by Foswiki::Plugins::UpdatesPlugin::BEGIN@29 at line 29 of /var/www/foswikidev/core/lib/Foswiki/Plugins/UpdatesPlugin.pm # once (34µs+4µs) by Foswiki::Configure::Item::BEGIN@33 at line 33 of /var/www/foswikidev/core/lib/Foswiki/Configure/Item.pm # once (34µs+3µs) by Foswiki::Configure::Reporter::BEGIN@13 at line 13 of /var/www/foswikidev/core/lib/Foswiki/Configure/Reporter.pm # once (33µs+3µs) by Foswiki::Configure::Load::BEGIN@29 at line 29 of /var/www/foswikidev/core/lib/Foswiki/Configure/Load.pm # once (33µs+4µs) by Foswiki::Render::BEGIN@70 at line 70 of /var/www/foswikidev/core/lib/Foswiki/Render.pm # once (33µs+3µs) by JSON::PP::IncrParser::BEGIN@1422 at line 1422 of JSON/PP.pm # once (33µs+2µs) by JSON::PP::IncrParser::BEGIN@1426 at line 1426 of JSON/PP.pm # once (33µs+2µs) by JSON::PP::IncrParser::BEGIN@1425 at line 1425 of JSON/PP.pm # once (32µs+3µs) by Foswiki::Contrib::JsonRpcContrib::Server::BEGIN@28 at line 28 of /var/www/foswikidev/core/lib/Foswiki/Contrib/JsonRpcContrib/Server.pm # once (32µs+3µs) by Foswiki::Meta::BEGIN@132 at line 132 of /var/www/foswikidev/core/lib/Foswiki/Meta.pm # once (32µs+3µs) by Data::Dumper::BEGIN@271 at line 271 of Data/Dumper.pm # once (32µs+3µs) by JSON::PP::IncrParser::BEGIN@1421 at line 1421 of JSON/PP.pm # once (31µs+3µs) by Foswiki::Contrib::MailerContrib::Subscription::BEGIN@20 at line 20 of /var/www/foswikidev/core/lib/Foswiki/Contrib/MailerContrib/Subscription.pm # once (31µs+3µs) by Foswiki::Configure::Query::BEGIN@16 at line 16 of /var/www/foswikidev/core/lib/Foswiki/Configure/Query.pm # once (31µs+3µs) by Foswiki::Iterator::BEGIN@26 at line 26 of /var/www/foswikidev/core/lib/Foswiki/Iterator.pm # once (31µs+3µs) by Foswiki::Iterator::EventIterator::BEGIN@29 at line 29 of /var/www/foswikidev/core/lib/Foswiki/Iterator/EventIterator.pm # once (30µs+4µs) by Foswiki::Infix::Node::BEGIN@26 at line 26 of /var/www/foswikidev/core/lib/Foswiki/Infix/Node.pm # once (30µs+3µs) by Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@9 at line 9 of /var/www/foswikidev/core/lib/Foswiki/Plugins/JQueryPlugin/Plugin.pm # once (29µs+3µs) by Foswiki::Store::Interfaces::QueryAlgorithm::BEGIN@30 at line 30 of /var/www/foswikidev/core/lib/Foswiki/Store/Interfaces/QueryAlgorithm.pm # once (30µs+3µs) by Foswiki::Templates::BEGIN@49 at line 49 of /var/www/foswikidev/core/lib/Foswiki/Templates.pm # once (30µs+3µs) by Foswiki::MetaCache::BEGIN@29 at line 29 of /var/www/foswikidev/core/lib/Foswiki/MetaCache.pm # once (32µs+0s) by Foswiki::Query::Parser::BEGIN@100 at line 100 of /var/www/foswikidev/core/lib/Foswiki/Query/Parser.pm # once (29µs+3µs) by Foswiki::Plugins::ConfigurePlugin::BEGIN@51 at line 51 of /var/www/foswikidev/core/lib/Foswiki/Plugins/ConfigurePlugin.pm # once (29µs+3µs) by Foswiki::Configure::Query::BEGIN@17 at line 17 of /var/www/foswikidev/core/lib/Foswiki/Configure/Query.pm # once (29µs+3µs) by Foswiki::Contrib::MailerContrib::WebNotify::BEGIN@25 at line 25 of /var/www/foswikidev/core/lib/Foswiki/Contrib/MailerContrib/WebNotify.pm # once (29µs+2µs) by Foswiki::LoginManager::BEGIN@76 at line 76 of /var/www/foswikidev/core/lib/Foswiki/LoginManager.pm # once (29µs+3µs) by Foswiki::Infix::Parser::BEGIN@36 at line 36 of /var/www/foswikidev/core/lib/Foswiki/Infix/Parser.pm # once (28µs+3µs) by Foswiki::Store::QueryAlgorithms::BruteForce::BEGIN@53 at line 53 of /var/www/foswikidev/core/lib/Foswiki/Store/QueryAlgorithms/BruteForce.pm # once (28µs+3µs) by Foswiki::Plugins::RenderPlugin::BEGIN@30 at line 30 of /var/www/foswikidev/core/lib/Foswiki/Plugins/RenderPlugin.pm # once (28µs+2µs) by JSON::PP::BEGIN@22 at line 22 of JSON/PP.pm # once (28µs+3µs) by Foswiki::Configure::Checker::BEGIN@38 at line 38 of /var/www/foswikidev/core/lib/Foswiki/Configure/Checker.pm # once (28µs+3µs) by Foswiki::Store::SearchAlgorithms::Forking::BEGIN@34 at line 34 of /var/www/foswikidev/core/lib/Foswiki/Store/SearchAlgorithms/Forking.pm # once (28µs+3µs) by Foswiki::Configure::LoadSpec::BEGIN@72 at line 72 of /var/www/foswikidev/core/lib/Foswiki/Configure/LoadSpec.pm # once (28µs+3µs) by Foswiki::Plugins::FindElsewherePlugin::Core::BEGIN@17 at line 17 of /var/www/foswikidev/core/lib/Foswiki/Plugins/FindElsewherePlugin/Core.pm # once (28µs+2µs) by JSON::PP::IncrParser::BEGIN@1423 at line 1423 of JSON/PP.pm # once (28µs+3µs) by Foswiki::Validation::BEGIN@61 at line 61 of /var/www/foswikidev/core/lib/Foswiki/Validation.pm # once (28µs+2µs) by Foswiki::Plugins::NatEditPlugin::BEGIN@41 at line 41 of /var/www/foswikidev/core/lib/Foswiki/Plugins/NatEditPlugin.pm # once (28µs+2µs) by Foswiki::Search::BEGIN@29 at line 29 of /var/www/foswikidev/core/lib/Foswiki/Search.pm # once (27µs+3µs) by Foswiki::Plugins::WysiwygPlugin::BEGIN@45 at line 45 of /var/www/foswikidev/core/lib/Foswiki/Plugins/WysiwygPlugin.pm # once (27µs+3µs) by Foswiki::Configure::Section::BEGIN@23 at line 23 of /var/www/foswikidev/core/lib/Foswiki/Configure/Section.pm # once (27µs+2µs) by JSON::PP::BEGIN@26 at line 26 of JSON/PP.pm # once (28µs+2µs) by File::Temp::BEGIN@94 at line 94 of File/Temp.pm # once (27µs+3µs) by Foswiki::Configure::Value::BEGIN@68 at line 68 of /var/www/foswikidev/core/lib/Foswiki/Configure/Value.pm # once (27µs+2µs) by JSON::PP::BEGIN@23 at line 23 of JSON/PP.pm # once (27µs+3µs) by Foswiki::Logger::PlainFile::BEGIN@64 at line 64 of /var/www/foswikidev/core/lib/Foswiki/Logger/PlainFile.pm # once (27µs+3µs) by File::Temp::BEGIN@83 at line 83 of File/Temp.pm # once (27µs+2µs) by Foswiki::Access::TopicACLAccess::BEGIN@16 at line 16 of /var/www/foswikidev/core/lib/Foswiki/Access/TopicACLAccess.pm # once (27µs+2µs) by JSON::PP::BEGIN@41 at line 41 of JSON/PP.pm # once (27µs+2µs) by JSON::PP::BEGIN@32 at line 32 of JSON/PP.pm # once (27µs+2µs) by JSON::PP::BEGIN@30 at line 30 of JSON/PP.pm # once (27µs+2µs) by JSON::PP::BEGIN@28 at line 28 of JSON/PP.pm # once (29µs+0s) by Foswiki::PageCache::BEGIN@74 at line 74 of /var/www/foswikidev/core/lib/Foswiki/PageCache.pm # once (26µs+3µs) by Foswiki::Contrib::JsonRpcContrib::Response::BEGIN@25 at line 25 of /var/www/foswikidev/core/lib/Foswiki/Contrib/JsonRpcContrib/Response.pm # once (27µs+2µs) by Foswiki::UI::BEGIN@181 at line 181 of /var/www/foswikidev/core/lib/Foswiki/UI.pm # once (26µs+2µs) by JSON::PP::BEGIN@31 at line 31 of JSON/PP.pm # once (26µs+2µs) by JSON::PP::BEGIN@27 at line 27 of JSON/PP.pm # once (26µs+2µs) by Foswiki::Sandbox::BEGIN@50 at line 50 of /var/www/foswikidev/core/lib/Foswiki/Sandbox.pm # once (26µs+2µs) by JSON::PP::BEGIN@29 at line 29 of JSON/PP.pm # once (26µs+2µs) by JSON::PP::BEGIN@25 at line 25 of JSON/PP.pm # once (26µs+2µs) by JSON::PP::BEGIN@43 at line 43 of JSON/PP.pm # once (26µs+2µs) by Foswiki::Address::BEGIN@71 at line 71 of /var/www/foswikidev/core/lib/Foswiki/Address.pm # once (26µs+2µs) by JSON::PP::BEGIN@34 at line 34 of JSON/PP.pm # once (26µs+2µs) by JSON::PP::IncrParser::BEGIN@1424 at line 1424 of JSON/PP.pm # once (26µs+2µs) by Time::Local::BEGIN@27 at line 27 of Time/Local.pm # once (26µs+2µs) by JSON::PP::BEGIN@37 at line 37 of JSON/PP.pm # once (26µs+2µs) by JSON::PP::BEGIN@24 at line 24 of JSON/PP.pm # once (26µs+2µs) by Foswiki::Contrib::MailerContrib::Subscription::BEGIN@23 at line 23 of /var/www/foswikidev/core/lib/Foswiki/Contrib/MailerContrib/Subscription.pm # once (25µs+2µs) by Foswiki::Query::Node::BEGIN@41 at line 41 of /var/www/foswikidev/core/lib/Foswiki/Query/Node.pm # once (25µs+2µs) by JSON::PP::BEGIN@38 at line 38 of JSON/PP.pm # once (25µs+2µs) by JSON::PP::BEGIN@39 at line 39 of JSON/PP.pm # once (25µs+2µs) by Foswiki::Access::BEGIN@16 at line 16 of /var/www/foswikidev/core/lib/Foswiki/Access.pm # once (25µs+2µs) by JSON::PP::BEGIN@36 at line 36 of JSON/PP.pm # once (25µs+2µs) by JSON::PP::BEGIN@35 at line 35 of JSON/PP.pm # once (25µs+2µs) by Foswiki::LoginManager::BEGIN@78 at line 78 of /var/www/foswikidev/core/lib/Foswiki/LoginManager.pm # once (26µs+0s) by Foswiki::If::Parser::BEGIN@40 at line 40 of /var/www/foswikidev/core/lib/Foswiki/If/Parser.pm # once (24µs+2µs) by Foswiki::Address::BEGIN@76 at line 76 of /var/www/foswikidev/core/lib/Foswiki/Address.pm # once (22µs+2µs) by Foswiki::Query::Node::BEGIN@42 at line 42 of /var/www/foswikidev/core/lib/Foswiki/Query/Node.pm # once (22µs+2µs) by Time::Local::BEGIN@28 at line 28 of Time/Local.pm # once (22µs+2µs) by Foswiki::Address::BEGIN@75 at line 75 of /var/www/foswikidev/core/lib/Foswiki/Address.pm # once (22µs+2µs) by File::Temp::BEGIN@86 at line 86 of File/Temp.pm # once (22µs+2µs) by Foswiki::Address::BEGIN@72 at line 72 of /var/www/foswikidev/core/lib/Foswiki/Address.pm # once (21µs+2µs) by Foswiki::Address::BEGIN@73 at line 73 of /var/www/foswikidev/core/lib/Foswiki/Address.pm # once (21µs+2µs) by File::Temp::BEGIN@90 at line 90 of File/Temp.pm # once (21µs+2µs) by Time::Local::BEGIN@29 at line 29 of Time/Local.pm # once (21µs+2µs) by Foswiki::Address::BEGIN@74 at line 74 of /var/www/foswikidev/core/lib/Foswiki/Address.pm # once (21µs+2µs) by File::Temp::BEGIN@95 at line 95 of File/Temp.pm # once (20µs+2µs) by File::Temp::BEGIN@96 at line 96 of File/Temp.pm
sub import {
459752µs my $class = shift;
469741µs return unless @_; # Ignore 'use constant;'
479713µs my $constants;
489740µs my $multiple = ref $_[0];
4997236µs my $pkg = caller;
509715µs my $flush_mro;
519711µs my $symtab;
52
539737µs if (_CAN_PCS) {
542459µs252µs
# spent 33µs (14+19) within constant::BEGIN@54 which was called: # once (14µs+19µs) by Assert::BEGIN@16 at line 54
no strict 'refs';
# spent 33µs making 1 call to constant::BEGIN@54 # spent 19µs making 1 call to strict::unimport
5597121µs $symtab = \%{$pkg . '::'};
56 };
57
589733µs if ( $multiple ) {
5911µs if (ref $_[0] ne 'HASH') {
60 require Carp;
61 Carp::croak("Invalid reference type '".ref(shift)."' not 'HASH'");
62 }
631500ns $constants = shift;
64 } else {
659627µs unless (defined $_[0]) {
66 require Carp;
67 Carp::croak("Can't use undef as constant name");
68 }
6996138µs $constants->{+shift} = undef;
70 }
71
7297180µs foreach my $name ( keys %$constants ) {
73 # Normal constant name
74101462µs if ($name =~ $normal_constant_name and !$forbidden{$name}) {
75 # Everything is okay
76
77 # Name forced into main, but we're not in main. Fatal.
78 } elsif ($forced_into_main{$name} and $pkg ne 'main') {
79 require Carp;
80 Carp::croak("Constant name '$name' is forced into main::");
81
82 # Starts with double underscore. Fatal.
83 } elsif ($name =~ /^__/) {
84 require Carp;
85 Carp::croak("Constant name '$name' begins with '__'");
86
87 # Maybe the name is tolerable
88 } elsif ($name =~ $tolerable) {
89 # Then we'll warn only if you've asked for warnings
90 if (warnings::enabled()) {
91 if ($keywords{$name}) {
92 warnings::warn("Constant name '$name' is a Perl keyword");
93 } elsif ($forced_into_main{$name}) {
94 warnings::warn("Constant name '$name' is " .
95 "forced into package main::");
96 }
97 }
98
99 # Looks like a boolean
100 # use constant FRED == fred;
101 } elsif ($name =~ $boolean) {
102 require Carp;
103 if (@_) {
104 Carp::croak("Constant name '$name' is invalid");
105 } else {
106 Carp::croak("Constant name looks like boolean value");
107 }
108
109 } else {
110 # Must have bad characters
111 require Carp;
112 Carp::croak("Constant name '$name' has invalid characters");
113 }
114
115 {
116103581µs255µs
# spent 35µs (15+20) within constant::BEGIN@116 which was called: # once (15µs+20µs) by Assert::BEGIN@16 at line 116
no strict 'refs';
# spent 35µs making 1 call to constant::BEGIN@116 # spent 20µs making 1 call to strict::unimport
11710168µs my $full_name = "${pkg}::$name";
118101130µs $declared{$full_name}++;
11910172µs if ($multiple || @_ == 1) {
1209943µs my $scalar = $multiple ? $constants->{$name} : $_[0];
121
122 if (_DOWNGRADE) { # for 5.8 to 5.14
123 # Work around perl bug #31991: Sub names (actually glob
124 # names in general) ignore the UTF8 flag. So we have to
125 # turn it off to get the "right" symbol table entry.
126 utf8::is_utf8 $name and utf8::encode $name;
127 }
128
129 # The constant serves to optimise this entire block out on
130 # 5.8 and earlier.
1319995µs if (_CAN_PCS && $symtab && !exists $symtab->{$name}) {
132 # No typeglob yet, so we can use a reference as space-
133 # efficient proxy for a constant subroutine
134 # The check in Perl_ck_rvconst knows that inlinable
135 # constants from cv_const_sv are read only. So we have to:
13698438µs98109µs Internals::SvREADONLY($scalar, 1);
# spent 109µs making 98 calls to Internals::SvREADONLY, avg 1µs/call
1379872µs $symtab->{$name} = \$scalar;
1389835µs ++$flush_mro;
139 } else {
14018µs *$full_name = sub () { $scalar };
141 }
142 } elsif (@_) {
14326µs my @list = @_;
144633µs
# spent 18µs within constant::__ANON__[/usr/share/perl5/vendor_perl/constant.pm:144] which was called 4 times, avg 5µs/call: # 3 times (16µs+0s) by Foswiki::Query::Parser::new at line 110 of /var/www/foswikidev/core/lib/Foswiki/Query/Parser.pm, avg 5µs/call # once (2µs+0s) by Foswiki::If::Parser::new at line 47 of /var/www/foswikidev/core/lib/Foswiki/If/Parser.pm
*$full_name = sub () { @list };
145 } else {
146 *$full_name = sub () { };
147 }
148 }
149 }
150 # Flush the cache exactly once if we make any direct symbol table changes.
15197806µs94145µs mro::method_changed_in($pkg) if _CAN_PCS && $flush_mro;
# spent 145µs making 94 calls to mro::method_changed_in, avg 2µs/call
152}
153
154114µs1;
155
156__END__