← Index
NYTProf Performance Profile   « block view • line view • sub view »
For bin/pan_genome_post_analysis
  Run on Fri Mar 27 11:43:32 2015
Reported on Fri Mar 27 11:45:56 2015

Filename/Users/ap13/perl5/perlbrew/perls/perl-5.16.2/lib/5.16.2/constant.pm
StatementsExecuted 777 statements in 3.05ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
313110840µs1.04msconstant::::importconstant::import
111358µs358µsconstant::::BEGIN@36constant::BEGIN@36
111296µs21.6msconstant::::BEGIN@25constant::BEGIN@25
344176µs76µsconstant::::CORE:regcompconstant::CORE:regcomp (opcode)
311170µs70µsconstant::::CORE:matchconstant::CORE:match (opcode)
11132µs32µsconstant::::BEGIN@2constant::BEGIN@2
11115µs198µsconstant::::BEGIN@4constant::BEGIN@4
11115µs78µsconstant::::BEGIN@6constant::BEGIN@6
11114µs35µsconstant::::BEGIN@29constant::BEGIN@29
11113µs42µsconstant::::BEGIN@3constant::BEGIN@3
11113µs32µsconstant::::BEGIN@65constant::BEGIN@65
1118µs20µsconstant::::BEGIN@127constant::BEGIN@127
3315µs5µ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;
2288µs132µs
# spent 32µs within constant::BEGIN@2 which was called: # once (32µs+0s) by Try::Tiny::ScopeGuard::BEGIN@144 at line 2
use 5.005;
# spent 32µs making 1 call to constant::BEGIN@2
3240µs271µs
# spent 42µs (13+29) within constant::BEGIN@3 which was called: # once (13µs+29µs) by Try::Tiny::ScopeGuard::BEGIN@144 at line 3
use strict;
# spent 42µs making 1 call to constant::BEGIN@3 # spent 29µs making 1 call to strict::import
4249µs2382µs
# spent 198µs (15+183) within constant::BEGIN@4 which was called: # once (15µs+183µs) by Try::Tiny::ScopeGuard::BEGIN@144 at line 4
use warnings::register;
# spent 198µs making 1 call to constant::BEGIN@4 # spent 183µs making 1 call to warnings::register::import
5
62222µs2140µs
# spent 78µs (15+63) within constant::BEGIN@6 which was called: # once (15µs+63µs) by Try::Tiny::ScopeGuard::BEGIN@144 at line 6
use vars qw($VERSION %declared);
# spent 78µs making 1 call to constant::BEGIN@6 # spent 63µs making 1 call to vars::import
71800ns$VERSION = '1.23';
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
1816µsmy %forbidden = (%keywords, %forced_into_main);
19
201700nsmy $str_end = $] >= 5.006 ? "\\z" : "\\Z";
21130µs219µsmy $normal_constant_name = qr/^_?[^\W_0-9]\w*$str_end/;
# spent 16µs making 1 call to constant::CORE:regcomp # spent 3µs making 1 call to constant::CORE:qr
22111µs26µsmy $tolerable = qr/^[A-Za-z_]\w*$str_end/;
# spent 5µs making 1 call to constant::CORE:regcomp # spent 1µs making 1 call to constant::CORE:qr
23110µs26µsmy $boolean = qr/^[01]?$str_end/;
# spent 5µs making 1 call to constant::CORE:regcomp # spent 900ns making 1 call to constant::CORE:qr
24
25
# spent 21.6ms (296µs+21.3) within constant::BEGIN@25 which was called: # once (296µs+21.3ms) by Try::Tiny::ScopeGuard::BEGIN@144 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.
292251µs257µs
# spent 35µs (14+22) within constant::BEGIN@29 which was called: # once (14µs+22µs) by Try::Tiny::ScopeGuard::BEGIN@144 at line 29
no strict 'refs';
# spent 35µs making 1 call to constant::BEGIN@29 # spent 22µs making 1 call to strict::unimport
3013µs my $const = $] > 5.009002;
3118µ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....
351200ns return unless $const;
363587µs14.96ms
# spent 358µs within constant::BEGIN@36 which was called: # once (358µs+0s) by constant::BEGIN@25 at line 45
*{chr 256} = \3;
# spent 4.96ms making 1 call to utf8::AUTOLOAD
3716µs if (exists ${__PACKAGE__."::"}{"\xc4\x80"}) {
38 delete ${__PACKAGE__."::"}{"\xc4\x80"};
39 *_DOWNGRADE = sub () {1};
40 }
41 else {
4213µs delete ${__PACKAGE__."::"}{chr 256};
4312µs *_DOWNGRADE = sub () {0};
44 }
451125µs221.9ms}
# spent 21.6ms making 1 call to constant::BEGIN@25 # spent 358µs 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 1.04ms (840µs+198µs) within constant::import which was called 31 times, avg 33µs/call: # once (63µs+15µs) by Class::MOP::Mixin::HasOverloads::BEGIN@50 at line 50 of Class/MOP/Mixin/HasOverloads.pm # once (41µs+12µs) by Bio::Tools::CodonTable::BEGIN@199 at line 199 of Bio/Tools/CodonTable.pm # once (38µs+14µs) by Try::Tiny::ScopeGuard::BEGIN@144 at line 144 of Try/Tiny.pm # once (43µs+9µs) by File::Spec::Unix::BEGIN@127 at line 127 of File/Spec/Unix.pm # once (39µs+12µs) by File::Temp::BEGIN@84 at line 84 of File/Temp.pm # once (36µs+15µs) by Class::MOP::Method::Meta::BEGIN@10 at line 10 of Class/MOP/Method/Meta.pm # once (42µs+9µs) by Getopt::Long::BEGIN@219 at line 219 of Getopt/Long.pm # once (40µs+8µs) by Data::Dumper::BEGIN@272 at line 272 of Data/Dumper.pm # once (39µs+8µs) by Moose::Meta::Role::Application::ToInstance::BEGIN@19 at line 19 of Moose/Meta/Role/Application/ToInstance.pm # once (38µs+8µs) by Text::Glob::BEGIN@13 at line 13 of Text/Glob.pm # once (24µs+5µs) by File::Spec::Unix::BEGIN@242 at line 242 of File/Spec/Unix.pm # once (23µs+5µs) by File::Spec::Unix::BEGIN@220 at line 220 of File/Spec/Unix.pm # once (23µs+4µs) by Getopt::Long::BEGIN@231 at line 231 of Getopt/Long.pm # once (22µs+5µs) by File::Spec::Unix::BEGIN@136 at line 136 of File/Spec/Unix.pm # once (23µs+4µs) by Getopt::Long::BEGIN@248 at line 257 of Getopt/Long.pm # once (21µs+5µs) by Getopt::Long::BEGIN@229 at line 229 of Getopt/Long.pm # once (21µs+4µs) by File::Temp::BEGIN@87 at line 87 of File/Temp.pm # once (20µs+5µs) by Getopt::Long::BEGIN@235 at line 235 of Getopt/Long.pm # once (20µs+4µs) by File::Temp::BEGIN@91 at line 91 of File/Temp.pm # once (20µs+4µs) by File::Spec::Unix::BEGIN@145 at line 145 of File/Spec/Unix.pm # once (19µs+4µs) by Getopt::Long::BEGIN@233 at line 233 of Getopt/Long.pm # once (19µs+4µs) by File::Temp::BEGIN@95 at line 95 of File/Temp.pm # once (19µs+4µs) by Getopt::Long::BEGIN@236 at line 236 of Getopt/Long.pm # once (19µs+4µs) by File::Temp::BEGIN@96 at line 96 of File/Temp.pm # once (19µs+4µs) by Getopt::Long::BEGIN@234 at line 234 of Getopt/Long.pm # once (19µs+4µs) by Getopt::Long::BEGIN@258 at line 258 of Getopt/Long.pm # once (18µs+4µs) by File::Temp::BEGIN@97 at line 97 of File/Temp.pm # once (18µs+4µs) by Getopt::Long::BEGIN@239 at line 239 of Getopt/Long.pm # once (18µs+4µs) by Getopt::Long::BEGIN@237 at line 237 of Getopt/Long.pm # once (18µs+4µs) by Getopt::Long::BEGIN@240 at line 240 of Getopt/Long.pm # once (18µs+4µs) by Getopt::Long::BEGIN@247 at line 247 of Getopt/Long.pm
sub import {
563114µs my $class = shift;
573112µs return unless @_; # Ignore 'use constant;'
58313µs my $constants;
593112µs my $multiple = ref $_[0];
603124µs my $pkg = caller;
61313µs my $flush_mro;
62312µs my $symtab;
63
643111µs if (_CAN_PCS) {
652299µs252µs
# spent 32µs (13+19) within constant::BEGIN@65 which was called: # once (13µs+19µs) by Try::Tiny::ScopeGuard::BEGIN@144 at line 65
no strict 'refs';
# spent 32µs making 1 call to constant::BEGIN@65 # spent 19µs making 1 call to strict::unimport
663139µs $symtab = \%{$pkg . '::'};
67 };
68
69317µs if ( $multiple ) {
70 if (ref $_[0] ne 'HASH') {
71 require Carp;
72 Carp::croak("Invalid reference type '".ref(shift)."' not 'HASH'");
73 }
74 $constants = shift;
75 } else {
76319µs unless (defined $_[0]) {
77 require Carp;
78 Carp::croak("Can't use undef as constant name");
79 }
803141µs $constants->{+shift} = undef;
81 }
82
833155µs foreach my $name ( keys %$constants ) {
84 # Normal constant name
8531263µs62121µs if ($name =~ $normal_constant_name and !$forbidden{$name}) {
# spent 70µs making 31 calls to constant::CORE:match, avg 2µs/call # spent 51µs making 31 calls to constant::CORE:regcomp, avg 2µ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 {
12733290µs231µs
# spent 20µs (8+12) within constant::BEGIN@127 which was called: # once (8µs+12µs) by Try::Tiny::ScopeGuard::BEGIN@144 at line 127
no strict 'refs';
# spent 20µs making 1 call to constant::BEGIN@127 # spent 12µs making 1 call to strict::unimport
1283126µs my $full_name = "${pkg}::$name";
1293134µs $declared{$full_name}++;
1303121µs if ($multiple || @_ == 1) {
1313114µ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.
1423124µ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:
14731104µs3137µs Internals::SvREADONLY($scalar, 1);
# spent 37µs making 31 calls to Internals::SvREADONLY, avg 1µs/call
1483123µs $symtab->{$name} = \$scalar;
1493111µ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.
16231226µs3140µs mro::method_changed_in($pkg) if _CAN_PCS && $flush_mro;
# spent 40µs making 31 calls to mro::method_changed_in, avg 1µs/call
163}
164
165120µs1;
166
167__END__
 
# spent 70µs within constant::CORE:match which was called 31 times, avg 2µs/call: # 31 times (70µs+0s) by constant::import at line 85, 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 Try::Tiny::ScopeGuard::BEGIN@144 at line 21 # once (1µs+0s) by Try::Tiny::ScopeGuard::BEGIN@144 at line 22 # once (900ns+0s) by Try::Tiny::ScopeGuard::BEGIN@144 at line 23
sub constant::CORE:qr; # opcode
# spent 76µs within constant::CORE:regcomp which was called 34 times, avg 2µs/call: # 31 times (51µs+0s) by constant::import at line 85, avg 2µs/call # once (16µs+0s) by Try::Tiny::ScopeGuard::BEGIN@144 at line 21 # once (5µs+0s) by Try::Tiny::ScopeGuard::BEGIN@144 at line 22 # once (5µs+0s) by Try::Tiny::ScopeGuard::BEGIN@144 at line 23
sub constant::CORE:regcomp; # opcode