Profile of constant.pm

← Index
NYTProf Performance Profile «block view•line view•sub view»
For xt/tapper-mcp-scheduler-with-db-longrun.t
Run on Tue May 22 17:18:39 2012
Reported on Tue May 22 17:22:43 2012

Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/5.12.3/constant.pm
Statements | Executed 2057 statements in 3.77ms

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
73 | 73 | 29 | 2.02ms | 2.59ms | constant::::importconstant::import
93 | 1 | 1 | 202µs | 202µs | constant::::CORE:matchconstant::CORE:match (opcode)
96 | 4 | 1 | 146µs | 146µs | constant::::CORE:regcompconstant::CORE:regcomp (opcode)
1 | 1 | 1 | 29µs | 29µs | constant::::BEGIN@2constant::BEGIN@2
1 | 1 | 1 | 15µs | 15µs | constant::::BEGIN@25constant::BEGIN@25
1 | 1 | 1 | 10µs | 48µs | constant::::BEGIN@6constant::BEGIN@6
1 | 1 | 1 | 8µs | 10µs | constant::::BEGIN@3constant::BEGIN@3
1 | 1 | 1 | 6µs | 16µs | constant::::BEGIN@114constant::BEGIN@114
1 | 1 | 1 | 6µs | 70µs | constant::::BEGIN@4constant::BEGIN@4
1 | 1 | 1 | 6µs | 20µs | constant::::BEGIN@29constant::BEGIN@29
1 | 1 | 1 | 5µs | 16µs | constant::::BEGIN@52constant::BEGIN@52
3 | 3 | 1 | 5µs | 5µs | constant::::CORE:qrconstant::CORE:qr (opcode)
1 | 1 | 1 | 4µs | 4µs | constant::::__ANON__[:141]constant::__ANON__[:141]
0 | 0 | 0 | 0s | 0s | constant::::__ANON__[:137]constant::__ANON__[:137]
0 | 0 | 0 | 0s | 0s | constant::::__ANON__[:143]constant::__ANON__[:143]
0 | 0 | 0 | 0s | 0s | constant::::__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
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | package constant;
2 | 3 | 35µs | 1 | 29µs | # spent 29µs within constant::BEGIN@2 which was called: # once (29µs+0s) by Class::MOP::Method::Meta::BEGIN@16 at line 2 use 5.005; # spent 29µs making 1 call to constant::BEGIN@2
3 | 3 | 16µs | 2 | 12µs | # spent 10µs (8+2) within constant::BEGIN@3 which was called: # once (8µs+2µs) by Class::MOP::Method::Meta::BEGIN@16 at line 3 use strict; # spent 10µs making 1 call to constant::BEGIN@3 # spent 2µs making 1 call to strict::import
4 | 3 | 21µs | 2 | 134µs | # spent 70µs (6+64) within constant::BEGIN@4 which was called: # once (6µs+64µs) by Class::MOP::Method::Meta::BEGIN@16 at line 4 use warnings::register; # spent 70µs making 1 call to constant::BEGIN@4 # spent 64µs making 1 call to warnings::register::import
5 |  |  |  |  |
6 | 3 | 110µs | 2 | 87µs | # spent 48µs (10+39) within constant::BEGIN@6 which was called: # once (10µs+39µs) by Class::MOP::Method::Meta::BEGIN@16 at line 6 use vars qw($VERSION %declared); # spent 48µs making 1 call to constant::BEGIN@6 # spent 39µs making 1 call to vars::import
7 | 1 | 500ns |  |  | $VERSION = '1.21';
8 |  |  |  |  |
9 |  |  |  |  | #=======================================================================
10 |  |  |  |  |
11 |  |  |  |  | # Some names are evil choices.
12 | 1 | 12µs |  |  | my %keywords = map +($_, 1), qw{ BEGIN INIT CHECK END DESTROY AUTOLOAD };
13 | 1 | 2µs |  |  | $keywords{UNITCHECK}++ if $] > 5.009;
14 |  |  |  |  |
15 | 1 | 6µs |  |  | my %forced_into_main = map +($_, 1),
16 |  |  |  |  | qw{ STDIN STDOUT STDERR ARGV ARGVOUT ENV INC SIG };
17 |  |  |  |  |
18 | 1 | 5µs |  |  | my %forbidden = (%keywords, %forced_into_main);
19 |  |  |  |  |
20 | 1 | 1µs |  |  | my $str_end = $] >= 5.006 ? "\\z" : "\\Z";
21 | 1 | 29µs | 2 | 21µs | my $normal_constant_name = qr/^_?[^\W_0-9]\w*$str_end/; # spent 18µs making 1 call to constant::CORE:regcomp # spent 3µs making 1 call to constant::CORE:qr
22 | 1 | 9µs | 2 | 5µs | my $tolerable = qr/^[A-Za-z_]\w*$str_end/; # spent 4µs making 1 call to constant::CORE:regcomp # spent 1µs making 1 call to constant::CORE:qr
23 | 1 | 13µs | 2 | 9µs | my $boolean = qr/^[01]?$str_end/; # spent 8µs making 1 call to constant::CORE:regcomp # spent 1µs making 1 call to constant::CORE:qr
24 |  |  |  |  |
25 |  |  |  |  | # spent 15µs within constant::BEGIN@25 which was called: # once (15µs+0s) by Class::MOP::Method::Meta::BEGIN@16 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.
29 | 3 | 41µs | 2 | 34µs | # spent 20µs (6+14) within constant::BEGIN@29 which was called: # once (6µs+14µs) by Class::MOP::Method::Meta::BEGIN@16 at line 29 no strict 'refs'; # spent 20µs making 1 call to constant::BEGIN@29 # spent 14µs making 1 call to strict::unimport
30 | 2 | 15µs |  |  | my $const = $] > 5.009002;
31 |  |  |  |  | *_CAN_PCS = sub () {$const};
32 | 1 | 50µs | 1 | 15µs | } # spent 15µ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 2.59ms (2.02+568µs) within constant::import which was called 73 times, avg 35µs/call: # once (94µs+24µs) by Compress::Bzip2::BEGIN@146 at line 146 of Compress/Bzip2.pm # once (67µs+17µs) by Compress::Bzip2::BEGIN@143 at line 143 of Compress/Bzip2.pm # once (60µs+12µs) by Compress::Bzip2::BEGIN@153 at line 153 of Compress/Bzip2.pm # once (43µs+18µs) by Log::Log4perl::BEGIN@69 at line 69 of Log/Log4perl.pm # once (42µs+16µs) by DateTime::TimeZone::BEGIN@18 at line 18 of DateTime/TimeZone.pm # once (39µs+19µs) by Log::Log4perl::Config::BaseConfigurator::BEGIN@5 at line 5 of Log/Log4perl/Config/BaseConfigurator.pm # once (43µs+13µs) by File::stat::BEGIN@144 at line 144 of File/stat.pm # once (42µs+12µs) by Compress::Bzip2::BEGIN@150 at line 150 of Compress/Bzip2.pm # once (40µs+14µs) by IPC::Open3::BEGIN@184 at line 184 of IPC/Open3.pm # once (42µs+12µs) by File::ShareDir::BEGIN@133 at line 133 of File/ShareDir.pm # once (42µs+12µs) by SQL::Translator::Schema::Constants::BEGIN@81 at line 81 of SQL/Translator/Schema/Constants.pm # once (41µs+12µs) by YAML::Syck::BEGIN@36 at line 53 of YAML/Syck.pm # once (38µs+14µs) by YAML::BEGIN@15 at line 15 of YAML.pm # once (40µs+12µs) by DBD::SQLite::BEGIN@30 at line 30 of DBD/SQLite.pm # once (38µs+14µs) by Log::Log4perl::Appender::BEGIN@12 at line 12 of Log/Log4perl/Appender.pm # once (38µs+14µs) by Log::Log4perl::Level::BEGIN@13 at line 13 of Log/Log4perl/Level.pm # once (40µs+11µs) by Compress::Bzip2::BEGIN@141 at line 141 of Compress/Bzip2.pm # once (38µs+13µs) by DateTime::Duration::BEGIN@23 at line 23 of DateTime/Duration.pm # once (35µs+15µs) by Class::MOP::Method::Meta::BEGIN@16 at line 16 of Class/MOP/Method/Meta.pm # once (37µs+12µs) by namespace::clean::BEGIN@168 at line 168 of namespace/clean.pm # once (35µs+12µs) by File::Temp::BEGIN@217 at line 217 of File/Temp.pm # once (35µs+12µs) by Compress::Bzip2::BEGIN@156 at line 156 of Compress/Bzip2.pm # once (35µs+11µs) by Devel::Backtrace::Point::BEGIN@29 at line 48 of Devel/Backtrace/Point.pm # once (35µs+10µs) by SQL::Translator::Utils::BEGIN@33 at line 33 of SQL/Translator/Utils.pm # once (34µs+9µs) by Time::Local::BEGIN@27 at line 27 of Time/Local.pm # once (31µs+11µs) by Log::Log4perl::Layout::PatternLayout::BEGIN@9 at line 9 of Log/Log4perl/Layout/PatternLayout.pm # once (25µs+7µs) by Log::Log4perl::Logger::BEGIN@20 at line 20 of Log/Log4perl/Logger.pm # once (25µs+5µs) by DateTime::TimeZone::BEGIN@24 at line 24 of DateTime/TimeZone.pm # once (24µs+5µs) by Log::Log4perl::Config::Watch::BEGIN@3 at line 3 of Log/Log4perl/Config/Watch.pm # once (23µs+6µs) by DateTime::BEGIN@74 at line 74 of DateTime.pm # once (23µs+5µs) by Log::Log4perl::Config::PropertyConfigurator::BEGIN@17 at line 17 of Log/Log4perl/Config/PropertyConfigurator.pm # once (22µs+6µs) by Log::Log4perl::Filter::Boolean::BEGIN@13 at line 13 of Log/Log4perl/Filter/Boolean.pm # once (20µs+8µs) by Log::Log4perl::Level::BEGIN@16 at line 16 of Log/Log4perl/Level.pm # once (21µs+6µs) by Log::Log4perl::JavaMap::BEGIN@6 at line 6 of Log/Log4perl/JavaMap.pm # once (19µs+8µs) by SQL::Translator::Schema::Constants::BEGIN@93 at line 93 of SQL/Translator/Schema/Constants.pm # once (22µs+5µs) by Log::Log4perl::Config::BEGIN@16 at line 16 of Log/Log4perl/Config.pm # once (20µs+5µs) by Log::Log4perl::Filter::BEGIN@12 at line 12 of Log/Log4perl/Filter.pm # once (19µs+6µs) by DateTime::TimeZone::BEGIN@19 at line 19 of DateTime/TimeZone.pm # once (19µs+6µs) by DateTime::TimeZone::BEGIN@22 at line 22 of DateTime/TimeZone.pm # once (20µs+5µs) by File::Temp::BEGIN@220 at line 220 of File/Temp.pm # once (22µs+3µs) by DateTime::BEGIN@76 at line 76 of DateTime.pm # once (20µs+5µs) by SQL::Translator::Schema::Constants::BEGIN@91 at line 91 of SQL/Translator/Schema/Constants.pm # once (20µs+4µs) by SQL::Translator::Schema::Constants::BEGIN@87 at line 87 of SQL/Translator/Schema/Constants.pm # once (19µs+5µs) by DateTime::TimeZone::BEGIN@25 at line 25 of DateTime/TimeZone.pm # once (20µs+5µs) by namespace::clean::BEGIN@169 at line 169 of namespace/clean.pm # once (19µs+5µs) by DateTime::TimeZone::BEGIN@26 at line 26 of DateTime/TimeZone.pm # once (19µs+5µs) by SQL::Translator::Schema::Constants::BEGIN@83 at line 83 of SQL/Translator/Schema/Constants.pm # once (18µs+5µs) by DateTime::TimeZone::BEGIN@28 at line 28 of DateTime/TimeZone.pm # once (19µs+5µs) by DateTime::TimeZone::BEGIN@23 at line 23 of DateTime/TimeZone.pm # once (19µs+5µs) by Log::Log4perl::Level::BEGIN@14 at line 14 of Log/Log4perl/Level.pm # once (20µs+4µs) by File::Temp::BEGIN@228 at line 228 of File/Temp.pm # once (19µs+4µs) by SQL::Translator::Schema::Constants::BEGIN@89 at line 89 of SQL/Translator/Schema/Constants.pm # once (18µs+5µs) by DateTime::TimeZone::BEGIN@27 at line 27 of DateTime/TimeZone.pm # once (19µs+4µs) by SQL::Translator::Schema::Constants::BEGIN@95 at line 95 of SQL/Translator/Schema/Constants.pm # once (19µs+4µs) by Time::Local::BEGIN@28 at line 28 of Time/Local.pm # once (19µs+4µs) by Time::Local::BEGIN@29 at line 29 of Time/Local.pm # once (19µs+4µs) by SQL::Translator::Schema::Constants::BEGIN@97 at line 97 of SQL/Translator/Schema/Constants.pm # once (19µs+4µs) by Log::Log4perl::Level::BEGIN@15 at line 15 of Log/Log4perl/Level.pm # once (19µs+4µs) by File::Temp::BEGIN@230 at line 230 of File/Temp.pm # once (19µs+4µs) by File::Temp::BEGIN@224 at line 224 of File/Temp.pm # once (18µs+4µs) by Log::Log4perl::Level::BEGIN@17 at line 17 of Log/Log4perl/Level.pm # once (18µs+5µs) by SQL::Translator::Schema::Constants::BEGIN@85 at line 85 of SQL/Translator/Schema/Constants.pm # once (18µs+4µs) by DateTime::BEGIN@80 at line 80 of DateTime.pm # once (19µs+4µs) by Compress::Bzip2::BEGIN@158 at line 158 of Compress/Bzip2.pm # once (20µs+3µs) by DateTime::BEGIN@78 at line 78 of DateTime.pm # once (18µs+4µs) by Log::Log4perl::Level::BEGIN@20 at line 20 of Log/Log4perl/Level.pm # once (18µs+4µs) by Compress::Bzip2::BEGIN@160 at line 160 of Compress/Bzip2.pm # once (19µs+4µs) by DateTime::BEGIN@82 at line 82 of DateTime.pm # once (18µs+4µs) by File::Temp::BEGIN@229 at line 229 of File/Temp.pm # once (18µs+4µs) by Log::Log4perl::Level::BEGIN@19 at line 19 of Log/Log4perl/Level.pm # once (18µs+4µs) by Log::Log4perl::Level::BEGIN@18 at line 18 of Log/Log4perl/Level.pm # once (19µs+3µs) by DateTime::BEGIN@77 at line 77 of DateTime.pm # once (3µs+0s) by Devel::Backtrace::Point::BEGIN@27 at line 27 of Devel/Backtrace/Point.pm sub import {
43 | 794 | 848µs |  |  | my $class = shift;
44 |  |  |  |  | return unless @_; # Ignore 'use constant;'
45 |  |  |  |  | my $constants;
46 |  |  |  |  | my $multiple = ref $_[0];
47 |  |  |  |  | my $pkg = caller;
48 |  |  |  |  | my $flush_mro;
49 |  |  |  |  | my $symtab;
50 |  |  |  |  |
51 | 72 | 89µs |  |  | if (_CAN_PCS) {
52 | 3 | 438µs | 2 | 26µs | # spent 16µs (5+10) within constant::BEGIN@52 which was called: # once (5µs+10µs) by Class::MOP::Method::Meta::BEGIN@16 at line 52 no strict 'refs'; # spent 16µs making 1 call to constant::BEGIN@52 # spent 10µs making 1 call to strict::unimport
53 |  |  |  |  | $symtab = \%{$pkg . '::'};
54 |  |  |  |  | };
55 |  |  |  |  |
56 | 144 | 115µs |  |  | if ( $multiple ) {
57 |  |  |  |  | if (ref $_[0] ne 'HASH') {
58 |  |  |  |  | require Carp;
59 |  |  |  |  | Carp::croak("Invalid reference type '".ref(shift)."' not 'HASH'");
60 |  |  |  |  | }
61 |  |  |  |  | $constants = shift;
62 |  |  |  |  | } else {
63 |  |  |  |  | unless (defined $_[0]) {
64 |  |  |  |  | require Carp;
65 |  |  |  |  | Carp::croak("Can't use undef as constant name");
66 |  |  |  |  | }
67 |  |  |  |  | $constants->{+shift} = undef;
68 |  |  |  |  | }
69 |  |  |  |  |
70 |  |  |  |  | foreach my $name ( keys %$constants ) {
71 |  |  |  |  | # Normal constant name
72 | 186 | 758µs | 186 | 319µs | if ($name =~ $normal_constant_name and !$forbidden{$name}) { # spent 202µs making 93 calls to constant::CORE:match, avg 2µs/call # spent 117µs making 93 calls to constant::CORE:regcomp, avg 1µ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 |  |  |  |  | {
114 | 3 | 210µs | 2 | 25µs | # spent 16µs (6+9) within constant::BEGIN@114 which was called: # once (6µs+9µs) by Class::MOP::Method::Meta::BEGIN@16 at line 114 no strict 'refs'; # spent 16µs making 1 call to constant::BEGIN@114 # spent 9µs making 1 call to strict::unimport
115 | 279 | 259µs |  |  | my $full_name = "${pkg}::$name";
116 |  |  |  |  | $declared{$full_name}++;
117 | 278 | 367µs |  |  | if ($multiple || @_ == 1) {
118 |  |  |  |  | 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.
123 |  |  | 92 | 67µs | utf8::is_utf8 $name and utf8::encode $name # spent 67µs making 92 calls to utf8::is_utf8, avg 726ns/call
124 |  |  |  |  | if defined &utf8::is_utf8;
125 |  |  |  |  |
126 |  |  |  |  | # The constant serves to optimise this entire block out on
127 |  |  |  |  | # 5.8 and earlier.
128 | 270 | 303µs |  |  | if (_CAN_PCS && $symtab && !exists $symtab->{$name}) {
129 |  |  |  |  | # No typeglob yet, so we can use a reference as space-
130 |  |  |  |  | # efficient proxy for a constant subroutine
131 |  |  |  |  | # The check in Perl_ck_rvconst knows that inlinable
132 |  |  |  |  | # constants from cv_const_sv are read only. So we have to:
133 |  |  | 89 | 69µs | Internals::SvREADONLY($scalar, 1); # spent 69µs making 89 calls to Internals::SvREADONLY, avg 771ns/call
134 |  |  |  |  | $symtab->{$name} = \$scalar;
135 |  |  |  |  | ++$flush_mro;
136 |  |  |  |  | } else {
137 |  |  |  |  | *$full_name = sub () { $scalar };
138 |  |  |  |  | }
139 |  |  |  |  | } elsif (@_) {
140 |  |  |  |  | my @list = @_;
141 | 1 | 6µs |  |  | # spent 4µs within constant::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/5.12.3/constant.pm:141] which was called: # once (4µs+0s) by Devel::Backtrace::BEGIN@4 at line 68 of Devel/Backtrace/Point.pm *$full_name = sub () { @list };
142 |  |  |  |  | } else {
143 |  |  |  |  | *$full_name = sub () { };
144 |  |  |  |  | }
145 |  |  |  |  | }
146 |  |  |  |  | }
147 |  |  |  |  | # Flush the cache exactly once if we make any direct symbol table changes.
148 |  |  | 68 | 113µs | mro::method_changed_in($pkg) if _CAN_PCS && $flush_mro; # spent 113µs making 68 calls to mro::method_changed_in, avg 2µs/call
149 |  |  |  |  | }
150 |  |  |  |  |
151 | 1 | 11µs |  |  | 1;
152 |  |  |  |  |
153 |  |  |  |  | __END__
|  |  |  |  | # spent 202µs within constant::CORE:match which was called 93 times, avg 2µs/call: # 93 times (202µs+0s) by constant::import at line 72, avg 2µs/call sub constant::CORE:match; # opcode
|  |  |  |  | # spent 5µs within constant::CORE:qr which was called 3 times, avg 2µs/call: # once (3µs+0s) by Class::MOP::Method::Meta::BEGIN@16 at line 21 # once (1µs+0s) by Class::MOP::Method::Meta::BEGIN@16 at line 22 # once (1µs+0s) by Class::MOP::Method::Meta::BEGIN@16 at line 23 sub constant::CORE:qr; # opcode
|  |  |  |  | # spent 146µs within constant::CORE:regcomp which was called 96 times, avg 2µs/call: # 93 times (117µs+0s) by constant::import at line 72, avg 1µs/call # once (18µs+0s) by Class::MOP::Method::Meta::BEGIN@16 at line 21 # once (8µs+0s) by Class::MOP::Method::Meta::BEGIN@16 at line 23 # once (4µs+0s) by Class::MOP::Method::Meta::BEGIN@16 at line 22 sub constant::CORE:regcomp; # opcode