| Filename | /usr/share/perl/5.10/Exporter.pm |
| Statements | Executed 341 statements in 1.11ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 19 | 19 | 15 | 982µs | 1.03ms | Exporter::import |
| 44 | 1 | 1 | 31µs | 31µs | Exporter::CORE:match (opcode) |
| 45 | 1 | 1 | 16µs | 16µs | Exporter::CORE:subst (opcode) |
| 0 | 0 | 0 | 0s | 0s | Exporter::__ANON__[:65] |
| 0 | 0 | 0 | 0s | 0s | Exporter::as_heavy |
| 0 | 0 | 0 | 0s | 0s | Exporter::export |
| 0 | 0 | 0 | 0s | 0s | Exporter::export_fail |
| 0 | 0 | 0 | 0s | 0s | Exporter::export_ok_tags |
| 0 | 0 | 0 | 0s | 0s | Exporter::export_tags |
| 0 | 0 | 0 | 0s | 0s | Exporter::export_to_level |
| 0 | 0 | 0 | 0s | 0s | Exporter::require_version |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Exporter; | ||||
| 2 | |||||
| 3 | 1 | 17µs | require 5.006; | ||
| 4 | |||||
| 5 | # Be lean. | ||||
| 6 | #use strict; | ||||
| 7 | #no strict 'refs'; | ||||
| 8 | |||||
| 9 | 1 | 500ns | our $Debug = 0; | ||
| 10 | 1 | 200ns | our $ExportLevel = 0; | ||
| 11 | 1 | 400ns | our $Verbose ||= 0; | ||
| 12 | 1 | 400ns | our $VERSION = '5.63'; | ||
| 13 | 1 | 300ns | our (%Cache); | ||
| 14 | |||||
| 15 | # Carp 1.05+ does this now for us, but we may be running with an old Carp | ||||
| 16 | 1 | 2µs | $Carp::Internal{Exporter}++; | ||
| 17 | |||||
| 18 | sub as_heavy { | ||||
| 19 | require Exporter::Heavy; | ||||
| 20 | # Unfortunately, this does not work if the caller is aliased as *name = \&foo | ||||
| 21 | # Thus the need to create a lot of identical subroutines | ||||
| 22 | my $c = (caller(1))[3]; | ||||
| 23 | $c =~ s/.*:://; | ||||
| 24 | \&{"Exporter::Heavy::heavy_$c"}; | ||||
| 25 | } | ||||
| 26 | |||||
| 27 | sub export { | ||||
| 28 | goto &{as_heavy()}; | ||||
| 29 | } | ||||
| 30 | |||||
| 31 | # spent 1.03ms (982µs+48µs) within Exporter::import which was called 19 times, avg 54µs/call:
# once (95µs+7µs) by DateTime::Duration::BEGIN@12 at line 12 of DateTime/Duration.pm
# once (69µs+6µs) by Class::Load::BEGIN@6 at line 6 of Class/Load.pm
# once (68µs+3µs) by DateTime::TimeZone::BEGIN@16 at line 16 of DateTime/TimeZone.pm
# once (67µs+3µs) by DateTime::BEGIN@49 at line 49 of DateTime.pm
# once (62µs+4µs) by DateTime::TimeZone::Local::BEGIN@9 at line 9 of DateTime/TimeZone/Local.pm
# once (62µs+2µs) by MongoDB::Cursor::BEGIN@22 at line 22 of MongoDB/Cursor.pm
# once (56µs+2µs) by DateTime::TimeZone::OffsetOnly::BEGIN@13 at line 13 of DateTime/TimeZone/OffsetOnly.pm
# once (55µs+3µs) by DateTime::Locale::BEGIN@12 at line 12 of DateTime/Locale.pm
# once (52µs+4µs) by DateTime::Locale::Base::BEGIN@6 at line 6 of DateTime/Locale/Base.pm
# once (50µs+2µs) by MongoDB::Collection::BEGIN@49 at line 49 of MongoDB/Collection.pm
# once (49µs+2µs) by Time::Local::BEGIN@4 at line 4 of Time/Local.pm
# once (48µs+2µs) by Tie::Hash::BEGIN@5 at line 5 of Tie/Hash.pm
# once (47µs+3µs) by DateTime::BEGIN@47 at line 47 of DateTime.pm
# once (44µs+2µs) by DateTime::BEGIN@11 at line 11 of DateTime.pm
# once (41µs+2µs) by MongoDB::Connection::BEGIN@29 at line 29 of MongoDB/Connection.pm
# once (37µs+1µs) by DateTime::Locale::Base::BEGIN@9 at line 9 of DateTime/Locale/Base.pm
# once (28µs+0s) by MongoDB::GridFS::BEGIN@25 at line 25 of MongoDB/GridFS.pm
# once (27µs+0s) by Params::Validate::BEGIN@6 at line 6 of Params/Validate.pm
# once (26µs+0s) by MongoDB::Connection::BEGIN@27 at line 27 of MongoDB/Connection.pm | ||||
| 32 | 285 | 738µs | my $pkg = shift; | ||
| 33 | my $callpkg = caller($ExportLevel); | ||||
| 34 | |||||
| 35 | if ($pkg eq "Exporter" and @_ and $_[0] eq "import") { | ||||
| 36 | *{$callpkg."::import"} = \&import; | ||||
| 37 | return; | ||||
| 38 | } | ||||
| 39 | |||||
| 40 | # We *need* to treat @{"$pkg\::EXPORT_FAIL"} since Carp uses it :-( | ||||
| 41 | my($exports, $fail) = (\@{"$pkg\::EXPORT"}, \@{"$pkg\::EXPORT_FAIL"}); | ||||
| 42 | return export $pkg, $callpkg, @_ | ||||
| 43 | if $Verbose or $Debug or @$fail > 1; | ||||
| 44 | my $export_cache = ($Cache{$pkg} ||= {}); | ||||
| 45 | my $args = @_ or @_ = @$exports; | ||||
| 46 | |||||
| 47 | local $_; | ||||
| 48 | 10 | 151µs | if ($args and not %$export_cache) { | ||
| 49 | s/^&//, $export_cache->{$_} = 1 | ||||
| 50 | 45 | 16µs | foreach (@$exports, @{"$pkg\::EXPORT_OK"}); # spent 16µs making 45 calls to Exporter::CORE:subst, avg 367ns/call | ||
| 51 | } | ||||
| 52 | my $heavy; | ||||
| 53 | # Try very hard not to use {} and hence have to enter scope on the foreach | ||||
| 54 | # We bomb out of the loop with last as soon as heavy is set. | ||||
| 55 | 38 | 198µs | if ($args or $fail) { | ||
| 56 | ($heavy = (/\W/ or $args and not exists $export_cache->{$_} | ||||
| 57 | or @$fail and $_ eq $fail->[0])) and last | ||||
| 58 | 44 | 31µs | foreach (@_); # spent 31µs making 44 calls to Exporter::CORE:match, avg 711ns/call | ||
| 59 | } else { | ||||
| 60 | ($heavy = /\W/) and last | ||||
| 61 | foreach (@_); | ||||
| 62 | } | ||||
| 63 | return export $pkg, $callpkg, ($args ? @_ : ()) if $heavy; | ||||
| 64 | local $SIG{__WARN__} = | ||||
| 65 | sub {require Carp; &Carp::carp}; | ||||
| 66 | # shortcut for the common case of no type character | ||||
| 67 | *{"$callpkg\::$_"} = \&{"$pkg\::$_"} foreach @_; | ||||
| 68 | } | ||||
| 69 | |||||
| 70 | # Default methods | ||||
| 71 | |||||
| 72 | sub export_fail { | ||||
| 73 | my $self = shift; | ||||
| 74 | @_; | ||||
| 75 | } | ||||
| 76 | |||||
| 77 | # Unfortunately, caller(1)[3] "does not work" if the caller is aliased as | ||||
| 78 | # *name = \&foo. Thus the need to create a lot of identical subroutines | ||||
| 79 | # Otherwise we could have aliased them to export(). | ||||
| 80 | |||||
| 81 | sub export_to_level { | ||||
| 82 | goto &{as_heavy()}; | ||||
| 83 | } | ||||
| 84 | |||||
| 85 | sub export_tags { | ||||
| 86 | goto &{as_heavy()}; | ||||
| 87 | } | ||||
| 88 | |||||
| 89 | sub export_ok_tags { | ||||
| 90 | goto &{as_heavy()}; | ||||
| 91 | } | ||||
| 92 | |||||
| 93 | sub require_version { | ||||
| 94 | goto &{as_heavy()}; | ||||
| 95 | } | ||||
| 96 | |||||
| 97 | 1 | 6µs | 1; | ||
| 98 | __END__ | ||||
# spent 31µs within Exporter::CORE:match which was called 44 times, avg 711ns/call:
# 44 times (31µs+0s) by Exporter::import at line 58, avg 711ns/call | |||||
# spent 16µs within Exporter::CORE:subst which was called 45 times, avg 367ns/call:
# 45 times (16µs+0s) by Exporter::import at line 50, avg 367ns/call |