← Index
NYTProf Performance Profile   « block view • line view • sub view »
For /usr/local/src/github.com/foswiki/core/bin/view
  Run on Sun Dec 4 17:17:59 2011
Reported on Sun Dec 4 17:27:03 2011

Filename/usr/share/perl/5.14/constant.pm
StatementsExecuted 1080 statements in 6.10ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
3939263.65ms4.39msconstant::::importconstant::import
4641212µs212µsconstant::::CORE:regcompconstant::CORE:regcomp (opcode)
4311212µs212µsconstant::::CORE:matchconstant::CORE:match (opcode)
42249µs49µsconstant::::__ANON__[:140]constant::__ANON__[:140]
11132µs32µsconstant::::BEGIN@2constant::BEGIN@2
11124µs24µsconstant::::BEGIN@25constant::BEGIN@25
11119µs48µsconstant::::BEGIN@52constant::BEGIN@52
11118µs25µsconstant::::BEGIN@3constant::BEGIN@3
11116µs45µsconstant::::BEGIN@114constant::BEGIN@114
11116µs284µsconstant::::BEGIN@4constant::BEGIN@4
33115µs15µsconstant::::CORE:qrconstant::CORE:qr (opcode)
11115µs45µsconstant::::BEGIN@29constant::BEGIN@29
11115µs89µsconstant::::BEGIN@6constant::BEGIN@6
0000s0sconstant::::__ANON__[:136]constant::__ANON__[:136]
0000s0sconstant::::__ANON__[:142]constant::__ANON__[:142]
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;
2271µs132µs
# spent 32µs within constant::BEGIN@2 which was called: # once (32µs+0s) by CGI::Util::BEGIN@12 at line 2
use 5.005;
# spent 32µs making 1 call to constant::BEGIN@2
3250µs232µs
# spent 25µs (18+7) within constant::BEGIN@3 which was called: # once (18µs+7µs) by CGI::Util::BEGIN@12 at line 3
use strict;
# spent 25µs making 1 call to constant::BEGIN@3 # spent 7µs making 1 call to strict::import
4249µs2552µs
# spent 284µs (16+268) within constant::BEGIN@4 which was called: # once (16µs+268µs) by CGI::Util::BEGIN@12 at line 4
use warnings::register;
# spent 284µs making 1 call to constant::BEGIN@4 # spent 268µs making 1 call to warnings::register::import
5
62215µs2164µs
# spent 89µs (15+74) within constant::BEGIN@6 which was called: # once (15µs+74µs) by CGI::Util::BEGIN@12 at line 6
use vars qw($VERSION %declared);
# spent 89µs making 1 call to constant::BEGIN@6 # spent 74µs making 1 call to vars::import
712µs$VERSION = '1.21';
8
9#=======================================================================
10
11# Some names are evil choices.
1218µsmy %keywords = map +($_, 1), qw{ BEGIN INIT CHECK END DESTROY AUTOLOAD };
1313µ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
18111µsmy %forbidden = (%keywords, %forced_into_main);
19
2012µsmy $str_end = $] >= 5.006 ? "\\z" : "\\Z";
21145µs228µsmy $normal_constant_name = qr/^_?[^\W_0-9]\w*$str_end/;
# spent 18µs making 1 call to constant::CORE:regcomp # spent 10µs making 1 call to constant::CORE:qr
22121µs211µsmy $tolerable = qr/^[A-Za-z_]\w*$str_end/;
# spent 9µs making 1 call to constant::CORE:regcomp # spent 3µs making 1 call to constant::CORE:qr
23120µs211µsmy $boolean = qr/^[01]?$str_end/;
# spent 8µs making 1 call to constant::CORE:regcomp # spent 3µs making 1 call to constant::CORE:qr
24
25
# spent 24µs within constant::BEGIN@25 which was called: # once (24µs+0s) by CGI::Util::BEGIN@12 at line 32
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.
29278µs275µs
# spent 45µs (15+30) within constant::BEGIN@29 which was called: # once (15µs+30µs) by CGI::Util::BEGIN@12 at line 29
no strict 'refs';
# spent 45µs making 1 call to constant::BEGIN@29 # spent 30µs making 1 call to strict::unimport
3013µs my $const = $] > 5.009002;
31122µs *_CAN_PCS = sub () {$const};
32198µs124µs}
# spent 24µs making 1 call to constant::BEGIN@25
33
34#=======================================================================
35# import() - import symbols into user's namespace
36#
37# What we actually do is define a function in the caller's namespace
38# which returns the value. The function we create will normally
39# be inlined as a constant, thereby avoiding further sub calling
40# overhead.
41#=======================================================================
42
# spent 4.39ms (3.65+738µs) within constant::import which was called 39 times, avg 113µs/call: # once (241µs+51µs) by Foswiki::Infix::Node::BEGIN@22 at line 23 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Infix/Node.pm # once (128µs+25µs) by Foswiki::UI::BEGIN@165 at line 165 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/UI.pm # once (121µs+29µs) by Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@9 at line 9 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/JQueryPlugin/Plugin.pm # once (119µs+28µs) by Foswiki::Contrib::MailerContrib::Subscription::BEGIN@20 at line 20 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Contrib/MailerContrib/Subscription.pm # once (121µs+25µs) by Time::Local::BEGIN@27 at line 27 of Time/Local.pm # once (117µs+29µs) by Foswiki::Render::BEGIN@72 at line 72 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Render.pm # once (111µs+25µs) by Foswiki::MetaCache::BEGIN@28 at line 28 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/MetaCache.pm # once (109µs+24µs) by Foswiki::Query::HoistREs::BEGIN@58 at line 58 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Query/HoistREs.pm # once (99µs+19µs) by Foswiki::Infix::Node::BEGIN@19 at line 19 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Infix/Node.pm # once (88µs+25µs) by Foswiki::Validation::BEGIN@54 at line 54 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Validation.pm # once (92µs+20µs) by Foswiki::Users::HtPasswdUser::BEGIN@26 at line 26 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Users/HtPasswdUser.pm # once (94µs+18µs) by CGI::Util::BEGIN@12 at line 12 of CGI/Util.pm # once (96µs+16µs) by Foswiki::Query::Parser::BEGIN@93 at line 93 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Query/Parser.pm # once (89µs+22µs) by MultipartBuffer::BEGIN@3945 at line 3945 of CGI.pm # once (90µs+20µs) by Foswiki::Iterator::BEGIN@26 at line 26 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Iterator.pm # once (89µs+20µs) by Foswiki::Access::BEGIN@16 at line 16 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Access.pm # once (90µs+19µs) by File::Temp::BEGIN@217 at line 217 of File/Temp.pm # once (91µs+16µs) by Foswiki::Search::BEGIN@28 at line 28 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Search.pm # once (88µs+16µs) by Foswiki::Access::TopicACLAccess::BEGIN@16 at line 16 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Access/TopicACLAccess.pm # once (86µs+18µs) by Foswiki::Sandbox::BEGIN@45 at line 45 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Sandbox.pm # once (85µs+17µs) by Foswiki::Store::Interfaces::QueryAlgorithm::BEGIN@23 at line 23 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Store/Interfaces/QueryAlgorithm.pm # once (86µs+16µs) by Foswiki::Templates::BEGIN@42 at line 42 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Templates.pm # once (83µs+17µs) by Foswiki::Infix::Parser::BEGIN@29 at line 29 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Infix/Parser.pm # once (83µs+15µs) by Foswiki::Address::BEGIN@71 at line 71 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Address.pm # once (81µs+16µs) by Foswiki::Store::QueryAlgorithms::BruteForce::BEGIN@46 at line 46 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Store/QueryAlgorithms/BruteForce.pm # once (77µs+19µs) by Time::Local::BEGIN@29 at line 29 of Time/Local.pm # once (81µs+13µs) by File::Temp::BEGIN@229 at line 229 of File/Temp.pm # once (80µs+13µs) by Foswiki::Address::BEGIN@72 at line 72 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Address.pm # once (79µs+14µs) by Foswiki::Query::Node::BEGIN@41 at line 41 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Query/Node.pm # once (78µs+14µs) by Foswiki::Contrib::MailerContrib::Subscription::BEGIN@23 at line 23 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Contrib/MailerContrib/Subscription.pm # once (77µs+15µs) by CGI::BEGIN@33 at line 33 of CGI.pm # once (76µs+14µs) by File::Temp::BEGIN@220 at line 220 of File/Temp.pm # once (77µs+13µs) by Foswiki::Address::BEGIN@73 at line 73 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Address.pm # once (77µs+13µs) by Time::Local::BEGIN@28 at line 28 of Time/Local.pm # once (76µs+13µs) by File::Temp::BEGIN@230 at line 230 of File/Temp.pm # once (75µs+13µs) by File::Temp::BEGIN@228 at line 228 of File/Temp.pm # once (75µs+13µs) by File::Temp::BEGIN@224 at line 224 of File/Temp.pm # once (74µs+13µs) by Foswiki::Query::Node::BEGIN@42 at line 42 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Query/Node.pm # once (74µs+11µs) by Foswiki::If::Parser::BEGIN@33 at line 33 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/If/Parser.pm
sub import {
433981µs my $class = shift;
443965µs return unless @_; # Ignore 'use constant;'
453950µs my $constants;
463983µs my $multiple = ref $_[0];
473980µs my $pkg = caller;
483942µs my $flush_mro;
493941µs my $symtab;
50
5139109µs if (_CAN_PCS) {
522451µs277µs
# spent 48µs (19+29) within constant::BEGIN@52 which was called: # once (19µs+29µs) by CGI::Util::BEGIN@12 at line 52
no strict 'refs';
# spent 48µs making 1 call to constant::BEGIN@52 # spent 29µs making 1 call to strict::unimport
5378267µs $symtab = \%{$pkg . '::'};
54 };
55
5639101µs if ( $multiple ) {
5712µs if (ref $_[0] ne 'HASH') {
58 require Carp;
59 Carp::croak("Invalid reference type '".ref(shift)."' not 'HASH'");
60 }
6111µs $constants = shift;
62 } else {
633858µs unless (defined $_[0]) {
64 require Carp;
65 Carp::croak("Can't use undef as constant name");
66 }
6738144µs $constants->{+shift} = undef;
68 }
69
7039200µs foreach my $name ( keys %$constants ) {
71 # Normal constant name
7243910µs86390µs if ($name =~ $normal_constant_name and !$forbidden{$name}) {
# spent 212µs making 43 calls to constant::CORE:match, avg 5µs/call # spent 178µs making 43 calls to constant::CORE:regcomp, avg 4µs/call
73 # Everything is okay
74
75 # Name forced into main, but we're not in main. Fatal.
76 } elsif ($forced_into_main{$name} and $pkg ne 'main') {
77 require Carp;
78 Carp::croak("Constant name '$name' is forced into main::");
79
80 # Starts with double underscore. Fatal.
81 } elsif ($name =~ /^__/) {
82 require Carp;
83 Carp::croak("Constant name '$name' begins with '__'");
84
85 # Maybe the name is tolerable
86 } elsif ($name =~ $tolerable) {
87 # Then we'll warn only if you've asked for warnings
88 if (warnings::enabled()) {
89 if ($keywords{$name}) {
90 warnings::warn("Constant name '$name' is a Perl keyword");
91 } elsif ($forced_into_main{$name}) {
92 warnings::warn("Constant name '$name' is " .
93 "forced into package main::");
94 }
95 }
96
97 # Looks like a boolean
98 # use constant FRED == fred;
99 } elsif ($name =~ $boolean) {
100 require Carp;
101 if (@_) {
102 Carp::croak("Constant name '$name' is invalid");
103 } else {
104 Carp::croak("Constant name looks like boolean value");
105 }
106
107 } else {
108 # Must have bad characters
109 require Carp;
110 Carp::croak("Constant name '$name' has invalid characters");
111 }
112
113 {
11445577µs274µs
# spent 45µs (16+29) within constant::BEGIN@114 which was called: # once (16µs+29µs) by CGI::Util::BEGIN@12 at line 114
no strict 'refs';
# spent 45µs making 1 call to constant::BEGIN@114 # spent 29µs making 1 call to strict::unimport
11543110µs my $full_name = "${pkg}::$name";
11643168µs $declared{$full_name}++;
11743138µs if ($multiple || @_ == 1) {
1184170µs my $scalar = $multiple ? $constants->{$name} : $_[0];
119
120 # Work around perl bug #xxxxx: Sub names (actually glob
121 # names in general) ignore the UTF8 flag. So we have to
122 # turn it off to get the "right" symbol table entry.
12341331µs41120µs utf8::is_utf8 $name and utf8::encode $name;
# spent 120µs making 41 calls to utf8::is_utf8, avg 3µs/call
124
125 # The constant serves to optimise this entire block out on
126 # 5.8 and earlier.
12741142µs if (_CAN_PCS && $symtab && !exists $symtab->{$name}) {
128 # No typeglob yet, so we can use a reference as space-
129 # efficient proxy for a constant subroutine
130 # The check in Perl_ck_rvconst knows that inlinable
131 # constants from cv_const_sv are read only. So we have to:
13241294µs4195µs Internals::SvREADONLY($scalar, 1);
# spent 95µs making 41 calls to Internals::SvREADONLY, avg 2µs/call
1334193µs $symtab->{$name} = \$scalar;
1344165µs ++$flush_mro;
135 } else {
136 *$full_name = sub () { $scalar };
137 }
138 } elsif (@_) {
139213µs my @list = @_;
140671µs
# spent 49µs within constant::__ANON__[/usr/share/perl/5.14/constant.pm:140] which was called 4 times, avg 12µs/call: # 3 times (42µs+0s) by Foswiki::Query::Parser::new at line 103 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Query/Parser.pm, avg 14µs/call # once (7µs+0s) by Foswiki::If::Parser::new at line 40 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/If/Parser.pm
*$full_name = sub () { @list };
141 } else {
142 *$full_name = sub () { };
143 }
144 }
145 }
146 # Flush the cache exactly once if we make any direct symbol table changes.
14739616µs37134µs mro::method_changed_in($pkg) if _CAN_PCS && $flush_mro;
# spent 134µs making 37 calls to mro::method_changed_in, avg 4µs/call
148}
149
150118µs1;
151
152__END__
 
# spent 212µs within constant::CORE:match which was called 43 times, avg 5µs/call: # 43 times (212µs+0s) by constant::import at line 72, avg 5µs/call
sub constant::CORE:match; # opcode
# spent 15µs within constant::CORE:qr which was called 3 times, avg 5µs/call: # once (10µs+0s) by CGI::Util::BEGIN@12 at line 21 # once (3µs+0s) by CGI::Util::BEGIN@12 at line 22 # once (3µs+0s) by CGI::Util::BEGIN@12 at line 23
sub constant::CORE:qr; # opcode
# spent 212µs within constant::CORE:regcomp which was called 46 times, avg 5µs/call: # 43 times (178µs+0s) by constant::import at line 72, avg 4µs/call # once (18µs+0s) by CGI::Util::BEGIN@12 at line 21 # once (9µs+0s) by CGI::Util::BEGIN@12 at line 22 # once (8µs+0s) by CGI::Util::BEGIN@12 at line 23
sub constant::CORE:regcomp; # opcode