| Filename | /usr/libdata/perl5/Exporter.pm |
| Statements | Executed 787 statements in 7.78ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 10 | 2 | 1 | 33.1ms | 33.3ms | Exporter::as_heavy |
| 50 | 50 | 26 | 6.25ms | 41.6ms | Exporter::import |
| 355 | 2 | 1 | 378µs | 378µs | Exporter::CORE:match (opcode) |
| 294 | 2 | 1 | 277µs | 277µs | Exporter::CORE:subst (opcode) |
| 8 | 1 | 1 | 69µs | 33.3ms | Exporter::export |
| 2 | 2 | 2 | 14µs | 46µs | Exporter::export_ok_tags |
| 0 | 0 | 0 | 0s | 0s | Exporter::__ANON__[:64] |
| 0 | 0 | 0 | 0s | 0s | Exporter::export_fail |
| 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 | 29µ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.72'; | ||
| 13 | our (%Cache); | ||||
| 14 | |||||
| 15 | sub as_heavy { | ||||
| 16 | 10 | 436µ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 | 10 | 51µs | my $c = (caller(1))[3]; | ||
| 20 | 10 | 91µs | 10 | 52µs | $c =~ s/.*:://; # spent 52µs making 10 calls to Exporter::CORE:subst, avg 5µs/call |
| 21 | 10 | 72µs | \&{"Exporter::Heavy::heavy_$c"}; | ||
| 22 | } | ||||
| 23 | |||||
| 24 | # spent 33.3ms (69µs+33.2) within Exporter::export which was called 8 times, avg 4.16ms/call:
# 8 times (69µs+33.2ms) by Exporter::import at line 62, avg 4.16ms/call | ||||
| 25 | 8 | 572µs | 16 | 34.7ms | goto &{as_heavy()}; # spent 33.2ms making 8 calls to Exporter::as_heavy, avg 4.15ms/call
# spent 1.45ms making 8 calls to Exporter::Heavy::heavy_export, avg 181µs/call |
| 26 | } | ||||
| 27 | |||||
| 28 | # spent 41.6ms (6.25+35.4) within Exporter::import which was called 50 times, avg 832µs/call:
# once (1.04ms+33.5ms) by OpenBSD::PackageInfo::BEGIN@39 at line 39 of OpenBSD/PackageInfo.pm
# once (701µs+31µs) by Compress::Raw::Zlib::BEGIN@6 at line 6 of Compress/Raw/Zlib.pm
# once (146µs+559µs) by File::Glob::import at line 46 of File/Glob.pm
# once (424µs+38µs) by IO::Uncompress::RawInflate::BEGIN@8 at line 8 of IO/Uncompress/RawInflate.pm
# once (315µs+10µs) by OpenBSD::State::BEGIN@86 at line 86 of OpenBSD/State.pm
# once (71µs+233µs) by IO::Uncompress::Gunzip::BEGIN@16 at line 16 of IO/Uncompress/Gunzip.pm
# once (69µs+211µs) by IO::Compress::Zlib::Extra::BEGIN@13 at line 13 of IO/Compress/Zlib/Extra.pm
# once (104µs+158µs) by IO::Uncompress::RawInflate::BEGIN@9 at line 9 of IO/Uncompress/RawInflate.pm
# once (204µs+14µs) by OpenBSD::State::BEGIN@88 at line 88 of OpenBSD/State.pm
# once (185µs+20µs) by OpenBSD::PkgInfo::BEGIN@177 at line 177 of OpenBSD/PkgInfo.pm
# once (181µs+24µs) by OpenBSD::PkgInfo::State::BEGIN@65 at line 65 of OpenBSD/PkgInfo.pm
# once (176µs+19µs) by IO::Uncompress::Base::BEGIN@19 at line 147 of IO/File.pm
# once (153µs+31µs) by IO::Uncompress::Adapter::Inflate::BEGIN@8 at line 8 of IO/Uncompress/Adapter/Inflate.pm
# once (163µs+21µs) by IO::Uncompress::Base::BEGIN@19 at line 19 of IO/Uncompress/Base.pm
# once (163µs+19µs) by IO::Uncompress::Base::BEGIN@17 at line 17 of IO/Uncompress/Base.pm
# once (157µs+22µs) by OpenBSD::PackageRepository::Installed::BEGIN@197 at line 198 of OpenBSD/PackageRepository/Installed.pm
# once (50µs+127µs) by OpenBSD::Getopt::getopts at line 85 of OpenBSD/Getopt.pm
# once (162µs+14µs) by OpenBSD::PackageLocation::BEGIN@23 at line 23 of OpenBSD/PackageLocation.pm
# once (160µs+8µs) by OpenBSD::Error::BEGIN@72 at line 72 of OpenBSD/Error.pm
# once (146µs+21µs) by IO::Compress::Base::Common::BEGIN@8 at line 8 of IO/Compress/Base/Common.pm
# once (27µs+135µs) by IO::Uncompress::Adapter::Inflate::BEGIN@7 at line 7 of IO/Uncompress/Adapter/Inflate.pm
# once (22µs+101µs) by IO::Uncompress::Gunzip::BEGIN@15 at line 15 of IO/Uncompress/Gunzip.pm
# once (85µs+7µs) by OpenBSD::PackageLocation::BEGIN@25 at line 25 of OpenBSD/PackageLocation.pm
# once (78µs+8µs) by OpenBSD::PackageRepository::Local::BEGIN@454 at line 454 of OpenBSD/PackageRepository.pm
# once (74µs+6µs) by OpenBSD::PkgInfo::BEGIN@180 at line 180 of OpenBSD/PkgInfo.pm
# once (65µs+8µs) by File::Path::BEGIN@6 at line 6 of File/Path.pm
# once (66µs+4µs) by IO::Compress::Base::Common::BEGIN@7 at line 7 of IO/Compress/Base/Common.pm
# once (63µs+5µs) by OpenBSD::PackageRepository::BEGIN@32 at line 32 of OpenBSD/PackageRepository.pm
# once (63µs+5µs) by OpenBSD::Temp::BEGIN@25 at line 25 of OpenBSD/Temp.pm
# once (64µs+4µs) by File::GlobMapper::BEGIN@5 at line 5 of File/GlobMapper.pm
# once (66µs+0s) by main::BEGIN@22 at line 22 of OpenBSD/PkgInfo.pm
# once (57µs+3µs) by OpenBSD::Temp::BEGIN@23 at line 23 of OpenBSD/Temp.pm
# once (56µs+2µs) by OpenBSD::PkgInfo::BEGIN@179 at line 179 of OpenBSD/PkgInfo.pm
# once (54µs+3µs) by IO::BEGIN@6 at line 6 of IO.pm
# once (53µs+3µs) by IO::Compress::Base::Common::BEGIN@523 at line 523 of IO/Compress/Base/Common.pm
# once (49µs+3µs) by IO::Seekable::BEGIN@104 at line 104 of IO/Seekable.pm
# once (48µs+4µs) by IO::File::BEGIN@131 at line 131 of IO/File.pm
# once (49µs+3µs) by IO::File::BEGIN@130 at line 130 of IO/File.pm
# once (43µs+3µs) by IO::Uncompress::Base::BEGIN@20 at line 20 of IO/Uncompress/Base.pm
# once (43µs+3µs) by IO::Seekable::BEGIN@98 at line 98 of IO/Seekable.pm
# once (42µs+3µs) by IO::Handle::BEGIN@267 at line 267 of IO/Handle.pm
# once (42µs+3µs) by IO::Handle::BEGIN@266 at line 266 of IO/Handle.pm
# once (41µs+2µs) by SelectSaver::BEGIN@38 at line 38 of SelectSaver.pm
# once (40µs+3µs) by SelectSaver::BEGIN@39 at line 39 of SelectSaver.pm
# once (40µs+3µs) by IO::File::BEGIN@133 at line 133 of IO/File.pm
# once (41µs+0s) by Cwd::BEGIN@3 at line 3 of Cwd.pm
# once (36µs+2µs) by IO::Uncompress::Base::BEGIN@23 at line 23 of IO/Uncompress/Base.pm
# once (30µs+0s) by IO::Uncompress::RawInflate::BEGIN@11 at line 11 of IO/Uncompress/RawInflate.pm
# once (25µs+0s) by IO::Uncompress::Gunzip::BEGIN@12 at line 12 of IO/Uncompress/Gunzip.pm
# once (18µs+0s) by OpenBSD::MkTemp::BEGIN@7 at line 7 of OpenBSD/MkTemp.pm | ||||
| 29 | 50 | 70µs | my $pkg = shift; | ||
| 30 | 50 | 87µs | my $callpkg = caller($ExportLevel); | ||
| 31 | |||||
| 32 | 50 | 65µs | if ($pkg eq "Exporter" and @_ and $_[0] eq "import") { | ||
| 33 | 1 | 9µs | *{$callpkg."::import"} = \&import; | ||
| 34 | 1 | 6µs | return; | ||
| 35 | } | ||||
| 36 | |||||
| 37 | # We *need* to treat @{"$pkg\::EXPORT_FAIL"} since Carp uses it :-( | ||||
| 38 | 49 | 218µs | 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 | 49 | 147µs | my $fail = ${$pkg . '::'}{EXPORT_FAIL} && \@{"$pkg\::EXPORT_FAIL"}; | ||
| 42 | 49 | 71µs | return export $pkg, $callpkg, @_ | ||
| 43 | if $Verbose or $Debug or $fail && @$fail > 1; | ||||
| 44 | 49 | 112µs | my $export_cache = ($Cache{$pkg} ||= {}); | ||
| 45 | 49 | 198µs | my $args = @_ or @_ = @$exports; | ||
| 46 | |||||
| 47 | 49 | 49µs | if ($args and not %$export_cache) { | ||
| 48 | s/^&//, $export_cache->{$_} = 1 | ||||
| 49 | 7 | 1.17ms | 284 | 225µs | foreach (@$exports, @{"$pkg\::EXPORT_OK"}); # spent 225µs making 284 calls to Exporter::CORE:subst, avg 793ns/call |
| 50 | } | ||||
| 51 | 49 | 38µs | 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 | 49 | 82µs | 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 | 25 | 665µs | 140 | 170µs | foreach (@_); # spent 170µs making 140 calls to Exporter::CORE:match, avg 1µs/call |
| 58 | } else { | ||||
| 59 | ($heavy = /\W/) and last | ||||
| 60 | 24 | 894µs | 215 | 208µs | foreach (@_); # spent 208µs making 215 calls to Exporter::CORE:match, avg 966ns/call |
| 61 | } | ||||
| 62 | 49 | 112µs | 8 | 33.3ms | return export $pkg, $callpkg, ($args ? @_ : ()) if $heavy; # spent 33.3ms making 8 calls to Exporter::export, avg 4.16ms/call |
| 63 | local $SIG{__WARN__} = | ||||
| 64 | 41 | 772µs | sub {require Carp; &Carp::carp} if not $SIG{__WARN__}; | ||
| 65 | # shortcut for the common case of no type character | ||||
| 66 | 41 | 1.72ms | *{"$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 46µs (14+32) within Exporter::export_ok_tags which was called 2 times, avg 23µs/call:
# once (8µs+16µs) by IO::Uncompress::Gunzip::BEGIN@12 at line 25 of IO/Uncompress/RawInflate.pm
# once (6µs+16µs) by OpenBSD::PackageRepository::uncompress at line 27 of IO/Uncompress/Gunzip.pm | ||||
| 89 | 2 | 17µs | 4 | 72µs | goto &{as_heavy()}; # spent 40µs making 2 calls to Exporter::Heavy::heavy_export_ok_tags, avg 20µs/call
# spent 32µs making 2 calls to Exporter::as_heavy, avg 16µs/call |
| 90 | } | ||||
| 91 | |||||
| 92 | sub require_version { | ||||
| 93 | goto &{as_heavy()}; | ||||
| 94 | } | ||||
| 95 | |||||
| 96 | 1 | 19µs | 1; | ||
| 97 | __END__ | ||||
sub Exporter::CORE:match; # opcode | |||||
sub Exporter::CORE:subst; # opcode |