← Index
NYTProf Performance Profile   « block view • line view • sub view »
For bin/hailo
  Run on Thu Oct 21 22:50:37 2010
Reported on Thu Oct 21 22:52:07 2010

Filename/home/hinrik/perl5/perlbrew/perls/perl-5.13.5/lib/5.13.5/constant.pm
StatementsExecuted 866 statements in 3.00ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
353551.79ms2.09msconstant::::importconstant::import
351197µs97µsconstant::::CORE:matchconstant::CORE:match (opcode)
384185µs85µsconstant::::CORE:regcompconstant::CORE:regcomp (opcode)
11132µs32µsconstant::::BEGIN@2constant::BEGIN@2
11113µs35µsconstant::::BEGIN@114constant::BEGIN@114
11112µs12µsconstant::::BEGIN@25constant::BEGIN@25
11112µs198µsconstant::::BEGIN@4constant::BEGIN@4
11111µs16µsconstant::::BEGIN@3constant::BEGIN@3
11111µs35µsconstant::::BEGIN@29constant::BEGIN@29
11111µs32µsconstant::::BEGIN@52constant::BEGIN@52
11110µs62µsconstant::::BEGIN@6constant::BEGIN@6
33110µs10µsconstant::::CORE:qrconstant::CORE:qr (opcode)
0000s0sconstant::::__ANON__[:130]constant::__ANON__[:130]
0000s0sconstant::::__ANON__[:134]constant::__ANON__[:134]
0000s0sconstant::::__ANON__[:136]constant::__ANON__[:136]
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;
2238µs132µs
# spent 32µs within constant::BEGIN@2 which was called: # once (32µs+0s) by Getopt::Long::BEGIN@208 at line 2
use 5.005;
# spent 32µs making 1 call to constant::BEGIN@2
3225µs222µs
# spent 16µs (11+5) within constant::BEGIN@3 which was called: # once (11µs+5µs) by Getopt::Long::BEGIN@208 at line 3
use strict;
# spent 16µs making 1 call to constant::BEGIN@3 # spent 5µs making 1 call to strict::import
4229µs2383µs
# spent 198µs (12+186) within constant::BEGIN@4 which was called: # once (12µs+186µs) by Getopt::Long::BEGIN@208 at line 4
use warnings::register;
# spent 198µs making 1 call to constant::BEGIN@4 # spent 186µs making 1 call to warnings::register::import
5
62112µs2114µs
# spent 62µs (10+52) within constant::BEGIN@6 which was called: # once (10µs+52µs) by Getopt::Long::BEGIN@208 at line 6
use vars qw($VERSION %declared);
# spent 62µs making 1 call to constant::BEGIN@6 # spent 52µs making 1 call to vars::import
711µs$VERSION = '1.20';
8
9#=======================================================================
10
11# Some names are evil choices.
1218µsmy %keywords = map +($_, 1), qw{ BEGIN INIT CHECK END DESTROY AUTOLOAD };
1312µs$keywords{UNITCHECK}++ if $] > 5.009;
14
1517µsmy %forced_into_main = map +($_, 1),
16 qw{ STDIN STDOUT STDERR ARGV ARGVOUT ENV INC SIG };
17
1815µsmy %forbidden = (%keywords, %forced_into_main);
19
2012µsmy $str_end = $] >= 5.006 ? "\\z" : "\\Z";
21128µs218µsmy $normal_constant_name = qr/^_?[^\W_0-9]\w*$str_end/;
# spent 12µs making 1 call to constant::CORE:regcomp # spent 6µs making 1 call to constant::CORE:qr
22114µs28µsmy $tolerable = qr/^[A-Za-z_]\w*$str_end/;
# spent 6µs making 1 call to constant::CORE:regcomp # spent 2µs making 1 call to constant::CORE:qr
23114µs27µsmy $boolean = qr/^[01]?$str_end/;
# spent 6µs making 1 call to constant::CORE:regcomp # spent 2µs making 1 call to constant::CORE:qr
24
25
# spent 12µs within constant::BEGIN@25 which was called: # once (12µs+0s) by Getopt::Long::BEGIN@208 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.
29250µs260µs
# spent 35µs (11+25) within constant::BEGIN@29 which was called: # once (11µs+25µs) by Getopt::Long::BEGIN@208 at line 29
no strict 'refs';
# spent 35µs making 1 call to constant::BEGIN@29 # spent 25µs making 1 call to strict::unimport
30212µs my $const = $] > 5.009002;
31 *_CAN_PCS = sub () {$const};
32149µs112µs}
# spent 12µ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.09ms (1.79+292µs) within constant::import which was called 35 times, avg 60µs/call: # once (64µs+12µs) by Fatal::BEGIN@10 at line 10 of Fatal.pm # once (63µs+13µs) by DBD::SQLite::BEGIN@30 at line 30 of DBD/SQLite.pm # once (60µs+13µs) by Getopt::Long::BEGIN@208 at line 208 of Getopt/Long.pm # once (61µs+9µs) by Hailo::BEGIN@11 at line 11 of lib/Hailo.pm # once (60µs+8µs) by Getopt::Long::BEGIN@237 at line 237 of Getopt/Long.pm # once (59µs+8µs) by Getopt::Long::BEGIN@226 at line 226 of Getopt/Long.pm # once (58µs+8µs) by Fatal::BEGIN@21 at line 21 of Fatal.pm # once (54µs+10µs) by autodie::BEGIN@14 at line 14 of autodie.pm # once (53µs+8µs) by Fatal::BEGIN@33 at line 33 of Fatal.pm # once (52µs+7µs) by Fatal::BEGIN@23 at line 23 of Fatal.pm # once (51µs+8µs) by Getopt::Long::BEGIN@220 at line 220 of Getopt/Long.pm # once (50µs+8µs) by Fatal::BEGIN@13 at line 13 of Fatal.pm # once (51µs+7µs) by Fatal::BEGIN@25 at line 25 of Fatal.pm # once (50µs+8µs) by Getopt::Long::BEGIN@229 at line 229 of Getopt/Long.pm # once (50µs+8µs) by Fatal::BEGIN@22 at line 22 of Fatal.pm # once (50µs+8µs) by Fatal::BEGIN@27 at line 27 of Fatal.pm # once (50µs+7µs) by Fatal::BEGIN@29 at line 29 of Fatal.pm # once (49µs+8µs) by Getopt::Long::BEGIN@247 at line 247 of Getopt/Long.pm # once (48µs+9µs) by Getopt::Long::BEGIN@218 at line 218 of Getopt/Long.pm # once (49µs+8µs) by Fatal::BEGIN@17 at line 17 of Fatal.pm # once (48µs+8µs) by Fatal::BEGIN@31 at line 31 of Fatal.pm # once (48µs+8µs) by Getopt::Long::BEGIN@223 at line 223 of Getopt/Long.pm # once (49µs+7µs) by Fatal::BEGIN@40 at line 40 of Fatal.pm # once (48µs+8µs) by Getopt::Long::BEGIN@225 at line 225 of Getopt/Long.pm # once (48µs+8µs) by Fatal::BEGIN@19 at line 19 of Fatal.pm # once (48µs+8µs) by Getopt::Long::BEGIN@228 at line 228 of Getopt/Long.pm # once (48µs+7µs) by Fatal::BEGIN@20 at line 20 of Fatal.pm # once (48µs+7µs) by Fatal::BEGIN@18 at line 18 of Fatal.pm # once (48µs+7µs) by Fatal::BEGIN@35 at line 35 of Fatal.pm # once (47µs+8µs) by Fatal::BEGIN@14 at line 14 of Fatal.pm # once (47µs+8µs) by Fatal::BEGIN@12 at line 12 of Fatal.pm # once (47µs+8µs) by Getopt::Long::BEGIN@222 at line 222 of Getopt/Long.pm # once (47µs+8µs) by Getopt::Long::BEGIN@224 at line 224 of Getopt/Long.pm # once (47µs+7µs) by Fatal::BEGIN@16 at line 16 of Fatal.pm # once (45µs+8µs) by Getopt::Long::BEGIN@236 at line 236 of Getopt/Long.pm
sub import {
43385815µ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
513566µs if (_CAN_PCS) {
522261µs253µs
# spent 32µs (11+21) within constant::BEGIN@52 which was called: # once (11µs+21µs) by Getopt::Long::BEGIN@208 at line 52
no strict 'refs';
# spent 32µs making 1 call to constant::BEGIN@52 # spent 21µs making 1 call to strict::unimport
53 $symtab = \%{$pkg . '::'};
54 };
55
5670118µ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
7270498µs70159µs if ($name =~ $normal_constant_name and !$forbidden{$name}) {
# spent 97µs making 35 calls to constant::CORE:match, avg 3µs/call # spent 61µs making 35 calls to constant::CORE:regcomp, avg 2µ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 {
1142205µs257µs
# spent 35µs (13+22) within constant::BEGIN@114 which was called: # once (13µs+22µs) by Getopt::Long::BEGIN@208 at line 114
no strict 'refs';
# spent 35µs making 1 call to constant::BEGIN@114 # spent 22µs making 1 call to strict::unimport
115105205µs my $full_name = "${pkg}::$name";
116 $declared{$full_name}++;
11770138µs if ($multiple || @_ == 1) {
118 my $scalar = $multiple ? $constants->{$name} : $_[0];
119 # The constant serves to optimise this entire block out on
120 # 5.8 and earlier.
121105292µs if (_CAN_PCS && $symtab && !exists $symtab->{$name}) {
122 # No typeglob yet, so we can use a reference as space-
123 # efficient proxy for a constant subroutine
124 # The check in Perl_ck_rvconst knows that inlinable
125 # constants from cv_const_sv are read only. So we have to:
1263563µs Internals::SvREADONLY($scalar, 1);
# spent 63µs making 35 calls to Internals::SvREADONLY, avg 2µs/call
127 $symtab->{$name} = \$scalar;
128 ++$flush_mro;
129 } else {
130 *$full_name = sub () { $scalar };
131 }
132 } elsif (@_) {
133 my @list = @_;
134 *$full_name = sub () { @list };
135 } else {
136 *$full_name = sub () { };
137 }
138 }
139 }
140 # Flush the cache exactly once if we make any direct symbol table changes.
1413571µs mro::method_changed_in($pkg) if _CAN_PCS && $flush_mro;
# spent 71µs making 35 calls to mro::method_changed_in, avg 2µs/call
142}
143
144110µs1;
145
146__END__
 
# spent 97µs within constant::CORE:match which was called 35 times, avg 3µs/call: # 35 times (97µs+0s) by constant::import at line 72, avg 3µs/call
sub constant::CORE:match; # opcode
# spent 10µs within constant::CORE:qr which was called 3 times, avg 3µs/call: # once (6µs+0s) by Getopt::Long::BEGIN@208 at line 21 # once (2µs+0s) by Getopt::Long::BEGIN@208 at line 22 # once (2µs+0s) by Getopt::Long::BEGIN@208 at line 23
sub constant::CORE:qr; # opcode
# spent 85µs within constant::CORE:regcomp which was called 38 times, avg 2µs/call: # 35 times (61µs+0s) by constant::import at line 72, avg 2µs/call # once (12µs+0s) by Getopt::Long::BEGIN@208 at line 21 # once (6µs+0s) by Getopt::Long::BEGIN@208 at line 22 # once (6µs+0s) by Getopt::Long::BEGIN@208 at line 23
sub constant::CORE:regcomp; # opcode