← Index
NYTProf Performance Profile   « line view »
For fastest.pl
  Run on Fri Jan 31 20:48:16 2014
Reported on Fri Jan 31 20:49:40 2014

Filename/opt/perl-5.18.1/lib/site_perl/5.18.1/Sub/Exporter/Progressive.pm
StatementsExecuted 66 statements in 1.29ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
22263µs95µsSub::Exporter::Progressive::::__ANON__[:40]Sub::Exporter::Progressive::__ANON__[:40]
11155µs86µsSub::Exporter::Progressive::::sub_export_optionsSub::Exporter::Progressive::sub_export_options
11130µs116µsSub::Exporter::Progressive::::importSub::Exporter::Progressive::import
11115µs31µsSub::Exporter::Progressive::::BEGIN@3Sub::Exporter::Progressive::BEGIN@3
74113µs13µsSub::Exporter::Progressive::::CORE:matchSub::Exporter::Progressive::CORE:match (opcode)
11112µs26µsSub::Exporter::Progressive::::BEGIN@18Sub::Exporter::Progressive::BEGIN@18
1119µs13µsSub::Exporter::Progressive::::BEGIN@4Sub::Exporter::Progressive::BEGIN@4
1119µs23µsSub::Exporter::Progressive::::BEGIN@23Sub::Exporter::Progressive::BEGIN@23
1114µs4µsSub::Exporter::Progressive::::BEGIN@8Sub::Exporter::Progressive::BEGIN@8
1114µs4µsSub::Exporter::Progressive::::BEGIN@9Sub::Exporter::Progressive::BEGIN@9
2111µs1µsSub::Exporter::Progressive::::CORE:substSub::Exporter::Progressive::CORE:subst (opcode)
0000s0sSub::Exporter::Progressive::::__ANON__[:26]Sub::Exporter::Progressive::__ANON__[:26]
0000s0sSub::Exporter::Progressive::::__ANON__[:32]Sub::Exporter::Progressive::__ANON__[:32]
0000s0sSub::Exporter::Progressive::::__ANON__[:66]Sub::Exporter::Progressive::__ANON__[:66]
0000s0sSub::Exporter::Progressive::::__ANON__[:71]Sub::Exporter::Progressive::__ANON__[:71]
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Sub::Exporter::Progressive;
2
3232µs247µs
# spent 31µs (15+16) within Sub::Exporter::Progressive::BEGIN@3 which was called: # once (15µs+16µs) by Devel::GlobalDestruction::BEGIN@8 at line 3
use strict;
# spent 31µs making 1 call to Sub::Exporter::Progressive::BEGIN@3 # spent 16µs making 1 call to strict::import
4243µs218µs
# spent 13µs (9+4) within Sub::Exporter::Progressive::BEGIN@4 which was called: # once (9µs+4µs) by Devel::GlobalDestruction::BEGIN@8 at line 4
use warnings;
# spent 13µs making 1 call to Sub::Exporter::Progressive::BEGIN@4 # spent 4µs making 1 call to warnings::import
5
61800nsour $VERSION = '0.001011';
7
8232µs14µs
# spent 4µs within Sub::Exporter::Progressive::BEGIN@8 which was called: # once (4µs+0s) by Devel::GlobalDestruction::BEGIN@8 at line 8
use Carp ();
# spent 4µs making 1 call to Sub::Exporter::Progressive::BEGIN@8
9279µs14µs
# spent 4µs within Sub::Exporter::Progressive::BEGIN@9 which was called: # once (4µs+0s) by Devel::GlobalDestruction::BEGIN@8 at line 9
use List::Util ();
# spent 4µs making 1 call to Sub::Exporter::Progressive::BEGIN@9
10
11
# spent 116µs (30+86) within Sub::Exporter::Progressive::import which was called: # once (30µs+86µs) by Devel::GlobalDestruction::BEGIN@8 at line 11 of Devel/GlobalDestruction.pm
sub import {
1211µs my ($self, @args) = @_;
13
141600ns my $inner_target = caller;
1512µs186µs my $export_data = sub_export_options($inner_target, @args);
# spent 86µs making 1 call to Sub::Exporter::Progressive::sub_export_options
16
171100ns my $full_exporter;
182102µs240µs
# spent 26µs (12+14) within Sub::Exporter::Progressive::BEGIN@18 which was called: # once (12µs+14µs) by Devel::GlobalDestruction::BEGIN@8 at line 18
no strict 'refs';
# spent 26µs making 1 call to Sub::Exporter::Progressive::BEGIN@18 # spent 14µs making 1 call to strict::unimport
1917µs @{"${inner_target}::EXPORT_OK"} = @{$export_data->{exports}};
2013µs @{"${inner_target}::EXPORT"} = @{$export_data->{defaults}};
2114µs %{"${inner_target}::EXPORT_TAGS"} = %{$export_data->{tags}};
22
# spent 95µs (63+32) within Sub::Exporter::Progressive::__ANON__[/opt/perl-5.18.1/lib/site_perl/5.18.1/Sub/Exporter/Progressive.pm:40] which was called 2 times, avg 48µs/call: # once (32µs+17µs) by Class::MOP::Package::BEGIN@15 at line 15 of Class/MOP/Package.pm # once (32µs+15µs) by Moose::Meta::Role::BEGIN@16 at line 16 of Moose/Meta/Role.pm
*{"${inner_target}::import"} = sub {
232776µs238µs
# spent 23µs (9+14) within Sub::Exporter::Progressive::BEGIN@23 which was called: # once (9µs+14µs) by Devel::GlobalDestruction::BEGIN@8 at line 23
use strict;
# spent 23µs making 1 call to Sub::Exporter::Progressive::BEGIN@23 # spent 14µs making 1 call to strict::import
2426µs my ($self, @args) = @_;
25
26446µs637µs if (List::Util::first { ref || !m/ \A [:-]? \w+ \z /xm } @args) {
# spent 31µs making 4 calls to List::Util::first, avg 8µs/call # spent 6µs making 2 calls to Sub::Exporter::Progressive::CORE:match, avg 3µs/call
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;
32213µs22µs } elsif (defined(my $num = List::Util::first { !ref and m/^\d/ } @args)) {
# spent 2µs making 2 calls to Sub::Exporter::Progressive::CORE:match, avg 1µs/call
33 die "cannot export symbols with a leading digit: '$num'";
34 } else {
3521µs require Exporter;
36212µs21µs s/ \A - /:/xm for @args;
# spent 1µs making 2 calls to Sub::Exporter::Progressive::CORE:subst, avg 550ns/call
3723µs @_ = ($self, @args);
38226µs263µs goto \&Exporter::import;
# spent 63µs making 2 calls to Exporter::import, avg 31µs/call
39 }
4016µs };
4115µs return;
42}
43
441400nsmy $too_complicated = <<'DEATH';
45You are using Sub::Exporter::Progressive, but the features your program uses from
46Sub::Exporter cannot be implemented without Sub::Exporter, so you might as well
47just use vanilla Sub::Exporter
48DEATH
49
50
# spent 86µs (55+31) within Sub::Exporter::Progressive::sub_export_options which was called: # once (55µs+31µs) by Sub::Exporter::Progressive::import at line 15
sub sub_export_options {
511500ns my ($inner_target, $setup, $options) = @_;
52
531100ns my @exports;
5410s my @defaults;
551100ns my %tags;
56
571500ns if ($setup eq '-setup') {
5813µs my %options = %$options;
59
60 OPTIONS:
6111µs for my $opt (keys %options) {
6223µs if ($opt eq 'exports') {
63
641900ns Carp::croak $too_complicated if ref $options{exports} ne 'ARRAY';
651900ns @exports = @{$options{exports}};
66231µs119µs Carp::croak $too_complicated if List::Util::first { ref } @exports;
# spent 19µs making 1 call to List::Util::first
67
68 } elsif ($opt eq 'groups') {
6912µs %tags = %{$options{groups}};
7011µs for my $tagset (values %tags) {
71216µs212µ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 3µs making 1 call to Sub::Exporter::Progressive::CORE:match
72 }
7311µs @defaults = @{$tags{default} || [] };
74 } else {
75 Carp::croak $too_complicated;
76 }
77 }
78314µs22µs @{$_} = map { / \A [:-] all \z /x ? @exports : $_ } @{$_} for \@defaults, values %tags;
# spent 2µs making 2 calls to Sub::Exporter::Progressive::CORE:match, avg 1µs/call
7911µs $tags{all} ||= [ @exports ];
8012µs my %exports = map { $_ => 1 } @exports;
811800ns my @errors = grep { not $exports{$_} } @defaults;
8211µs Carp::croak join(', ', @errors) . " is not exported by the $inner_target module\n" if @errors;
83 }
84
85 return {
8616µs exports => \@exports,
87 defaults => \@defaults,
88 original => $options,
89 tags => \%tags,
90 };
91}
92
9314µs1;
94
95=encoding utf8
96
97=head1 NAME
98
99Sub::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
124L<Sub::Exporter> is an incredibly powerful module, but with that power comes
125great responsibility, er- as well as some runtime penalties. This module
126is a C<Sub::Exporter> wrapper that will let your users just use L<Exporter>
127if all they are doing is picking exports, but use C<Sub::Exporter> if your
128users try to use C<Sub::Exporter>'s more advanced features, like
129renaming exports, if they try to use them.
130
131Note that this module will export C<@EXPORT>, C<@EXPORT_OK> and
132C<%EXPORT_TAGS> package variables for C<Exporter> to work. Additionally, if
133your package uses advanced C<Sub::Exporter> features like currying, this module
134will only ever use C<Sub::Exporter>, so you might as well use it directly.
135
136=head1 AUTHOR
137
138frew - Arthur Axel Schmidt (cpan:FREW) <frioux+cpan@gmail.com>
139
140=head1 CONTRIBUTORS
141
142ilmari - Dagfinn Ilmari Mannsåker (cpan:ILMARI) <ilmari@ilmari.org>
143
144mst - Matt S. Trout (cpan:MSTROUT) <mst@shadowcat.co.uk>
145
146leont - Leon Timmermans (cpan:LEONT) <leont@cpan.org>
147
148=head1 COPYRIGHT
149
150Copyright (c) 2012 the Sub::Exporter::Progressive L</AUTHOR> and
151L</CONTRIBUTORS> as listed above.
152
153=head1 LICENSE
154
155This library is free software and may be distributed under the same terms
156as perl itself.
157
158=cut
 
# spent 13µs within Sub::Exporter::Progressive::CORE:match which was called 7 times, avg 2µs/call: # 2 times (6µs+0s) by List::Util::first at line 26, avg 3µs/call # 2 times (2µs+0s) by Sub::Exporter::Progressive::sub_export_options at line 78, avg 1µs/call # 2 times (2µs+0s) by List::Util::first at line 32, avg 1µs/call # once (3µs+0s) by List::Util::first at line 71
sub Sub::Exporter::Progressive::CORE:match; # opcode
# spent 1µs within Sub::Exporter::Progressive::CORE:subst which was called 2 times, avg 550ns/call: # 2 times (1µs+0s) by Sub::Exporter::Progressive::__ANON__[/opt/perl-5.18.1/lib/site_perl/5.18.1/Sub/Exporter/Progressive.pm:40] at line 36, avg 550ns/call
sub Sub::Exporter::Progressive::CORE:subst; # opcode