Profile of Exporter.pm

← Index
NYTProf Performance Profile «block view•line view•sub view»
For bin/dpath
Run on Tue Jun 5 15:31:33 2012
Reported on Tue Jun 5 15:31:37 2012

Filename | /home/ss5/perl5/perlbrew/perls/perl-5.14.1/lib/5.14.1/Exporter.pm
Statements | Executed 580 statements in 11.0ms

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
37 | 37 | 23 | 8.87ms | 30.2ms | Exporter::::importExporter::import
3 | 2 | 1 | 6.59ms | 6.91ms | Exporter::::as_heavyExporter::as_heavy
239 | 2 | 1 | 558µs | 558µs | Exporter::::CORE:matchExporter::CORE:match (opcode)
233 | 2 | 1 | 345µs | 345µs | Exporter::::CORE:substExporter::CORE:subst (opcode)
2 | 1 | 1 | 49µs | 6.90ms | Exporter::::exportExporter::export
1 | 1 | 1 | 24µs | 86µs | Exporter::::export_ok_tagsExporter::export_ok_tags
0 | 0 | 0 | 0s | 0s | Exporter::::__ANON__[:64]Exporter::__ANON__[:64]
0 | 0 | 0 | 0s | 0s | Exporter::::export_failExporter::export_fail
0 | 0 | 0 | 0s | 0s | Exporter::::export_tagsExporter::export_tags
0 | 0 | 0 | 0s | 0s | Exporter::::export_to_levelExporter::export_to_level
0 | 0 | 0 | 0s | 0s | Exporter::::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
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | package Exporter;
2 |  |  |  |  |
3 | 1 | 57µs |  |  | require 5.006;
4 |  |  |  |  |
5 |  |  |  |  | # Be lean.
6 |  |  |  |  | #use strict;
7 |  |  |  |  | #no strict 'refs';
8 |  |  |  |  |
9 | 1 | 2µs |  |  | our $Debug = 0;
10 | 1 | 1µs |  |  | our $ExportLevel = 0;
11 | 1 | 2µs |  |  | our $Verbose ||= 0;
12 | 1 | 2µs |  |  | our $VERSION = '5.66';
13 | 1 | 1µs |  |  | our (%Cache);
14 |  |  |  |  |
15 |  |  |  |  | # spent 6.91ms (6.59+325µs) within Exporter::as_heavy which was called 3 times, avg 2.30ms/call: # 2 times (6.55ms+304µs) by Exporter::export at line 25, avg 3.42ms/call # once (40µs+22µs) by Exporter::export_ok_tags at line 89 sub as_heavy {
16 | 12 | 633µs |  |  | 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 |  |  | 3 | 56µs | $c =~ s/.*:://; # spent 56µs making 3 calls to Exporter::CORE:subst, avg 19µs/call
21 |  |  |  |  | \&{"Exporter::Heavy::heavy_$c"};
22 |  |  |  |  | }
23 |  |  |  |  |
24 |  |  |  |  | # spent 6.90ms (49µs+6.85) within Exporter::export which was called 2 times, avg 3.45ms/call: # 2 times (49µs+6.85ms) by Exporter::import at line 62, avg 3.45ms/call sub export {
25 | 2 | 54µs | 4 | 20.5ms | goto &{as_heavy()}; # spent 13.6ms making 2 calls to Exporter::Heavy::heavy_export, avg 6.81ms/call # spent 6.85ms making 2 calls to Exporter::as_heavy, avg 3.42ms/call
26 |  |  |  |  | }
27 |  |  |  |  |
28 |  |  |  |  | # spent 30.2ms (8.87+21.4) within Exporter::import which was called 37 times, avg 817µs/call: # once (872µs+19.9ms) by POSIX::import at line 29 of POSIX.pm # once (1.76ms+217µs) by POSIX::BEGIN@13 at line 13 of POSIX.pm # once (228µs+830µs) by Safe::BEGIN@46 at line 46 of Safe.pm # once (406µs+46µs) by Data::DPath::Context::BEGIN@16 at line 16 of Data/DPath/Context.pm # once (331µs+23µs) by Data::DPath::Context::BEGIN@19 at line 19 of Data/DPath/Context.pm # once (260µs+46µs) by Data::DPath::Path::BEGIN@17 at line 17 of Data/DPath/Path.pm # once (254µs+25µs) by Data::DPath::Context::BEGIN@17 at line 17 of Data/DPath/Context.pm # once (253µs+10µs) by Devel::StackTrace::BEGIN@13 at line 13 of Devel/StackTrace.pm # once (246µs+13µs) by IO::Handle::BEGIN@263 at line 263 of IO/Handle.pm # once (238µs+20µs) by Class::XSAccessor::Array::BEGIN@5 at line 5 of Class/XSAccessor/Array.pm # once (215µs+12µs) by Text::Balanced::BEGIN@343 at line 343 of Text/Balanced.pm # once (206µs+8µs) by SelectSaver::BEGIN@38 at line 38 of SelectSaver.pm # once (200µs+13µs) by IO::Handle::BEGIN@264 at line 264 of IO/Handle.pm # once (197µs+13µs) by Attribute::Handlers::BEGIN@3 at line 3 of Attribute/Handlers.pm # once (191µs+12µs) by Text::Balanced::BEGIN@885 at line 885 of Text/Balanced.pm # once (184µs+13µs) by Opcode::BEGIN@11 at line 11 of Opcode.pm # once (185µs+12µs) by Data::Dumper::BEGIN@20 at line 20 of Data/Dumper.pm # once (179µs+16µs) by Data::DPath::Context::BEGIN@20 at line 20 of Data/DPath/Context.pm # once (179µs+11µs) by Sub::Install::BEGIN@6 at line 6 of Sub/Install.pm # once (180µs+9µs) by Tie::Hash::BEGIN@188 at line 188 of Tie/Hash.pm # once (161µs+10µs) by Safe::BEGIN@4 at line 4 of Safe.pm # once (148µs+8µs) by IO::BEGIN@6 at line 6 of IO.pm # once (141µs+8µs) by Data::OptList::BEGIN@10 at line 95 of Params/Util.pm # once (142µs+7µs) by Safe::BEGIN@29 at line 29 of Safe.pm # once (140µs+8µs) by Exception::Class::BEGIN@11 at line 11 of Exception/Class.pm # once (138µs+7µs) by Class::XSAccessor::Heavy::BEGIN@7 at line 7 of Class/XSAccessor/Heavy.pm # once (137µs+8µs) by Data::DPath::Path::BEGIN@13 at line 13 of Data/DPath/Path.pm # once (133µs+10µs) by Text::Balanced::BEGIN@9 at line 9 of Text/Balanced.pm # once (133µs+9µs) by Exception::Class::Base::BEGIN@11 at line 11 of Exception/Class/Base.pm # once (129µs+6µs) by SelectSaver::BEGIN@39 at line 39 of SelectSaver.pm # once (126µs+7µs) by Data::DPath::Context::BEGIN@13 at line 13 of Data/DPath/Context.pm # once (119µs+9µs) by main::BEGIN@11 at line 11 of bin/dpath # once (107µs+5µs) by Data::DPath::Filters::BEGIN@13 at line 13 of Data/DPath/Filters.pm # once (100µs+5µs) by Class::XSAccessor::BEGIN@5 at line 5 of Class/XSAccessor.pm # once (101µs+0s) by SelfLoader::BEGIN@42 at line 42 of SelfLoader.pm # once (98µs+0s) by SelfLoader::BEGIN@4 at line 4 of SelfLoader.pm # once (60µs+0s) by Data::DPath::Filters::BEGIN@14 at line 14 of Data/DPath/Filters.pm sub import {
29 | 558 | 10.2ms |  |  | my $pkg = shift;
30 |  |  |  |  | my $callpkg = caller($ExportLevel);
31 |  |  |  |  |
32 |  |  |  |  | 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 :-(
38 |  |  |  |  | my $exports = \@{"$pkg\::EXPORT"};
39 |  |  |  |  | # But, avoid creating things if they don't exist, which saves a couple of
40 |  |  |  |  | # hundred bytes per package processed.
41 |  |  |  |  | my $fail = ${$pkg . '::'}{EXPORT_FAIL} && \@{"$pkg\::EXPORT_FAIL"};
42 |  |  |  |  | return export $pkg, $callpkg, @_
43 |  |  |  |  | if $Verbose or $Debug or $fail && @$fail > 1;
44 |  |  |  |  | my $export_cache = ($Cache{$pkg} ||= {});
45 |  |  |  |  | my $args = @_ or @_ = @$exports;
46 |  |  |  |  |
47 |  |  |  |  | if ($args and not %$export_cache) {
48 |  |  |  |  | s/^&//, $export_cache->{$_} = 1
49 |  |  | 230 | 289µs | foreach (@$exports, @{"$pkg\::EXPORT_OK"}); # spent 289µs making 230 calls to Exporter::CORE:subst, avg 1µs/call
50 |  |  |  |  | }
51 |  |  |  |  | my $heavy;
52 |  |  |  |  | # Try very hard not to use {} and hence have to enter scope on the foreach
53 |  |  |  |  | # We bomb out of the loop with last as soon as heavy is set.
54 |  |  |  |  | if ($args or $fail) {
55 |  |  |  |  | ($heavy = (/\W/ or $args and not exists $export_cache->{$_}
56 |  |  |  |  | or $fail and @$fail and $_ eq $fail->[0])) and last
57 |  |  | 95 | 305µs | foreach (@_); # spent 305µs making 95 calls to Exporter::CORE:match, avg 3µs/call
58 |  |  |  |  | } else {
59 |  |  |  |  | ($heavy = /\W/) and last
60 |  |  | 144 | 253µs | foreach (@_); # spent 253µs making 144 calls to Exporter::CORE:match, avg 2µs/call
61 |  |  |  |  | }
62 |  |  | 2 | 6.90ms | return export $pkg, $callpkg, ($args ? @_ : ()) if $heavy; # spent 6.90ms making 2 calls to Exporter::export, avg 3.45ms/call
63 |  |  |  |  | local $SIG{__WARN__} =
64 |  |  |  |  | sub {require Carp; &Carp::carp} if not $SIG{__WARN__};
65 |  |  |  |  | # shortcut for the common case of no type character
66 |  |  |  |  | *{"$callpkg\::$_"} = \&{"$pkg\::$_"} foreach @_;
67 |  |  |  |  | }
68 |  |  |  |  |
69 |  |  |  |  | # Default methods
70 |  |  |  |  |
71 |  |  |  |  | sub export_fail {
72 |  |  |  |  | my $self = shift;
73 |  |  |  |  | @_;
74 |  |  |  |  | }
75 |  |  |  |  |
76 |  |  |  |  | # Unfortunately, caller(1)[3] "does not work" if the caller is aliased as
77 |  |  |  |  | # *name = \&foo. Thus the need to create a lot of identical subroutines
78 |  |  |  |  | # Otherwise we could have aliased them to export().
79 |  |  |  |  |
80 |  |  |  |  | sub export_to_level {
81 |  |  |  |  | goto &{as_heavy()};
82 |  |  |  |  | }
83 |  |  |  |  |
84 |  |  |  |  | sub export_tags {
85 |  |  |  |  | goto &{as_heavy()};
86 |  |  |  |  | }
87 |  |  |  |  |
88 |  |  |  |  | # spent 86µs (24+61) within Exporter::export_ok_tags which was called: # once (24µs+61µs) by Data::DPath::Path::BEGIN@17 at line 31 of Text/Balanced.pm sub export_ok_tags {
89 | 1 | 28µs | 2 | 160µs | goto &{as_heavy()}; # spent 99µs making 1 call to Exporter::Heavy::heavy_export_ok_tags # spent 61µs making 1 call to Exporter::as_heavy
90 |  |  |  |  | }
91 |  |  |  |  |
92 |  |  |  |  | sub require_version {
93 |  |  |  |  | goto &{as_heavy()};
94 |  |  |  |  | }
95 |  |  |  |  |
96 | 1 | 19µs |  |  | 1;
97 |  |  |  |  | __END__
|  |  |  |  | # spent 558µs within Exporter::CORE:match which was called 239 times, avg 2µs/call: # 144 times (253µs+0s) by Exporter::import at line 60, avg 2µs/call # 95 times (305µs+0s) by Exporter::import at line 57, avg 3µs/call sub Exporter::CORE:match; # opcode
|  |  |  |  | # spent 345µs within Exporter::CORE:subst which was called 233 times, avg 1µs/call: # 230 times (289µs+0s) by Exporter::import at line 49, avg 1µs/call # 3 times (56µs+0s) by Exporter::as_heavy at line 20, avg 19µs/call sub Exporter::CORE:subst; # opcode