← Index
NYTProf Performance Profile   « line view »
For ./view
  Run on Fri Jul 31 19:05:14 2015
Reported on Fri Jul 31 19:08:09 2015

Filename/usr/share/perl5/vendor_perl/constant.pm
StatementsExecuted 699 statements in 2.61ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
282820965µs1.06msconstant::::importconstant::import
11126µs26µsconstant::::BEGIN@2constant::BEGIN@2
11124µs24µsconstant::::BEGIN@24constant::BEGIN@24
11119µs54µsconstant::::BEGIN@6constant::BEGIN@6
11117µs36µsconstant::::BEGIN@3constant::BEGIN@3
11114µs31µsconstant::::BEGIN@116constant::BEGIN@116
11113µs31µsconstant::::BEGIN@28constant::BEGIN@28
11113µs122µsconstant::::BEGIN@4constant::BEGIN@4
11112µs29µsconstant::::BEGIN@54constant::BEGIN@54
0000s0sconstant::::__ANON__[:140]constant::__ANON__[:140]
0000s0sconstant::::__ANON__[:144]constant::__ANON__[:144]
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;
2273µs126µs
# spent 26µs within constant::BEGIN@2 which was called: # once (26µs+0s) by CGI::Util::BEGIN@10 at line 2
use 5.008;
# spent 26µs making 1 call to constant::BEGIN@2
3239µs256µs
# spent 36µs (17+20) within constant::BEGIN@3 which was called: # once (17µs+20µs) by CGI::Util::BEGIN@10 at line 3
use strict;
# spent 36µs making 1 call to constant::BEGIN@3 # spent 20µs making 1 call to strict::import
4256µs2231µs
# spent 122µs (13+109) within constant::BEGIN@4 which was called: # once (13µs+109µs) by CGI::Util::BEGIN@10 at line 4
use warnings::register;
# spent 122µs making 1 call to constant::BEGIN@4 # spent 109µs making 1 call to warnings::register::import
5
62205µs289µs
# spent 54µs (19+35) within constant::BEGIN@6 which was called: # once (19µs+35µs) by CGI::Util::BEGIN@10 at line 6
use vars qw($VERSION %declared);
# spent 54µs making 1 call to constant::BEGIN@6 # spent 35µs making 1 call to vars::import
71900ns$VERSION = '1.27';
8
9#=======================================================================
10
11# Some names are evil choices.
1219µsmy %keywords = map +($_, 1), qw{ BEGIN INIT CHECK END DESTROY AUTOLOAD };
1312µs$keywords{UNITCHECK}++ if $] > 5.009;
14
1518µsmy %forced_into_main = map +($_, 1),
16 qw{ STDIN STDOUT STDERR ARGV ARGVOUT ENV INC SIG };
17
18110µsmy %forbidden = (%keywords, %forced_into_main);
19
2019µ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 24µs within constant::BEGIN@24 which was called: # once (24µs+0s) by CGI::Util::BEGIN@10 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.
282122µs250µs
# spent 31µs (13+18) within constant::BEGIN@28 which was called: # once (13µs+18µs) by CGI::Util::BEGIN@10 at line 28
no strict 'refs';
# spent 31µs making 1 call to constant::BEGIN@28 # spent 18µs making 1 call to strict::unimport
2912µs my $const = $] > 5.009002;
30111µs *_CAN_PCS = sub () {$const};
31
3211µs my $downgrade = $] < 5.015004; # && $] >= 5.008
33112µs *_DOWNGRADE = sub () { $downgrade };
341118µs124µs}
# spent 24µ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 1.06ms (965µs+90µs) within constant::import which was called 28 times, avg 38µs/call: # once (68µs+5µs) by Data::Dumper::BEGIN@271 at line 271 of Data/Dumper.pm # once (62µs+6µs) by Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@9 at line 9 of /var/www/foswiki11/lib/Foswiki/Plugins/JQueryPlugin/Plugin.pm # once (59µs+5µs) by Foswiki::Render::BEGIN@81 at line 81 of /var/www/foswiki11/lib/Foswiki/Render.pm # once (54µs+4µs) by Foswiki::Logger::PlainFile::BEGIN@35 at line 35 of /var/www/foswiki11/lib/Foswiki/Logger/PlainFile.pm # once (51µs+5µs) by CGI::Util::BEGIN@10 at line 10 of CGI/Util.pm # once (52µs+4µs) by Foswiki::Templates::BEGIN@42 at line 42 of /var/www/foswiki11/lib/Foswiki/Templates.pm # once (40µs+4µs) by MultipartBuffer::BEGIN@3908 at line 3908 of CGI.pm # once (38µs+4µs) by Foswiki::MetaCache::BEGIN@31 at line 31 of /var/www/foswiki11/lib/Foswiki/MetaCache.pm # once (37µs+4µs) by CGI::BEGIN@33 at line 33 of CGI.pm # once (35µs+3µs) by File::Temp::BEGIN@83 at line 83 of File/Temp.pm # once (33µs+2µs) by Time::Local::BEGIN@27 at line 27 of Time/Local.pm # once (31µs+3µs) by Foswiki::Plugins::RenderPlugin::BEGIN@30 at line 30 of /var/www/foswiki11/lib/Foswiki/Plugins/RenderPlugin.pm # once (30µs+2µs) by Encode::BEGIN@8 at line 8 of Encode.pm # once (29µs+3µs) by Foswiki::Store::QueryAlgorithms::BruteForce::BEGIN@40 at line 40 of /var/www/foswiki11/lib/Foswiki/Store/QueryAlgorithms/BruteForce.pm # once (28µs+3µs) by Foswiki::Sandbox::BEGIN@43 at line 43 of /var/www/foswiki11/lib/Foswiki/Sandbox.pm # once (28µs+3µs) by Foswiki::Validation::BEGIN@54 at line 54 of /var/www/foswiki11/lib/Foswiki/Validation.pm # once (26µs+2µs) by Foswiki::Iterator::BEGIN@26 at line 26 of /var/www/foswiki11/lib/Foswiki/Iterator.pm # once (26µs+2µs) by Foswiki::UI::BEGIN@165 at line 165 of /var/www/foswiki11/lib/Foswiki/UI.pm # once (26µs+3µs) by Foswiki::Query::HoistREs::BEGIN@33 at line 33 of /var/www/foswiki11/lib/Foswiki/Query/HoistREs.pm # once (26µs+2µs) by Foswiki::LoginManager::BEGIN@68 at line 68 of /var/www/foswiki11/lib/Foswiki/LoginManager.pm # once (26µs+2µs) by Encode::Alias::BEGIN@6 at line 6 of Encode/Alias.pm # once (21µs+6µs) by File::Temp::BEGIN@96 at line 96 of File/Temp.pm # once (24µs+2µs) by File::Temp::BEGIN@95 at line 95 of File/Temp.pm # once (24µs+2µs) by Time::Local::BEGIN@28 at line 28 of Time/Local.pm # once (24µs+2µs) by File::Temp::BEGIN@86 at line 86 of File/Temp.pm # once (22µs+2µs) by File::Temp::BEGIN@90 at line 90 of File/Temp.pm # once (22µs+2µs) by File::Temp::BEGIN@94 at line 94 of File/Temp.pm # once (21µs+2µs) by Time::Local::BEGIN@29 at line 29 of Time/Local.pm
sub import {
452820µs my $class = shift;
462814µs return unless @_; # Ignore 'use constant;'
47285µs my $constants;
482821µs my $multiple = ref $_[0];
492875µs my $pkg = caller;
50283µs my $flush_mro;
51284µs my $symtab;
52
532811µs if (_CAN_PCS) {
542417µs246µs
# spent 29µs (12+17) within constant::BEGIN@54 which was called: # once (12µs+17µs) by CGI::Util::BEGIN@10 at line 54
no strict 'refs';
# spent 29µs making 1 call to constant::BEGIN@54 # spent 17µs making 1 call to strict::unimport
552842µs $symtab = \%{$pkg . '::'};
56 };
57
582812µs if ( $multiple ) {
59 if (ref $_[0] ne 'HASH') {
60 require Carp;
61 Carp::croak("Invalid reference type '".ref(shift)."' not 'HASH'");
62 }
63 $constants = shift;
64 } else {
652810µs unless (defined $_[0]) {
66 require Carp;
67 Carp::croak("Can't use undef as constant name");
68 }
692842µs $constants->{+shift} = undef;
70 }
71
722866µs foreach my $name ( keys %$constants ) {
73 # Normal constant name
7428160µ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 {
11630423µs248µs
# spent 31µs (14+17) within constant::BEGIN@116 which was called: # once (14µs+17µs) by CGI::Util::BEGIN@10 at line 116
no strict 'refs';
# spent 31µs making 1 call to constant::BEGIN@116 # spent 17µs making 1 call to strict::unimport
1172829µs my $full_name = "${pkg}::$name";
1182848µs $declared{$full_name}++;
1192825µs if ($multiple || @_ == 1) {
1202816µ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.
1312832µ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:
13628156µs2843µs Internals::SvREADONLY($scalar, 1);
# spent 43µs making 28 calls to Internals::SvREADONLY, avg 2µs/call
1372823µs $symtab->{$name} = \$scalar;
1382811µs ++$flush_mro;
139 } else {
140 *$full_name = sub () { $scalar };
141 }
142 } elsif (@_) {
143 my @list = @_;
144 *$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.
15128257µs2847µs mro::method_changed_in($pkg) if _CAN_PCS && $flush_mro;
# spent 47µs making 28 calls to mro::method_changed_in, avg 2µs/call
152}
153
154112µs1;
155
156__END__