← Index
NYTProf Performance Profile   « block view • line view • sub view »
For lexer.pl
  Run on Thu Mar 22 18:01:49 2012
Reported on Thu Mar 22 18:02:03 2012

Filename/System/Library/Perl/5.12/Exporter.pm
StatementsExecuted 41 statements in 177µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
222123µs129µsExporter::::importExporter::import
4116µs6µsExporter::::CORE:matchExporter::CORE:match (opcode)
0000s0sExporter::::__ANON__[:62]Exporter::__ANON__[:62]
0000s0sExporter::::as_heavyExporter::as_heavy
0000s0sExporter::::exportExporter::export
0000s0sExporter::::export_failExporter::export_fail
0000s0sExporter::::export_ok_tagsExporter::export_ok_tags
0000s0sExporter::::export_tagsExporter::export_tags
0000s0sExporter::::export_to_levelExporter::export_to_level
0000s0sExporter::::require_versionExporter::require_version
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Exporter;
2
3127µsrequire 5.006;
4
5# Be lean.
6#use strict;
7#no strict 'refs';
8
91400nsour $Debug = 0;
101200nsour $ExportLevel = 0;
111400nsour $Verbose ||= 0;
121600nsour $VERSION = '5.64_01';
131300nsour (%Cache);
14
15sub as_heavy {
16 require Exporter::Heavy;
17 # Unfortunately, this does not work if the caller is aliased as *name = \&foo
18 # Thus the need to create a lot of identical subroutines
19 my $c = (caller(1))[3];
20 $c =~ s/.*:://;
21 \&{"Exporter::Heavy::heavy_$c"};
22}
23
24sub export {
25 goto &{as_heavy()};
26}
27
28
# spent 129µs (123+6) within Exporter::import which was called 2 times, avg 64µs/call: # once (77µs+4µs) by Data::Dumper::BEGIN@20 at line 20 of Data/Dumper.pm # once (46µs+2µs) by Parse::Lexer::BEGIN@17 at line 17 of Parse/Lexer.pm
sub import {
2922µs my $pkg = shift;
3022µs my $callpkg = caller($ExportLevel);
31
3221µs if ($pkg eq "Exporter" and @_ and $_[0] eq "import") {
33 *{$callpkg."::import"} = \&import;
34 return;
35 }
36
37 # We *need* to treat @{"$pkg\::EXPORT_FAIL"} since Carp uses it :-(
38211µs my($exports, $fail) = (\@{"$pkg\::EXPORT"}, \@{"$pkg\::EXPORT_FAIL"});
3926µs return export $pkg, $callpkg, @_
40 if $Verbose or $Debug or @$fail > 1;
4124µs my $export_cache = ($Cache{$pkg} ||= {});
4226µs my $args = @_ or @_ = @$exports;
43
442500ns local $_;
452500ns if ($args and not %$export_cache) {
46 s/^&//, $export_cache->{$_} = 1
47 foreach (@$exports, @{"$pkg\::EXPORT_OK"});
48 }
492300ns my $heavy;
50 # Try very hard not to use {} and hence have to enter scope on the foreach
51 # We bomb out of the loop with last as soon as heavy is set.
5222µs if ($args or $fail) {
53 ($heavy = (/\W/ or $args and not exists $export_cache->{$_}
54 or @$fail and $_ eq $fail->[0])) and last
55440µs46µs foreach (@_);
# spent 6µs making 4 calls to Exporter::CORE:match, avg 2µs/call
56 } else {
57 ($heavy = /\W/) and last
58 foreach (@_);
59 }
602300ns return export $pkg, $callpkg, ($args ? @_ : ()) if $heavy;
61 local $SIG{__WARN__} =
62215µs sub {require Carp; &Carp::carp};
63 # shortcut for the common case of no type character
64441µs *{"$callpkg\::$_"} = \&{"$pkg\::$_"} foreach @_;
65}
66
67# Default methods
68
69sub export_fail {
70 my $self = shift;
71 @_;
72}
73
74# Unfortunately, caller(1)[3] "does not work" if the caller is aliased as
75# *name = \&foo. Thus the need to create a lot of identical subroutines
76# Otherwise we could have aliased them to export().
77
78sub export_to_level {
79 goto &{as_heavy()};
80}
81
82sub export_tags {
83 goto &{as_heavy()};
84}
85
86sub export_ok_tags {
87 goto &{as_heavy()};
88}
89
90sub require_version {
91 goto &{as_heavy()};
92}
93
94117µs1;
95__END__
 
# spent 6µs within Exporter::CORE:match which was called 4 times, avg 2µs/call: # 4 times (6µs+0s) by Exporter::import at line 55, avg 2µs/call
sub Exporter::CORE:match; # opcode