← Index
NYTProf Performance Profile   « block view • line view • sub view »
For conv.pl
  Run on Sun Nov 14 22:50:31 2010
Reported on Sun Nov 14 22:51:20 2010

Filename/usr/share/perl/5.10/constant.pm
StatementsExecuted 2108 statements in 7.55ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
818165.24ms6.25msconstant::::importconstant::import
10111309µs309µsconstant::::CORE:matchconstant::CORE:match (opcode)
10111198µs198µsconstant::::CORE:regcompconstant::CORE:regcomp (opcode)
11138µs38µsconstant::::BEGIN@2constant::BEGIN@2
11121µs28µsconstant::::BEGIN@3constant::BEGIN@3
11118µs184µsconstant::::BEGIN@4constant::BEGIN@4
11115µs38µsconstant::::BEGIN@101constant::BEGIN@101
11114µs80µsconstant::::BEGIN@6constant::BEGIN@6
11113µs42µsconstant::::BEGIN@38constant::BEGIN@38
0000s0sconstant::::__ANON__[:115]constant::__ANON__[:115]
0000s0sconstant::::__ANON__[:119]constant::__ANON__[:119]
0000s0sconstant::::__ANON__[:121]constant::__ANON__[:121]
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package constant;
2362µs138µs
# spent 38µs within constant::BEGIN@2 which was called: # once (38µs+0s) by MARC::Field::BEGIN@7 at line 2
use 5.005;
# spent 38µs making 1 call to constant::BEGIN@2
3348µs235µs
# spent 28µs (21+7) within constant::BEGIN@3 which was called: # once (21µs+7µs) by MARC::Field::BEGIN@7 at line 3
use strict;
# spent 28µs making 1 call to constant::BEGIN@3 # spent 7µs making 1 call to strict::import
4347µs2350µs
# spent 184µs (18+166) within constant::BEGIN@4 which was called: # once (18µs+166µs) by MARC::Field::BEGIN@7 at line 4
use warnings::register;
# spent 184µs making 1 call to constant::BEGIN@4 # spent 166µs making 1 call to warnings::register::import
5
63194µs2146µs
# spent 80µs (14+66) within constant::BEGIN@6 which was called: # once (14µs+66µs) by MARC::Field::BEGIN@7 at line 6
use vars qw($VERSION %declared);
# spent 80µs making 1 call to constant::BEGIN@6 # spent 66µs making 1 call to vars::import
712µs$VERSION = '1.17';
8
9#=======================================================================
10
11# Some names are evil choices.
1219µ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
1818µsmy %forbidden = (%keywords, %forced_into_main);
19
20#=======================================================================
21# import() - import symbols into user's namespace
22#
23# What we actually do is define a function in the caller's namespace
24# which returns the value. The function we create will normally
25# be inlined as a constant, thereby avoiding further sub calling
26# overhead.
27#=======================================================================
28
# spent 6.25ms (5.24+1.01) within constant::import which was called 81 times, avg 77µs/call: # once (671µs+178µs) by XML::LibXML::BEGIN@234 at line 235 of XML/LibXML.pm # once (119µs+41µs) by MARC::Field::BEGIN@7 at line 7 of MARC/Field.pm # once (103µs+10µs) by XML::LibXML::Error::BEGIN@30 at line 30 of XML/LibXML/Error.pm # once (70µs+14µs) by MARC::Charset::Constants::BEGIN@22 at line 22 of MARC/Charset/Constants.pm # once (69µs+14µs) by XML::LibXML::BEGIN@159 at line 159 of XML/LibXML.pm # once (66µs+14µs) by MARC::File::USMARC::BEGIN@19 at line 19 of MARC/File/USMARC.pm # once (65µs+13µs) by MARC::Charset::Constants::BEGIN@26 at line 26 of MARC/Charset/Constants.pm # once (65µs+11µs) by XML::LibXML::BEGIN@259 at line 259 of XML/LibXML.pm # once (65µs+10µs) by XML::LibXML::Error::BEGIN@38 at line 38 of XML/LibXML/Error.pm # once (64µs+10µs) by MARC::Charset::Constants::BEGIN@41 at line 41 of MARC/Charset/Constants.pm # once (65µs+9µs) by XML::LibXML::Error::BEGIN@45 at line 45 of XML/LibXML/Error.pm # once (63µs+10µs) by XML::LibXML::Error::BEGIN@37 at line 37 of XML/LibXML/Error.pm # once (63µs+9µs) by XML::LibXML::BEGIN@166 at line 166 of XML/LibXML.pm # once (62µs+10µs) by XML::LibXML::BEGIN@20 at line 20 of XML/LibXML.pm # once (61µs+10µs) by XML::LibXML::Error::BEGIN@39 at line 39 of XML/LibXML/Error.pm # once (59µs+10µs) by XML::LibXML::Error::BEGIN@54 at line 54 of XML/LibXML/Error.pm # once (57µs+12µs) by MARC::File::USMARC::BEGIN@21 at line 21 of MARC/File/USMARC.pm # once (58µs+11µs) by MARC::File::USMARC::BEGIN@20 at line 20 of MARC/File/USMARC.pm # once (59µs+10µs) by XML::LibXML::BEGIN@167 at line 167 of XML/LibXML.pm # once (57µs+11µs) by XML::LibXML::Error::BEGIN@34 at line 34 of XML/LibXML/Error.pm # once (58µs+10µs) by XML::LibXML::BEGIN@21 at line 21 of XML/LibXML.pm # once (57µs+10µs) by MARC::Charset::Constants::BEGIN@44 at line 44 of MARC/Charset/Constants.pm # once (57µs+10µs) by MARC::Charset::Constants::BEGIN@34 at line 34 of MARC/Charset/Constants.pm # once (57µs+10µs) by XML::LibXML::BEGIN@163 at line 163 of XML/LibXML.pm # once (57µs+10µs) by XML::LibXML::BEGIN@164 at line 164 of XML/LibXML.pm # once (56µs+10µs) by MARC::Charset::Constants::BEGIN@25 at line 25 of MARC/Charset/Constants.pm # once (57µs+9µs) by MARC::Charset::Constants::BEGIN@36 at line 36 of MARC/Charset/Constants.pm # once (55µs+11µs) by XML::LibXML::Error::BEGIN@33 at line 33 of XML/LibXML/Error.pm # once (57µs+9µs) by XML::LibXML::BEGIN@161 at line 161 of XML/LibXML.pm # once (56µs+10µs) by MARC::Record::BEGIN@34 at line 34 of MARC/Record.pm # once (55µs+10µs) by MARC::Charset::Constants::BEGIN@46 at line 46 of MARC/Charset/Constants.pm # once (55µs+10µs) by MARC::Charset::Constants::BEGIN@29 at line 29 of MARC/Charset/Constants.pm # once (55µs+10µs) by MARC::Charset::Constants::BEGIN@40 at line 40 of MARC/Charset/Constants.pm # once (55µs+10µs) by MARC::Charset::Constants::BEGIN@37 at line 37 of MARC/Charset/Constants.pm # once (54µs+11µs) by XML::LibXML::Error::BEGIN@55 at line 55 of XML/LibXML/Error.pm # once (55µs+10µs) by XML::LibXML::Error::BEGIN@36 at line 36 of XML/LibXML/Error.pm # once (56µs+9µs) by XML::LibXML::Error::BEGIN@51 at line 51 of XML/LibXML/Error.pm # once (55µs+10µs) by XML::LibXML::Error::BEGIN@41 at line 41 of XML/LibXML/Error.pm # once (53µs+11µs) by MARC::Charset::Constants::BEGIN@35 at line 35 of MARC/Charset/Constants.pm # once (55µs+9µs) by MARC::Charset::Constants::BEGIN@42 at line 42 of MARC/Charset/Constants.pm # once (55µs+9µs) by XML::LibXML::Error::BEGIN@46 at line 46 of XML/LibXML/Error.pm # once (53µs+11µs) by XML::LibXML::Error::BEGIN@27 at line 27 of XML/LibXML/Error.pm # once (54µs+10µs) by XML::LibXML::Error::BEGIN@28 at line 28 of XML/LibXML/Error.pm # once (54µs+10µs) by XML::LibXML::Error::BEGIN@52 at line 52 of XML/LibXML/Error.pm # once (54µs+10µs) by MARC::Field::BEGIN@8 at line 8 of MARC/Field.pm # once (55µs+9µs) by XML::LibXML::BEGIN@174 at line 174 of XML/LibXML.pm # once (54µs+10µs) by XML::LibXML::BEGIN@162 at line 162 of XML/LibXML.pm # once (54µs+10µs) by XML::LibXML::BEGIN@173 at line 173 of XML/LibXML.pm # once (54µs+10µs) by XML::LibXML::BEGIN@177 at line 177 of XML/LibXML.pm # once (54µs+10µs) by XML::LibXML::BEGIN@178 at line 178 of XML/LibXML.pm # once (54µs+10µs) by XML::LibXML::BEGIN@171 at line 171 of XML/LibXML.pm # once (53µs+10µs) by MARC::Charset::Constants::BEGIN@30 at line 30 of MARC/Charset/Constants.pm # once (51µs+12µs) by MARC::Charset::Constants::BEGIN@27 at line 27 of MARC/Charset/Constants.pm # once (54µs+9µs) by MARC::Charset::Constants::BEGIN@39 at line 39 of MARC/Charset/Constants.pm # once (53µs+10µs) by MARC::Charset::Constants::BEGIN@43 at line 43 of MARC/Charset/Constants.pm # once (53µs+10µs) by MARC::Charset::Constants::BEGIN@31 at line 31 of MARC/Charset/Constants.pm # once (54µs+9µs) by XML::LibXML::Error::BEGIN@32 at line 32 of XML/LibXML/Error.pm # once (55µs+8µs) by XML::LibXML::Error::BEGIN@53 at line 53 of XML/LibXML/Error.pm # once (53µs+10µs) by XML::LibXML::Error::BEGIN@48 at line 48 of XML/LibXML/Error.pm # once (53µs+10µs) by XML::LibXML::Error::BEGIN@42 at line 42 of XML/LibXML/Error.pm # once (53µs+10µs) by XML::LibXML::Error::BEGIN@29 at line 29 of XML/LibXML/Error.pm # once (53µs+10µs) by XML::LibXML::Error::BEGIN@43 at line 43 of XML/LibXML/Error.pm # once (54µs+9µs) by XML::LibXML::BEGIN@165 at line 165 of XML/LibXML.pm # once (53µs+10µs) by XML::LibXML::BEGIN@169 at line 169 of XML/LibXML.pm # once (53µs+9µs) by MARC::Charset::Constants::BEGIN@32 at line 32 of MARC/Charset/Constants.pm # once (52µs+10µs) by XML::LibXML::Error::BEGIN@44 at line 44 of XML/LibXML/Error.pm # once (53µs+9µs) by XML::LibXML::Error::BEGIN@40 at line 40 of XML/LibXML/Error.pm # once (52µs+10µs) by XML::LibXML::Error::BEGIN@47 at line 47 of XML/LibXML/Error.pm # once (53µs+9µs) by XML::LibXML::Error::BEGIN@49 at line 49 of XML/LibXML/Error.pm # once (52µs+10µs) by XML::LibXML::BEGIN@170 at line 170 of XML/LibXML.pm # once (51µs+11µs) by XML::LibXML::BEGIN@160 at line 160 of XML/LibXML.pm # once (52µs+10µs) by XML::LibXML::BEGIN@176 at line 176 of XML/LibXML.pm # once (51µs+10µs) by MARC::Charset::Constants::BEGIN@47 at line 47 of MARC/Charset/Constants.pm # once (51µs+10µs) by MARC::Charset::Constants::BEGIN@24 at line 24 of MARC/Charset/Constants.pm # once (51µs+10µs) by MARC::Charset::Constants::BEGIN@45 at line 45 of MARC/Charset/Constants.pm # once (52µs+9µs) by XML::LibXML::Error::BEGIN@35 at line 35 of XML/LibXML/Error.pm # once (52µs+9µs) by XML::LibXML::Error::BEGIN@50 at line 50 of XML/LibXML/Error.pm # once (52µs+9µs) by MARC::File::USMARC::BEGIN@22 at line 22 of MARC/File/USMARC.pm # once (51µs+9µs) by XML::LibXML::BEGIN@172 at line 172 of XML/LibXML.pm # once (51µs+8µs) by XML::LibXML::BEGIN@168 at line 168 of XML/LibXML.pm # once (51µs+8µs) by XML::LibXML::BEGIN@175 at line 175 of XML/LibXML.pm
sub import {
2920846.47ms my $class = shift;
30 return unless @_; # Ignore 'use constant;'
31 my $constants;
32 my $multiple = ref $_[0];
33 my $pkg = caller;
34 my $symtab;
35 my $str_end = $] >= 5.006 ? "\\z" : "\\Z";
36
37 if ($] > 5.009002) {
383403µs271µs
# spent 42µs (13+29) within constant::BEGIN@38 which was called: # once (13µs+29µs) by MARC::Field::BEGIN@7 at line 38
no strict 'refs';
# spent 42µs making 1 call to constant::BEGIN@38 # spent 29µs making 1 call to strict::unimport
39 $symtab = \%{$pkg . '::'};
40 };
41
42 if ( $multiple ) {
43 if (ref $_[0] ne 'HASH') {
44 require Carp;
45 Carp::croak("Invalid reference type '".ref(shift)."' not 'HASH'");
46 }
47 $constants = shift;
48 } else {
49 $constants->{+shift} = undef;
50 }
51
52 foreach my $name ( keys %$constants ) {
53 unless (defined $name) {
54 require Carp;
55 Carp::croak("Can't use undef as constant name");
56 }
57
58 # Normal constant name
59202507µs if ($name =~ /^_?[^\W_0-9]\w*$str_end/ and !$forbidden{$name}) {
# spent 309µs making 101 calls to constant::CORE:match, avg 3µs/call # spent 198µs making 101 calls to constant::CORE:regcomp, avg 2µs/call
60 # Everything is okay
61
62 # Name forced into main, but we're not in main. Fatal.
63 } elsif ($forced_into_main{$name} and $pkg ne 'main') {
64 require Carp;
65 Carp::croak("Constant name '$name' is forced into main::");
66
67 # Starts with double underscore. Fatal.
68 } elsif ($name =~ /^__/) {
69 require Carp;
70 Carp::croak("Constant name '$name' begins with '__'");
71
72 # Maybe the name is tolerable
73 } elsif ($name =~ /^[A-Za-z_]\w*$str_end/) {
74 # Then we'll warn only if you've asked for warnings
75 if (warnings::enabled()) {
76 if ($keywords{$name}) {
77 warnings::warn("Constant name '$name' is a Perl keyword");
78 } elsif ($forced_into_main{$name}) {
79 warnings::warn("Constant name '$name' is " .
80 "forced into package main::");
81 }
82 }
83
84 # Looks like a boolean
85 # use constant FRED == fred;
86 } elsif ($name =~ /^[01]?$str_end/) {
87 require Carp;
88 if (@_) {
89 Carp::croak("Constant name '$name' is invalid");
90 } else {
91 Carp::croak("Constant name looks like boolean value");
92 }
93
94 } else {
95 # Must have bad characters
96 require Carp;
97 Carp::croak("Constant name '$name' has invalid characters");
98 }
99
100 {
1013289µs261µs
# spent 38µs (15+23) within constant::BEGIN@101 which was called: # once (15µs+23µs) by MARC::Field::BEGIN@7 at line 101
no strict 'refs';
# spent 38µs making 1 call to constant::BEGIN@101 # spent 23µs making 1 call to strict::unimport
102 my $full_name = "${pkg}::$name";
103 $declared{$full_name}++;
104 if ($multiple || @_ == 1) {
105 my $scalar = $multiple ? $constants->{$name} : $_[0];
106 if ($symtab && !exists $symtab->{$name}) {
107 # No typeglob yet, so we can use a reference as space-
108 # efficient proxy for a constant subroutine
109 # The check in Perl_ck_rvconst knows that inlinable
110 # constants from cv_const_sv are read only. So we have to:
111101213µs Internals::SvREADONLY($scalar, 1);
# spent 213µs making 101 calls to Internals::SvREADONLY, avg 2µs/call
112 $symtab->{$name} = \$scalar;
113101292µs mro::method_changed_in($pkg);
# spent 292µs making 101 calls to mro::method_changed_in, avg 3µs/call
114 } else {
115 *$full_name = sub () { $scalar };
116 }
117 } elsif (@_) {
118 my @list = @_;
119 *$full_name = sub () { @list };
120 } else {
121 *$full_name = sub () { };
122 }
123 }
124 }
125}
126
127112µs1;
128
129__END__
 
# spent 309µs within constant::CORE:match which was called 101 times, avg 3µs/call: # 101 times (309µs+0s) by constant::import at line 59, avg 3µs/call
sub constant::CORE:match; # opcode
# spent 198µs within constant::CORE:regcomp which was called 101 times, avg 2µs/call: # 101 times (198µs+0s) by constant::import at line 59, avg 2µs/call
sub constant::CORE:regcomp; # opcode