← Index
NYTProf Performance Profile   « line view »
For webmerge/scripts/webmerge.pl
  Run on Mon Oct 7 02:42:42 2013
Reported on Mon Oct 7 03:03:20 2013

Filename/usr/lib64/perl5/5.16.0/constant.pm
StatementsExecuted 2441 statements in 28.7ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
92921315.5ms19.3msconstant::::importconstant::import
112111.32ms1.32msconstant::::CORE:matchconstant::CORE:match (opcode)
1111.17ms1.17msconstant::::BEGIN@36constant::BEGIN@36
11541805µs805µsconstant::::CORE:regcompconstant::CORE:regcomp (opcode)
111764µs84.0msconstant::::BEGIN@25constant::BEGIN@25
11196µs96µsconstant::::BEGIN@2constant::BEGIN@2
11168µs165µsconstant::::BEGIN@3constant::BEGIN@3
11160µs144µsconstant::::BEGIN@65constant::BEGIN@65
11158µs133µsconstant::::BEGIN@127constant::BEGIN@127
11154µs130µsconstant::::BEGIN@29constant::BEGIN@29
11153µs278µsconstant::::BEGIN@6constant::BEGIN@6
11152µs671µsconstant::::BEGIN@4constant::BEGIN@4
33130µs30µsconstant::::CORE:qrconstant::CORE:qr (opcode)
0000s0sconstant::::__ANON__[:151]constant::__ANON__[:151]
0000s0sconstant::::__ANON__[:155]constant::__ANON__[:155]
0000s0sconstant::::__ANON__[:157]constant::__ANON__[:157]
0000s0sconstant::::__ANON__[:31]constant::__ANON__[:31]
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package constant;
22279µs196µs
# spent 96µs within constant::BEGIN@2 which was called: # once (96µs+0s) by File::Which::BEGIN@16 at line 2
use 5.005;
# spent 96µs making 1 call to constant::BEGIN@2
32146µs2262µs
# spent 165µs (68+97) within constant::BEGIN@3 which was called: # once (68µs+97µs) by File::Which::BEGIN@16 at line 3
use strict;
# spent 165µs making 1 call to constant::BEGIN@3 # spent 97µs making 1 call to strict::import
42340µs21.29ms
# spent 671µs (52+619) within constant::BEGIN@4 which was called: # once (52µs+619µs) by File::Which::BEGIN@16 at line 4
use warnings::register;
# spent 671µs making 1 call to constant::BEGIN@4 # spent 619µs making 1 call to warnings::register::import
5
62722µs2502µs
# spent 278µs (53+224) within constant::BEGIN@6 which was called: # once (53µs+224µs) by File::Which::BEGIN@16 at line 6
use vars qw($VERSION %declared);
# spent 278µs making 1 call to constant::BEGIN@6 # spent 224µs making 1 call to vars::import
714µs$VERSION = '1.23';
8
9#=======================================================================
10
11# Some names are evil choices.
12133µsmy %keywords = map +($_, 1), qw{ BEGIN INIT CHECK END DESTROY AUTOLOAD };
13110µs$keywords{UNITCHECK}++ if $] > 5.009;
14
15133µsmy %forced_into_main = map +($_, 1),
16 qw{ STDIN STDOUT STDERR ARGV ARGVOUT ENV INC SIG };
17
18126µsmy %forbidden = (%keywords, %forced_into_main);
19
2014µsmy $str_end = $] >= 5.006 ? "\\z" : "\\Z";
211164µs294µsmy $normal_constant_name = qr/^_?[^\W_0-9]\w*$str_end/;
# spent 80µs making 1 call to constant::CORE:regcomp # spent 13µs making 1 call to constant::CORE:qr
22168µs234µsmy $tolerable = qr/^[A-Za-z_]\w*$str_end/;
# spent 25µs making 1 call to constant::CORE:regcomp # spent 9µs making 1 call to constant::CORE:qr
23169µs235µsmy $boolean = qr/^[01]?$str_end/;
# spent 26µs making 1 call to constant::CORE:regcomp # spent 8µs making 1 call to constant::CORE:qr
24
25
# spent 84.0ms (764µs+83.3) within constant::BEGIN@25 which was called: # once (764µs+83.3ms) by File::Which::BEGIN@16 at line 45
BEGIN {
26 # We'd like to do use constant _CAN_PCS => $] > 5.009002
27 # but that's a bit tricky before we load the constant module :-)
28 # By doing this, we save 1 run time check for *every* call to import.
292930µs2207µs
# spent 130µs (54+76) within constant::BEGIN@29 which was called: # once (54µs+76µs) by File::Which::BEGIN@16 at line 29
no strict 'refs';
# spent 130µs making 1 call to constant::BEGIN@29 # spent 76µs making 1 call to strict::unimport
3018µs my $const = $] > 5.009002;
31129µs *_CAN_PCS = sub () {$const};
32
33 # Before this makes its way into a dev perl release, we have to do
34 # browser-sniffing, as it were....
351900ns return unless $const;
3631.70ms120.6ms
# spent 1.17ms within constant::BEGIN@36 which was called: # once (1.17ms+0s) by constant::BEGIN@25 at line 45
*{chr 256} = \3;
# spent 20.6ms making 1 call to utf8::AUTOLOAD
37132µs if (exists ${__PACKAGE__."::"}{"\xc4\x80"}) {
38 delete ${__PACKAGE__."::"}{"\xc4\x80"};
39 *_DOWNGRADE = sub () {1};
40 }
41 else {
4219µs delete ${__PACKAGE__."::"}{chr 256};
4319µs *_DOWNGRADE = sub () {0};
44 }
451519µs285.2ms}
# spent 84.0ms making 1 call to constant::BEGIN@25 # spent 1.17ms making 1 call to constant::BEGIN@36
46
47#=======================================================================
48# import() - import symbols into user's namespace
49#
50# What we actually do is define a function in the caller's namespace
51# which returns the value. The function we create will normally
52# be inlined as a constant, thereby avoiding further sub calling
53# overhead.
54#=======================================================================
55
# spent 19.3ms (15.5+3.70) within constant::import which was called 92 times, avg 209µs/call: # once (1.67ms+455µs) by XML::LibXML::BEGIN@235 at line 236 of XML/LibXML.pm # once (261µs+68µs) by Data::Dumper::BEGIN@275 at line 275 of Data/Dumper.pm # once (220µs+59µs) by File::Which::BEGIN@16 at line 16 of File/Which.pm # once (212µs+56µs) by JSON::Backend::XS::BEGIN@9 at line 9 of (eval 18)[JSON.pm:268] # once (200µs+46µs) by Encode::Alias::BEGIN@6 at line 6 of Encode/Alias.pm # once (198µs+47µs) by Getopt::Long::BEGIN@208 at line 208 of Getopt/Long.pm # once (192µs+47µs) by XML::SAX::BEGIN@20 at line 20 of XML/SAX.pm # once (187µs+51µs) by XML::LibXML::BEGIN@160 at line 160 of XML/LibXML.pm # once (180µs+58µs) by Encode::BEGIN@8 at line 8 of Encode.pm # once (201µs+35µs) by XML::LibXML::Error::BEGIN@35 at line 35 of XML/LibXML/Error.pm # once (186µs+48µs) by IPC::Run3::BEGIN@41 at line 41 of IPC/Run3.pm # once (182µs+46µs) by RTP::Webmerge::Embedder::PHP::BEGIN@26 at line 26 of webmerge/scripts/modules/RTP/Webmerge/Embedder/PHP.pm # once (183µs+45µs) by File::Temp::BEGIN@217 at line 217 of File/Temp.pm # once (178µs+44µs) by XML::LibXML::Error::BEGIN@34 at line 34 of XML/LibXML/Error.pm # once (181µs+42µs) by XML::LibXML::BEGIN@21 at line 21 of XML/LibXML.pm # once (177µs+44µs) by RTP::Webmerge::Embedder::JS::BEGIN@26 at line 26 of webmerge/scripts/modules/RTP/Webmerge/Embedder/JS.pm # once (186µs+32µs) by IPC::Run3::BEGIN@42 at line 42 of IPC/Run3.pm # once (178µs+34µs) by XML::LibXML::Error::BEGIN@57 at line 57 of XML/LibXML/Error.pm # once (179µs+32µs) by XML::LibXML::Error::BEGIN@61 at line 61 of XML/LibXML/Error.pm # once (174µs+37µs) by Getopt::Long::BEGIN@237 at line 237 of Getopt/Long.pm # once (175µs+32µs) by XML::LibXML::BEGIN@22 at line 22 of XML/LibXML.pm # once (135µs+70µs) by XML::LibXML::BEGIN@164 at line 164 of XML/LibXML.pm # once (163µs+40µs) by File::Which::BEGIN@18 at line 18 of File/Which.pm # once (169µs+30µs) by XML::LibXML::BEGIN@175 at line 175 of XML/LibXML.pm # once (157µs+42µs) by File::Which::BEGIN@17 at line 17 of File/Which.pm # once (148µs+43µs) by XML::LibXML::Error::BEGIN@52 at line 52 of XML/LibXML/Error.pm # once (154µs+37µs) by XML::LibXML::Error::BEGIN@47 at line 47 of XML/LibXML/Error.pm # once (156µs+34µs) by XML::LibXML::Error::BEGIN@66 at line 66 of XML/LibXML/Error.pm # once (156µs+34µs) by XML::LibXML::Error::BEGIN@54 at line 54 of XML/LibXML/Error.pm # once (154µs+35µs) by JSON::Backend::XS::BEGIN@11 at line 11 of (eval 18)[JSON.pm:268] # once (144µs+46µs) by Getopt::Long::BEGIN@224 at line 224 of Getopt/Long.pm # once (153µs+34µs) by IPC::Run3::BEGIN@43 at line 43 of IPC/Run3.pm # once (155µs+32µs) by Getopt::Long::BEGIN@229 at line 229 of Getopt/Long.pm # once (156µs+30µs) by XML::LibXML::Error::BEGIN@51 at line 51 of XML/LibXML/Error.pm # once (151µs+35µs) by Getopt::Long::BEGIN@218 at line 218 of Getopt/Long.pm # once (154µs+32µs) by XML::LibXML::BEGIN@172 at line 172 of XML/LibXML.pm # once (154µs+32µs) by XML::LibXML::Error::BEGIN@64 at line 64 of XML/LibXML/Error.pm # once (136µs+47µs) by File::Temp::BEGIN@230 at line 230 of File/Temp.pm # once (149µs+33µs) by XML::LibXML::BEGIN@161 at line 161 of XML/LibXML.pm # once (147µs+34µs) by XML::LibXML::Error::BEGIN@65 at line 65 of XML/LibXML/Error.pm # once (143µs+36µs) by XML::LibXML::Error::BEGIN@58 at line 58 of XML/LibXML/Error.pm # once (145µs+34µs) by XML::SAX::BEGIN@22 at line 22 of XML/SAX.pm # once (143µs+34µs) by XML::LibXML::Error::BEGIN@46 at line 46 of XML/LibXML/Error.pm # once (142µs+35µs) by XML::LibXML::Error::BEGIN@62 at line 62 of XML/LibXML/Error.pm # once (145µs+30µs) by Getopt::Long::BEGIN@247 at line 247 of Getopt/Long.pm # once (143µs+32µs) by XML::LibXML::Error::BEGIN@53 at line 53 of XML/LibXML/Error.pm # once (140µs+34µs) by Getopt::Long::BEGIN@236 at line 236 of Getopt/Long.pm # once (143µs+31µs) by XML::LibXML::Error::BEGIN@67 at line 67 of XML/LibXML/Error.pm # once (141µs+33µs) by XML::LibXML::Error::BEGIN@48 at line 48 of XML/LibXML/Error.pm # once (140µs+33µs) by XML::LibXML::BEGIN@165 at line 165 of XML/LibXML.pm # once (138µs+35µs) by XML::LibXML::Error::BEGIN@36 at line 36 of XML/LibXML/Error.pm # once (140µs+32µs) by XML::LibXML::Error::BEGIN@45 at line 45 of XML/LibXML/Error.pm # once (140µs+32µs) by XML::LibXML::BEGIN@176 at line 176 of XML/LibXML.pm # once (139µs+33µs) by XML::LibXML::Error::BEGIN@37 at line 37 of XML/LibXML/Error.pm # once (138µs+34µs) by XML::LibXML::Error::BEGIN@55 at line 55 of XML/LibXML/Error.pm # once (140µs+32µs) by XML::LibXML::BEGIN@179 at line 179 of XML/LibXML.pm # once (139µs+32µs) by XML::LibXML::Error::BEGIN@39 at line 39 of XML/LibXML/Error.pm # once (139µs+31µs) by XML::SAX::BEGIN@23 at line 23 of XML/SAX.pm # once (138µs+32µs) by Getopt::Long::BEGIN@225 at line 225 of Getopt/Long.pm # once (138µs+31µs) by XML::LibXML::Error::BEGIN@40 at line 40 of XML/LibXML/Error.pm # once (138µs+31µs) by XML::LibXML::Error::BEGIN@59 at line 59 of XML/LibXML/Error.pm # once (139µs+30µs) by Getopt::Long::BEGIN@223 at line 223 of Getopt/Long.pm # once (136µs+32µs) by XML::LibXML::BEGIN@166 at line 166 of XML/LibXML.pm # once (137µs+31µs) by XML::LibXML::Error::BEGIN@63 at line 63 of XML/LibXML/Error.pm # once (136µs+32µs) by File::Temp::BEGIN@220 at line 220 of File/Temp.pm # once (138µs+30µs) by XML::LibXML::Error::BEGIN@49 at line 49 of XML/LibXML/Error.pm # once (137µs+31µs) by XML::LibXML::BEGIN@177 at line 177 of XML/LibXML.pm # once (136µs+31µs) by JSON::Backend::XS::BEGIN@18 at line 18 of (eval 18)[JSON.pm:268] # once (135µs+32µs) by XML::LibXML::Error::BEGIN@43 at line 43 of XML/LibXML/Error.pm # once (137µs+30µs) by XML::LibXML::BEGIN@162 at line 162 of XML/LibXML.pm # once (135µs+32µs) by File::Temp::BEGIN@224 at line 224 of File/Temp.pm # once (136µs+30µs) by XML::LibXML::Error::BEGIN@42 at line 42 of XML/LibXML/Error.pm # once (137µs+30µs) by Getopt::Long::BEGIN@228 at line 228 of Getopt/Long.pm # once (136µs+30µs) by XML::LibXML::Error::BEGIN@60 at line 60 of XML/LibXML/Error.pm # once (137µs+30µs) by XML::LibXML::BEGIN@174 at line 174 of XML/LibXML.pm # once (137µs+30µs) by File::Temp::BEGIN@229 at line 229 of File/Temp.pm # once (136µs+30µs) by XML::LibXML::Error::BEGIN@44 at line 44 of XML/LibXML/Error.pm # once (137µs+29µs) by XML::LibXML::BEGIN@173 at line 173 of XML/LibXML.pm # once (136µs+30µs) by Getopt::Long::BEGIN@220 at line 220 of Getopt/Long.pm # once (136µs+30µs) by XML::LibXML::Error::BEGIN@50 at line 50 of XML/LibXML/Error.pm # once (136µs+30µs) by XML::LibXML::Error::BEGIN@41 at line 41 of XML/LibXML/Error.pm # once (137µs+28µs) by Getopt::Long::BEGIN@222 at line 222 of Getopt/Long.pm # once (136µs+29µs) by XML::LibXML::BEGIN@167 at line 167 of XML/LibXML.pm # once (135µs+29µs) by XML::LibXML::BEGIN@178 at line 178 of XML/LibXML.pm # once (134µs+30µs) by XML::LibXML::Error::BEGIN@56 at line 56 of XML/LibXML/Error.pm # once (135µs+28µs) by Getopt::Long::BEGIN@226 at line 226 of Getopt/Long.pm # once (133µs+29µs) by XML::LibXML::BEGIN@163 at line 163 of XML/LibXML.pm # once (131µs+31µs) by File::Temp::BEGIN@228 at line 228 of File/Temp.pm # once (130µs+31µs) by XML::LibXML::BEGIN@169 at line 169 of XML/LibXML.pm # once (132µs+29µs) by XML::LibXML::BEGIN@170 at line 170 of XML/LibXML.pm # once (132µs+29µs) by XML::LibXML::BEGIN@168 at line 168 of XML/LibXML.pm # once (131µs+29µs) by XML::LibXML::BEGIN@171 at line 171 of XML/LibXML.pm
sub import {
5692254µs my $class = shift;
5792178µs return unless @_; # Ignore 'use constant;'
589258µs my $constants;
5992210µs my $multiple = ref $_[0];
6092372µs my $pkg = caller;
619257µs my $flush_mro;
629261µs my $symtab;
63
6492229µs if (_CAN_PCS) {
6521.57ms2227µs
# spent 144µs (60+83) within constant::BEGIN@65 which was called: # once (60µs+83µs) by File::Which::BEGIN@16 at line 65
no strict 'refs';
# spent 144µs making 1 call to constant::BEGIN@65 # spent 83µs making 1 call to strict::unimport
6692842µs $symtab = \%{$pkg . '::'};
67 };
68
6992181µs if ( $multiple ) {
7016µs if (ref $_[0] ne 'HASH') {
71 require Carp;
72 Carp::croak("Invalid reference type '".ref(shift)."' not 'HASH'");
73 }
7412µs $constants = shift;
75 } else {
7691132µs unless (defined $_[0]) {
77 require Carp;
78 Carp::croak("Can't use undef as constant name");
79 }
8091738µs $constants->{+shift} = undef;
81 }
82
8392924µs foreach my $name ( keys %$constants ) {
84 # Normal constant name
851125.21ms2241.99ms if ($name =~ $normal_constant_name and !$forbidden{$name}) {
# spent 1.32ms making 112 calls to constant::CORE:match, avg 12µs/call # spent 673µs making 112 calls to constant::CORE:regcomp, avg 6µs/call
86 # Everything is okay
87
88 # Name forced into main, but we're not in main. Fatal.
89 } elsif ($forced_into_main{$name} and $pkg ne 'main') {
90 require Carp;
91 Carp::croak("Constant name '$name' is forced into main::");
92
93 # Starts with double underscore. Fatal.
94 } elsif ($name =~ /^__/) {
95 require Carp;
96 Carp::croak("Constant name '$name' begins with '__'");
97
98 # Maybe the name is tolerable
99 } elsif ($name =~ $tolerable) {
100 # Then we'll warn only if you've asked for warnings
101 if (warnings::enabled()) {
102 if ($keywords{$name}) {
103 warnings::warn("Constant name '$name' is a Perl keyword");
104 } elsif ($forced_into_main{$name}) {
105 warnings::warn("Constant name '$name' is " .
106 "forced into package main::");
107 }
108 }
109
110 # Looks like a boolean
111 # use constant FRED == fred;
112 } elsif ($name =~ $boolean) {
113 require Carp;
114 if (@_) {
115 Carp::croak("Constant name '$name' is invalid");
116 } else {
117 Carp::croak("Constant name looks like boolean value");
118 }
119
120 } else {
121 # Must have bad characters
122 require Carp;
123 Carp::croak("Constant name '$name' has invalid characters");
124 }
125
126 {
1271142.23ms2208µs
# spent 133µs (58+75) within constant::BEGIN@127 which was called: # once (58µs+75µs) by File::Which::BEGIN@16 at line 127
no strict 'refs';
# spent 133µs making 1 call to constant::BEGIN@127 # spent 75µs making 1 call to strict::unimport
128112471µs my $full_name = "${pkg}::$name";
129112777µs $declared{$full_name}++;
130112426µs if ($multiple || @_ == 1) {
131112259µs my $scalar = $multiple ? $constants->{$name} : $_[0];
132
133 if (_DOWNGRADE) { # for 5.10 to 5.14
134 # Work around perl bug #31991: Sub names (actually glob
135 # names in general) ignore the UTF8 flag. So we have to
136 # turn it off to get the "right" symbol table entry.
137 utf8::is_utf8 $name and utf8::encode $name;
138 }
139
140 # The constant serves to optimise this entire block out on
141 # 5.8 and earlier.
142112559µs if (_CAN_PCS && $symtab && !exists $symtab->{$name}) {
143 # No typeglob yet, so we can use a reference as space-
144 # efficient proxy for a constant subroutine
145 # The check in Perl_ck_rvconst knows that inlinable
146 # constants from cv_const_sv are read only. So we have to:
1471122.29ms112711µs Internals::SvREADONLY($scalar, 1);
# spent 711µs making 112 calls to Internals::SvREADONLY, avg 6µs/call
148112602µs $symtab->{$name} = \$scalar;
149112295µs ++$flush_mro;
150 } else {
151 *$full_name = sub () { $scalar };
152 }
153 } elsif (@_) {
154 my @list = @_;
155 *$full_name = sub () { @list };
156 } else {
157 *$full_name = sub () { };
158 }
159 }
160 }
161 # Flush the cache exactly once if we make any direct symbol table changes.
162924.64ms921.00ms mro::method_changed_in($pkg) if _CAN_PCS && $flush_mro;
# spent 1.00ms making 92 calls to mro::method_changed_in, avg 11µs/call
163}
164
165146µs1;
166
167__END__
 
# spent 1.32ms within constant::CORE:match which was called 112 times, avg 12µs/call: # 112 times (1.32ms+0s) by constant::import at line 85, avg 12µs/call
sub constant::CORE:match; # opcode
# spent 30µs within constant::CORE:qr which was called 3 times, avg 10µs/call: # once (13µs+0s) by File::Which::BEGIN@16 at line 21 # once (9µs+0s) by File::Which::BEGIN@16 at line 22 # once (8µs+0s) by File::Which::BEGIN@16 at line 23
sub constant::CORE:qr; # opcode
# spent 805µs within constant::CORE:regcomp which was called 115 times, avg 7µs/call: # 112 times (673µs+0s) by constant::import at line 85, avg 6µs/call # once (80µs+0s) by File::Which::BEGIN@16 at line 21 # once (26µs+0s) by File::Which::BEGIN@16 at line 23 # once (25µs+0s) by File::Which::BEGIN@16 at line 22
sub constant::CORE:regcomp; # opcode