| Filename | /usr/local/share/perl/5.18.2/Sub/Exporter/Progressive.pm |
| Statements | Executed 58 statements in 805µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 36µs | 50µs | Sub::Exporter::Progressive::sub_export_options |
| 1 | 1 | 1 | 18µs | 29µs | Sub::Exporter::Progressive::__ANON__[:40] |
| 1 | 1 | 1 | 17µs | 67µs | Sub::Exporter::Progressive::import |
| 1 | 1 | 1 | 9µs | 27µs | Sub::Exporter::Progressive::BEGIN@3 |
| 5 | 4 | 1 | 7µs | 7µs | Sub::Exporter::Progressive::CORE:match (opcode) |
| 1 | 1 | 1 | 6µs | 14µs | Sub::Exporter::Progressive::BEGIN@18 |
| 1 | 1 | 1 | 6µs | 9µs | Sub::Exporter::Progressive::BEGIN@4 |
| 1 | 1 | 1 | 5µs | 13µs | Sub::Exporter::Progressive::BEGIN@23 |
| 1 | 1 | 1 | 3µs | 3µs | Sub::Exporter::Progressive::BEGIN@8 |
| 1 | 1 | 1 | 2µs | 2µs | Sub::Exporter::Progressive::BEGIN@9 |
| 1 | 1 | 1 | 400ns | 400ns | Sub::Exporter::Progressive::CORE:subst (opcode) |
| 0 | 0 | 0 | 0s | 0s | Sub::Exporter::Progressive::__ANON__[:26] |
| 0 | 0 | 0 | 0s | 0s | Sub::Exporter::Progressive::__ANON__[:32] |
| 0 | 0 | 0 | 0s | 0s | Sub::Exporter::Progressive::__ANON__[:66] |
| 0 | 0 | 0 | 0s | 0s | Sub::Exporter::Progressive::__ANON__[:71] |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Sub::Exporter::Progressive; | ||||
| 2 | |||||
| 3 | 2 | 18µs | 2 | 44µs | # spent 27µs (9+18) within Sub::Exporter::Progressive::BEGIN@3 which was called:
# once (9µs+18µs) by Devel::GlobalDestruction::BEGIN@8 at line 3 # spent 27µs making 1 call to Sub::Exporter::Progressive::BEGIN@3
# spent 18µs making 1 call to strict::import |
| 4 | 2 | 33µs | 2 | 12µs | # spent 9µs (6+3) within Sub::Exporter::Progressive::BEGIN@4 which was called:
# once (6µs+3µs) by Devel::GlobalDestruction::BEGIN@8 at line 4 # spent 9µs making 1 call to Sub::Exporter::Progressive::BEGIN@4
# spent 3µs making 1 call to warnings::import |
| 5 | |||||
| 6 | 1 | 400ns | our $VERSION = '0.001011'; | ||
| 7 | |||||
| 8 | 2 | 25µs | 1 | 3µs | # spent 3µs within Sub::Exporter::Progressive::BEGIN@8 which was called:
# once (3µs+0s) by Devel::GlobalDestruction::BEGIN@8 at line 8 # spent 3µs making 1 call to Sub::Exporter::Progressive::BEGIN@8 |
| 9 | 2 | 47µs | 1 | 2µs | # spent 2µs within Sub::Exporter::Progressive::BEGIN@9 which was called:
# once (2µs+0s) by Devel::GlobalDestruction::BEGIN@8 at line 9 # spent 2µs making 1 call to Sub::Exporter::Progressive::BEGIN@9 |
| 10 | |||||
| 11 | # spent 67µs (17+50) within Sub::Exporter::Progressive::import which was called:
# once (17µs+50µs) by Devel::GlobalDestruction::BEGIN@8 at line 8 of Devel/GlobalDestruction.pm | ||||
| 12 | 1 | 900ns | my ($self, @args) = @_; | ||
| 13 | |||||
| 14 | 1 | 400ns | my $inner_target = caller; | ||
| 15 | 1 | 1µs | 1 | 50µs | my $export_data = sub_export_options($inner_target, @args); # spent 50µs making 1 call to Sub::Exporter::Progressive::sub_export_options |
| 16 | |||||
| 17 | 1 | 100ns | my $full_exporter; | ||
| 18 | 2 | 59µs | 2 | 23µs | # spent 14µs (6+8) within Sub::Exporter::Progressive::BEGIN@18 which was called:
# once (6µs+8µs) by Devel::GlobalDestruction::BEGIN@8 at line 18 # spent 14µs making 1 call to Sub::Exporter::Progressive::BEGIN@18
# spent 8µs making 1 call to strict::unimport |
| 19 | 1 | 2µs | @{"${inner_target}::EXPORT_OK"} = @{$export_data->{exports}}; | ||
| 20 | 1 | 2µs | @{"${inner_target}::EXPORT"} = @{$export_data->{defaults}}; | ||
| 21 | 1 | 3µs | %{"${inner_target}::EXPORT_TAGS"} = %{$export_data->{tags}}; | ||
| 22 | # spent 29µs (18+11) within Sub::Exporter::Progressive::__ANON__[/usr/local/share/perl/5.18.2/Sub/Exporter/Progressive.pm:40] which was called:
# once (18µs+11µs) by Class::MOP::Package::BEGIN@8 at line 8 of Class/MOP/Package.pm | ||||
| 23 | 2 | 520µs | 2 | 20µs | # spent 13µs (5+7) within Sub::Exporter::Progressive::BEGIN@23 which was called:
# once (5µs+7µs) by Devel::GlobalDestruction::BEGIN@8 at line 23 # spent 13µs making 1 call to Sub::Exporter::Progressive::BEGIN@23
# spent 8µs making 1 call to strict::import |
| 24 | 1 | 800ns | my ($self, @args) = @_; | ||
| 25 | |||||
| 26 | 2 | 14µs | 3 | 13µs | if (List::Util::first { ref || !m/ \A [:-]? \w+ \z /xm } @args) { # spent 11µs making 2 calls to List::Util::first, avg 5µs/call
# spent 2µs making 1 call to Sub::Exporter::Progressive::CORE:match |
| 27 | Carp::croak 'your usage of Sub::Exporter::Progressive requires Sub::Exporter to be installed' | ||||
| 28 | unless eval { require Sub::Exporter }; | ||||
| 29 | $full_exporter ||= Sub::Exporter::build_exporter($export_data->{original}); | ||||
| 30 | |||||
| 31 | goto $full_exporter; | ||||
| 32 | 1 | 5µs | 1 | 600ns | } elsif (defined(my $num = List::Util::first { !ref and m/^\d/ } @args)) { # spent 600ns making 1 call to Sub::Exporter::Progressive::CORE:match |
| 33 | die "cannot export symbols with a leading digit: '$num'"; | ||||
| 34 | } else { | ||||
| 35 | 1 | 500ns | require Exporter; | ||
| 36 | 1 | 5µs | 1 | 400ns | s/ \A - /:/xm for @args; # spent 400ns making 1 call to Sub::Exporter::Progressive::CORE:subst |
| 37 | 1 | 1µs | @_ = ($self, @args); | ||
| 38 | 1 | 5µs | 1 | 25µs | goto \&Exporter::import; # spent 25µs making 1 call to Exporter::import |
| 39 | } | ||||
| 40 | 1 | 4µs | }; | ||
| 41 | 1 | 4µs | return; | ||
| 42 | } | ||||
| 43 | |||||
| 44 | 1 | 300ns | my $too_complicated = <<'DEATH'; | ||
| 45 | You are using Sub::Exporter::Progressive, but the features your program uses from | ||||
| 46 | Sub::Exporter cannot be implemented without Sub::Exporter, so you might as well | ||||
| 47 | just use vanilla Sub::Exporter | ||||
| 48 | DEATH | ||||
| 49 | |||||
| 50 | # spent 50µs (36+14) within Sub::Exporter::Progressive::sub_export_options which was called:
# once (36µs+14µs) by Sub::Exporter::Progressive::import at line 15 | ||||
| 51 | 1 | 400ns | my ($inner_target, $setup, $options) = @_; | ||
| 52 | |||||
| 53 | 1 | 0s | my @exports; | ||
| 54 | 1 | 0s | my @defaults; | ||
| 55 | 1 | 100ns | my %tags; | ||
| 56 | |||||
| 57 | 1 | 400ns | if ($setup eq '-setup') { | ||
| 58 | 1 | 2µs | my %options = %$options; | ||
| 59 | |||||
| 60 | OPTIONS: | ||||
| 61 | 1 | 1µs | for my $opt (keys %options) { | ||
| 62 | 2 | 2µs | if ($opt eq 'exports') { | ||
| 63 | |||||
| 64 | 1 | 800ns | Carp::croak $too_complicated if ref $options{exports} ne 'ARRAY'; | ||
| 65 | 1 | 600ns | @exports = @{$options{exports}}; | ||
| 66 | 2 | 10µs | 1 | 3µs | Carp::croak $too_complicated if List::Util::first { ref } @exports; # spent 3µs making 1 call to List::Util::first |
| 67 | |||||
| 68 | } elsif ($opt eq 'groups') { | ||||
| 69 | 1 | 1µs | %tags = %{$options{groups}}; | ||
| 70 | 1 | 700ns | for my $tagset (values %tags) { | ||
| 71 | 2 | 13µs | 2 | 11µs | Carp::croak $too_complicated if List::Util::first { / \A - (?! all \b ) /x || ref } @{$tagset}; # spent 9µs making 1 call to List::Util::first
# spent 2µs making 1 call to Sub::Exporter::Progressive::CORE:match |
| 72 | } | ||||
| 73 | 1 | 900ns | @defaults = @{$tags{default} || [] }; | ||
| 74 | } else { | ||||
| 75 | Carp::croak $too_complicated; | ||||
| 76 | } | ||||
| 77 | } | ||||
| 78 | 3 | 10µs | 2 | 2µs | @{$_} = map { / \A [:-] all \z /x ? @exports : $_ } @{$_} for \@defaults, values %tags; # spent 2µs making 2 calls to Sub::Exporter::Progressive::CORE:match, avg 950ns/call |
| 79 | 1 | 900ns | $tags{all} ||= [ @exports ]; | ||
| 80 | 1 | 2µs | my %exports = map { $_ => 1 } @exports; | ||
| 81 | 1 | 800ns | my @errors = grep { not $exports{$_} } @defaults; | ||
| 82 | 1 | 900ns | Carp::croak join(', ', @errors) . " is not exported by the $inner_target module\n" if @errors; | ||
| 83 | } | ||||
| 84 | |||||
| 85 | return { | ||||
| 86 | 1 | 5µs | exports => \@exports, | ||
| 87 | defaults => \@defaults, | ||||
| 88 | original => $options, | ||||
| 89 | tags => \%tags, | ||||
| 90 | }; | ||||
| 91 | } | ||||
| 92 | |||||
| 93 | 1 | 2µs | 1; | ||
| 94 | |||||
| 95 | =encoding utf8 | ||||
| 96 | |||||
| 97 | =head1 NAME | ||||
| 98 | |||||
| 99 | Sub::Exporter::Progressive - Only use Sub::Exporter if you need it | ||||
| 100 | |||||
| 101 | =head1 SYNOPSIS | ||||
| 102 | |||||
| 103 | package Syntax::Keyword::Gather; | ||||
| 104 | |||||
| 105 | use Sub::Exporter::Progressive -setup => { | ||||
| 106 | exports => [qw( break gather gathered take )], | ||||
| 107 | groups => { | ||||
| 108 | default => [qw( break gather gathered take )], | ||||
| 109 | }, | ||||
| 110 | }; | ||||
| 111 | |||||
| 112 | # elsewhere | ||||
| 113 | |||||
| 114 | # uses Exporter for speed | ||||
| 115 | use Syntax::Keyword::Gather; | ||||
| 116 | |||||
| 117 | # somewhere else | ||||
| 118 | |||||
| 119 | # uses Sub::Exporter for features | ||||
| 120 | use Syntax::Keyword::Gather 'gather', take => { -as => 'grab' }; | ||||
| 121 | |||||
| 122 | =head1 DESCRIPTION | ||||
| 123 | |||||
| 124 | L<Sub::Exporter> is an incredibly powerful module, but with that power comes | ||||
| 125 | great responsibility, er- as well as some runtime penalties. This module | ||||
| 126 | is a C<Sub::Exporter> wrapper that will let your users just use L<Exporter> | ||||
| 127 | if all they are doing is picking exports, but use C<Sub::Exporter> if your | ||||
| 128 | users try to use C<Sub::Exporter>'s more advanced features, like | ||||
| 129 | renaming exports, if they try to use them. | ||||
| 130 | |||||
| 131 | Note that this module will export C<@EXPORT>, C<@EXPORT_OK> and | ||||
| 132 | C<%EXPORT_TAGS> package variables for C<Exporter> to work. Additionally, if | ||||
| 133 | your package uses advanced C<Sub::Exporter> features like currying, this module | ||||
| 134 | will only ever use C<Sub::Exporter>, so you might as well use it directly. | ||||
| 135 | |||||
| 136 | =head1 AUTHOR | ||||
| 137 | |||||
| 138 | frew - Arthur Axel Schmidt (cpan:FREW) <frioux+cpan@gmail.com> | ||||
| 139 | |||||
| 140 | =head1 CONTRIBUTORS | ||||
| 141 | |||||
| 142 | ilmari - Dagfinn Ilmari Mannsåker (cpan:ILMARI) <ilmari@ilmari.org> | ||||
| 143 | |||||
| 144 | mst - Matt S. Trout (cpan:MSTROUT) <mst@shadowcat.co.uk> | ||||
| 145 | |||||
| 146 | leont - Leon Timmermans (cpan:LEONT) <leont@cpan.org> | ||||
| 147 | |||||
| 148 | =head1 COPYRIGHT | ||||
| 149 | |||||
| 150 | Copyright (c) 2012 the Sub::Exporter::Progressive L</AUTHOR> and | ||||
| 151 | L</CONTRIBUTORS> as listed above. | ||||
| 152 | |||||
| 153 | =head1 LICENSE | ||||
| 154 | |||||
| 155 | This library is free software and may be distributed under the same terms | ||||
| 156 | as perl itself. | ||||
| 157 | |||||
| 158 | =cut | ||||
# spent 7µs within Sub::Exporter::Progressive::CORE:match which was called 5 times, avg 1µs/call:
# 2 times (2µs+0s) by Sub::Exporter::Progressive::sub_export_options at line 78, avg 950ns/call
# once (2µs+0s) by List::Util::first at line 71
# once (2µs+0s) by List::Util::first at line 26
# once (600ns+0s) by List::Util::first at line 32 | |||||
# spent 400ns within Sub::Exporter::Progressive::CORE:subst which was called:
# once (400ns+0s) by Sub::Exporter::Progressive::__ANON__[/usr/local/share/perl/5.18.2/Sub/Exporter/Progressive.pm:40] at line 36 |