← Index
NYTProf Performance Profile   « line view »
For examples/Atom-timer.pl
  Run on Mon Aug 12 14:45:28 2013
Reported on Mon Aug 12 14:46:14 2013

Filename/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/Sub/Exporter.pm
StatementsExecuted 10310 statements in 10.3ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
38112.42ms24.5msSub::Exporter::::_do_import Sub::Exporter::_do_import
364111.74ms4.07msSub::Exporter::::default_generator Sub::Exporter::default_generator
96211.67ms5.27msSub::Exporter::::_expand_groups Sub::Exporter::_expand_groups (recurses: max depth 2, inclusive time 5.25ms)
38321.61ms14.1msSub::Exporter::::default_installer Sub::Exporter::default_installer
5811711µs4.77msSub::Exporter::::_expand_group Sub::Exporter::_expand_group (recurses: max depth 1, inclusive time 3.56ms)
381312710µs31.4msSub::Exporter::::__ANON__[:337] Sub::Exporter::__ANON__[:337]
48021592µs592µsSub::Exporter::::_group_name Sub::Exporter::_group_name
3811453µs648µsSub::Exporter::::_collect_collections Sub::Exporter::_collect_collections
3811175µs175µsSub::Exporter::::_mk_collection_builder Sub::Exporter::_mk_collection_builder
611168µs1.59msSub::Exporter::::_rewrite_build_config Sub::Exporter::_rewrite_build_config
61146µs46µsSub::Exporter::::_key_intersection Sub::Exporter::_key_intersection
63237µs1.63msSub::Exporter::::build_exporter Sub::Exporter::build_exporter
61121µs23µsSub::Exporter::::_assert_collector_names_ok Sub::Exporter::_assert_collector_names_ok
22220µs499µsSub::Exporter::::setup_exporter Sub::Exporter::setup_exporter
11115µs15µsMoose::Exporter::::BEGIN@1Moose::Exporter::BEGIN@1
11113µs20µsSub::Exporter::::__ANON__[:159] Sub::Exporter::__ANON__[:159]
1119µs9µsSub::Exporter::::BEGIN@217 Sub::Exporter::BEGIN@217
1119µs19µsMoose::Exporter::::BEGIN@2.1Moose::Exporter::BEGIN@2.1
1119µs15µsSub::Exporter::::BEGIN@12 Sub::Exporter::BEGIN@12
1119µs16µsSub::Exporter::::BEGIN@11 Sub::Exporter::BEGIN@11
1116µs12µsSub::Exporter::::BEGIN@13 Sub::Exporter::BEGIN@13
1116µs9µsMoose::Exporter::::BEGIN@3Moose::Exporter::BEGIN@3
1116µs6µsSub::Exporter::::_setup Sub::Exporter::_setup
1114µs83µsSub::Exporter::::__ANON__[:460] Sub::Exporter::__ANON__[:460]
1113µs3µsSub::Exporter::::BEGIN@10 Sub::Exporter::BEGIN@10
1112µs2µsSub::Exporter::::CORE:match Sub::Exporter::CORE:match (opcode)
0000s0sSub::Exporter::::__ANON__[:354] Sub::Exporter::__ANON__[:354]
0000s0sSub::Exporter::::default_exporter Sub::Exporter::default_exporter
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1238µs115µs
# spent 15µs within Moose::Exporter::BEGIN@1 which was called: # once (15µs+0s) by Moose::Exporter::BEGIN@17 at line 1
use 5.006;
# spent 15µs making 1 call to Moose::Exporter::BEGIN@1
2219µs229µs
# spent 19µs (9+10) within Moose::Exporter::BEGIN@2.1 which was called: # once (9µs+10µs) by Moose::Exporter::BEGIN@17 at line 2
use strict;
# spent 19µs making 1 call to Moose::Exporter::BEGIN@2.1 # spent 10µs making 1 call to strict::import
3234µs212µs
# spent 9µs (6+3) within Moose::Exporter::BEGIN@3 which was called: # once (6µs+3µs) by Moose::Exporter::BEGIN@17 at line 3
use warnings;
# spent 9µs making 1 call to Moose::Exporter::BEGIN@3 # spent 3µs making 1 call to warnings::import
4package Sub::Exporter;
5{
62800ns $Sub::Exporter::VERSION = '0.986';
7}
8# ABSTRACT: a sophisticated exporter for custom-built routines
9
10220µs13µs
# spent 3µs within Sub::Exporter::BEGIN@10 which was called: # once (3µs+0s) by Moose::Exporter::BEGIN@17 at line 10
use Carp ();
# spent 3µs making 1 call to Sub::Exporter::BEGIN@10
11332µs223µs
# spent 16µs (9+7) within Sub::Exporter::BEGIN@11 which was called: # once (9µs+7µs) by Moose::Exporter::BEGIN@17 at line 11
use Data::OptList 0.100 ();
# spent 16µs making 1 call to Sub::Exporter::BEGIN@11 # spent 7µs making 1 call to UNIVERSAL::VERSION
12330µs221µs
# spent 15µs (9+6) within Sub::Exporter::BEGIN@12 which was called: # once (9µs+6µs) by Moose::Exporter::BEGIN@17 at line 12
use Params::Util 0.14 (); # _CODELIKE
# spent 15µs making 1 call to Sub::Exporter::BEGIN@12 # spent 6µs making 1 call to UNIVERSAL::VERSION
133833µs218µs
# spent 12µs (6+6) within Sub::Exporter::BEGIN@13 which was called: # once (6µs+6µs) by Moose::Exporter::BEGIN@17 at line 13
use Sub::Install 0.92 ();
# spent 12µs making 1 call to Sub::Exporter::BEGIN@13 # spent 6µs making 1 call to UNIVERSAL::VERSION
14
15
16# Given a potential import name, this returns the group name -- if it's got a
17# group prefix.
18
# spent 592µs within Sub::Exporter::_group_name which was called 480 times, avg 1µs/call: # 422 times (519µs+0s) by Sub::Exporter::_expand_groups at line 36, avg 1µs/call # 58 times (73µs+0s) by Sub::Exporter::_expand_group at line 76, avg 1µs/call
sub _group_name {
1948060µs my ($name) = @_;
20
21480542µs return if (index q{-:}, (substr $name, 0, 1)) == -1;
22116178µs return substr $name, 1;
23}
24
25# \@groups is a canonicalized opt list of exports and groups this returns
26# another canonicalized opt list with groups replaced with relevant exports.
27# \%seen is groups we've already expanded and can ignore.
28# \%merge is merged options from the group we're descending through.
29
# spent 5.27ms (1.67+3.59) within Sub::Exporter::_expand_groups which was called 96 times, avg 55µs/call: # 58 times (1.26ms+-1.26ms) by Sub::Exporter::_expand_group at line 124, avg 0s/call # 38 times (410µs+4.86ms) by Sub::Exporter::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/Sub/Exporter.pm:337] at line 323, avg 139µs/call
sub _expand_groups {
309632µs my ($class, $config, $groups, $collection, $seen, $merge) = @_;
319616µs $seen ||= {};
32966µs $merge ||= {};
339650µs my @groups = @$groups;
34
3596131µs for my $i (reverse 0 .. $#groups) {
36422375µs422519µs if (my $group_name = _group_name($groups[$i][0])) {
# spent 519µs making 422 calls to Sub::Exporter::_group_name, avg 1µs/call
375853µs my $seen = { %$seen }; # faux-dynamic scoping
38
3958135µs584.77ms splice @groups, $i, 1,
# spent 8.32ms making 58 calls to Sub::Exporter::_expand_group, avg 143µs/call, recursion: max depth 1, sum of overlapping time 3.56ms
40 _expand_group($class, $config, $groups[$i], $collection, $seen, $merge);
41 } else {
42 # there's nothing to munge in this export's args
43364167µs next unless my %merge = %$merge;
44
45 # we have things to merge in; do so
46 my $prefix = (delete $merge{-prefix}) || '';
47 my $suffix = (delete $merge{-suffix}) || '';
48
49 if (
50 Params::Util::_CODELIKE($groups[$i][1]) ## no critic Private
51 or
52 Params::Util::_SCALAR0($groups[$i][1]) ## no critic Private
53 ) {
54 # this entry was build by a group generator
55 $groups[$i][0] = $prefix . $groups[$i][0] . $suffix;
56 } else {
57 my $as
58 = ref $groups[$i][1]{-as} ? $groups[$i][1]{-as}
59 : $groups[$i][1]{-as} ? $prefix . $groups[$i][1]{-as} . $suffix
60 : $prefix . $groups[$i][0] . $suffix;
61
62 $groups[$i][1] = { %{ $groups[$i][1] }, %merge, -as => $as };
63 }
64 }
65 }
66
6796165µs return \@groups;
68}
69
70# \@group is a name/value pair from an opt list.
71
# spent 4.77ms (711µs+4.06) within Sub::Exporter::_expand_group which was called 58 times, avg 82µs/call: # 58 times (711µs+4.06ms) by Sub::Exporter::_expand_groups at line 39, avg 82µs/call
sub _expand_group {
725817µs my ($class, $config, $group, $collection, $seen, $merge) = @_;
73583µs $merge ||= {};
74
755814µs my ($group_name, $group_arg) = @$group;
765838µs5873µs $group_name = _group_name($group_name);
# spent 73µs making 58 calls to Sub::Exporter::_group_name, avg 1µs/call
77
785822µs Carp::croak qq(group "$group_name" is not exported by the $class module)
79 unless exists $config->{groups}{$group_name};
80
815829µs return if $seen->{$group_name}++;
82
83585µs if (ref $group_arg) {
84 my $prefix = (delete $merge->{-prefix}||'') . ($group_arg->{-prefix}||'');
85 my $suffix = ($group_arg->{-suffix}||'') . (delete $merge->{-suffix}||'');
86 $merge = {
87 %$merge,
88 %$group_arg,
89 ($prefix ? (-prefix => $prefix) : ()),
90 ($suffix ? (-suffix => $suffix) : ()),
91 };
92 }
93
945819µs my $exports = $config->{groups}{$group_name};
95
9658208µs11666µs if (
# spent 42µs making 58 calls to Params::Util::_CODELIKE, avg 726ns/call # spent 23µs making 58 calls to Params::Util::_SCALAR0, avg 403ns/call
97 Params::Util::_CODELIKE($exports) ## no critic Private
98 or
99 Params::Util::_SCALAR0($exports) ## no critic Private
100 ) {
101 # I'm not very happy with this code for hiding -prefix and -suffix, but
102 # it's needed, and I'm not sure, offhand, how to make it better.
103 # -- rjbs, 2006-12-05
104 my $group_arg = $merge ? { %$merge } : {};
105 delete $group_arg->{-prefix};
106 delete $group_arg->{-suffix};
107
108 my $group = Params::Util::_CODELIKE($exports) ## no critic Private
109 ? $exports->($class, $group_name, $group_arg, $collection)
110 : $class->$$exports($group_name, $group_arg, $collection);
111
112 Carp::croak qq(group generator "$group_name" did not return a hashref)
113 if ref $group ne 'HASH';
114
115 my $stuff = [ map { [ $_ => $group->{$_} ] } keys %$group ];
116 return @{
117 _expand_groups($class, $config, $stuff, $collection, $seen, $merge)
118 };
119 } else {
1205849µs582.22ms $exports
# spent 2.22ms making 58 calls to Data::OptList::mkopt, avg 38µs/call
121 = Data::OptList::mkopt($exports, "$group_name exports");
122
123 return @{
12458183µs580s _expand_groups($class, $config, $exports, $collection, $seen, $merge)
# spent 5.25ms making 58 calls to Sub::Exporter::_expand_groups, avg 91µs/call, recursion: max depth 2, sum of overlapping time 5.25ms
125 };
126 }
127}
128
129
# spent 175µs within Sub::Exporter::_mk_collection_builder which was called 38 times, avg 5µs/call: # 38 times (175µs+0s) by Sub::Exporter::_collect_collections at line 175, avg 5µs/call
sub _mk_collection_builder {
130388µs my ($col, $etc) = @_;
1313817µs my ($config, $import_args, $class, $into) = @$etc;
132
133381µs my %seen;
134
# spent 20µs (13+6) within Sub::Exporter::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/Sub/Exporter.pm:159] which was called: # once (13µs+6µs) by Sub::Exporter::_collect_collections at line 177
sub {
1351200ns my ($collection) = @_;
1361400ns my ($name, $value) = @$collection;
137
1381600ns Carp::croak "collection $name provided multiple times in import"
139 if $seen{ $name }++;
140
1411700ns if (ref(my $hook = $config->{collectors}{$name})) {
14212µs my $arg = {
143 name => $name,
144 config => $config,
145 import_args => $import_args,
146 class => $class,
147 into => $into,
148 };
149
15011µs my $error_msg = "collection $name failed validation";
15114µs1600ns if (Params::Util::_SCALAR0($hook)) { ## no critic Private
# spent 600ns making 1 call to Params::Util::_SCALAR0
152 Carp::croak $error_msg unless $class->$$hook($value, $arg);
153 } else {
15411µs16µs Carp::croak $error_msg unless $hook->($value, $arg);
# spent 6µs making 1 call to Sub::Exporter::_setup
155 }
156 }
157
15813µs $col->{ $name } = $value;
159 }
16038163µs}
161
162# Given a config and pre-canonicalized importer args, remove collections from
163# the args and return them.
164
# spent 648µs (453+195) within Sub::Exporter::_collect_collections which was called 38 times, avg 17µs/call: # 38 times (453µs+195µs) by Sub::Exporter::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/Sub/Exporter.pm:337] at line 321, avg 17µs/call
sub _collect_collections {
1653814µs my ($config, $import_args, $class, $into) = @_;
166
167 my @collections
168 = map { splice @$import_args, $_, 1 }
1693889µs grep { exists $config->{collectors}{ $import_args->[$_][0] } }
170 reverse 0 .. $#$import_args;
171
1723810µs unshift @collections, [ INIT => {} ] if $config->{collectors}{INIT};
173
1743810µs my $col = {};
1753843µs38175µs my $builder = _mk_collection_builder($col, \@_);
# spent 175µs making 38 calls to Sub::Exporter::_mk_collection_builder, avg 5µs/call
1763817µs for my $collection (@collections) {
17712µs120µs $builder->($collection)
# spent 20µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:159]
178 }
179
18038237µs return $col;
181}
182
183
184
# spent 499µs (20+479) within Sub::Exporter::setup_exporter which was called 2 times, avg 250µs/call: # once (10µs+242µs) by Moose::Meta::Class::BEGIN@28 at line 40 of Moose/Util.pm # once (10µs+237µs) by Moose::Exporter::BEGIN@17 at line 461
sub setup_exporter {
1852700ns my ($config) = @_;
186
1872800ns Carp::croak 'into and into_level may not both be supplied to exporter'
188 if exists $config->{into} and exists $config->{into_level};
189
19021µs my $as = delete $config->{as} || 'import';
19122µs my $into
192 = exists $config->{into} ? delete $config->{into}
193 : exists $config->{into_level} ? caller(delete $config->{into_level})
194 : caller(0);
195
19622µs2396µs my $import = build_exporter($config);
# spent 396µs making 2 calls to Sub::Exporter::build_exporter, avg 198µs/call
197
198211µs283µs Sub::Install::reinstall_sub({
# spent 83µs making 2 calls to Sub::Install::__ANON__[Sub/Install.pm:132], avg 41µs/call
199 code => $import,
200 into => $into,
201 as => $as,
202 });
203}
204
205
206
# spent 46µs within Sub::Exporter::_key_intersection which was called 6 times, avg 8µs/call: # 6 times (46µs+0s) by Sub::Exporter::_rewrite_build_config at line 262, avg 8µs/call
sub _key_intersection {
20762µs my ($x, $y) = @_;
208631µs my %seen = map { $_ => 1 } keys %$x;
209618µs my @names = grep { $seen{$_} } keys %$y;
210}
211
212# Given the config passed to setup_exporter, which contains sugary opt list
213# data, rewrite the opt lists into hashes, catch a few kinds of invalid
214# configurations, and set up defaults. Since the config is a reference, it's
215# rewritten in place.
2161100nsmy %valid_config_key;
217
# spent 9µs within Sub::Exporter::BEGIN@217 which was called: # once (9µs+0s) by Moose::Exporter::BEGIN@17 at line 222
BEGIN {
218 %valid_config_key =
219110µs map { $_ => 1 }
220 qw(as collectors installer generator exports groups into into_level),
221 qw(exporter), # deprecated
2221930µs19µs}
# spent 9µs making 1 call to Sub::Exporter::BEGIN@217
223
224
# spent 23µs (21+1) within Sub::Exporter::_assert_collector_names_ok which was called 6 times, avg 4µs/call: # 6 times (21µs+1µs) by Sub::Exporter::_rewrite_build_config at line 260, avg 4µs/call
sub _assert_collector_names_ok {
22561µs my ($collectors) = @_;
226
227724µs12µs for my $reserved_name (grep { /\A[_A-Z]+\z/ } keys %$collectors) {
# spent 2µs making 1 call to Sub::Exporter::CORE:match
228 Carp::croak "unknown reserved collector name: $reserved_name"
229 if $reserved_name ne 'INIT';
230 }
231}
232
233
# spent 1.59ms (168µs+1.42) within Sub::Exporter::_rewrite_build_config which was called 6 times, avg 265µs/call: # 6 times (168µs+1.42ms) by Sub::Exporter::build_exporter at line 290, avg 265µs/call
sub _rewrite_build_config {
23461µs my ($config) = @_;
235
236616µs if (my @keys = grep { not exists $valid_config_key{$_} } keys %$config) {
237 Carp::croak "unknown options (@keys) passed to Sub::Exporter";
238 }
239
24062µs Carp::croak q(into and into_level may not both be supplied to exporter)
241 if exists $config->{into} and exists $config->{into_level};
242
243 # XXX: Remove after deprecation period.
24462µs if ($config->{exporter}) {
245 Carp::cluck "'exporter' argument to build_exporter is deprecated. Use 'installer' instead; the semantics are identical.";
246 $config->{installer} = delete $config->{exporter};
247 }
248
24962µs Carp::croak q(into and into_level may not both be supplied to exporter)
250 if exists $config->{into} and exists $config->{into_level};
251
25264µs for (qw(exports collectors)) {
2531238µs121.15ms $config->{$_} = Data::OptList::mkopt_hash(
# spent 1.15ms making 12 calls to Data::OptList::mkopt_hash, avg 96µs/call
254 $config->{$_},
255 $_,
256 [ 'CODE', 'SCALAR' ],
257 );
258 }
259
26069µs623µs _assert_collector_names_ok($config->{collectors});
# spent 23µs making 6 calls to Sub::Exporter::_assert_collector_names_ok, avg 4µs/call
261
262611µs646µs if (my @names = _key_intersection(@$config{qw(exports collectors)})) {
# spent 46µs making 6 calls to Sub::Exporter::_key_intersection, avg 8µs/call
263 Carp::croak "names (@names) used in both collections and exports";
264 }
265
266617µs6206µs $config->{groups} = Data::OptList::mkopt_hash(
# spent 206µs making 6 calls to Data::OptList::mkopt_hash, avg 34µs/call
267 $config->{groups},
268 'groups',
269 [
270 'HASH', # standard opt list
271 'ARRAY', # standard opt list
272 'CODE', # group generator
273 'SCALAR', # name of group generation method
274 ]
275 );
276
277 # by default, export nothing
27864µs $config->{groups}{default} ||= [];
279
280 # by default, build an all-inclusive 'all' group
281610µs $config->{groups}{all} ||= [ keys %{ $config->{exports} } ];
282
28364µs $config->{generator} ||= \&default_generator;
284613µs $config->{installer} ||= \&default_installer;
285}
286
287
# spent 1.63ms (37µs+1.59) within Sub::Exporter::build_exporter which was called 6 times, avg 271µs/call: # 3 times (20µs+1.13ms) by Moose::Exporter::_make_exporter at line 139 of Moose/Exporter.pm, avg 384µs/call # 2 times (12µs+384µs) by Sub::Exporter::setup_exporter at line 196, avg 198µs/call # once (5µs+73µs) by Sub::Exporter::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/Sub/Exporter.pm:460] at line 460
sub build_exporter {
28861µs my ($config) = @_;
289
29066µs61.59ms _rewrite_build_config($config);
# spent 1.59ms making 6 calls to Sub::Exporter::_rewrite_build_config, avg 265µs/call
291
292
# spent 31.4ms (710µs+30.7) within Sub::Exporter::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/Sub/Exporter.pm:337] which was called 38 times, avg 826µs/call: # 26 times (485µs+29.5ms) by Moose::Exporter::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Exporter.pm:519] at line 518 of Moose/Exporter.pm, avg 1.15ms/call # once (16µs+216µs) by String::RewritePrefix::BEGIN@11 at line 13 of String/RewritePrefix.pm # once (21µs+133µs) by Moose::Meta::TypeConstraint::DuckType::BEGIN@16 at line 16 of Moose/Meta/TypeConstraint/DuckType.pm # once (16µs+113µs) by Moose::Meta::Role::BEGIN@24 at line 24 of Moose/Meta/Role.pm # once (17µs+99µs) by Moose::Meta::Role::Application::ToClass::BEGIN@14 at line 14 of Moose/Meta/Role/Application/ToClass.pm # once (24µs+91µs) by Moose::Meta::Role::Method::Conflicting::BEGIN@13 at line 13 of Moose/Meta/Role/Method/Conflicting.pm # once (22µs+87µs) by Moose::Util::BEGIN@15 at line 15 of Moose/Util.pm # once (20µs+87µs) by Moose::Exporter::BEGIN@17 at line 17 of Moose/Exporter.pm # once (18µs+72µs) by MooseX::Storage::Basic::BEGIN@11 at line 11 of MooseX/Storage/Basic.pm # once (18µs+70µs) by Moose::Role::BEGIN@15 at line 15 of Moose/Role.pm # once (18µs+68µs) by Moose::Meta::Method::Accessor::Native::Writer::BEGIN@13 at line 13 of Moose/Meta/Method/Accessor/Native/Writer.pm # once (17µs+66µs) by Moose::Meta::Class::BEGIN@28 at line 28 of Moose/Meta/Class.pm # once (17µs+65µs) by Moose::Meta::Attribute::Native::Trait::BEGIN@14 at line 14 of Moose/Meta/Attribute/Native/Trait.pm
my $import = sub {
2933813µs my ($class) = shift;
294
295 # XXX: clean this up -- rjbs, 2006-03-16
2963818µs my $special = (ref $_[0]) ? shift(@_) : {};
2973810µs Carp::croak q(into and into_level may not both be supplied to exporter)
298 if exists $special->{into} and exists $special->{into_level};
299
300387µs if ($special->{exporter}) {
301 Carp::cluck "'exporter' special import argument is deprecated. Use 'installer' instead; the semantics are identical.";
302 $special->{installer} = delete $special->{exporter};
303 }
304
3053848µs my $into
306 = defined $special->{into} ? delete $special->{into}
307 : defined $special->{into_level} ? caller(delete $special->{into_level})
308 : defined $config->{into} ? $config->{into}
309 : defined $config->{into_level} ? caller($config->{into_level})
310 : caller(0);
311
3123818µs my $generator = delete $special->{generator} || $config->{generator};
3133811µs my $installer = delete $special->{installer} || $config->{installer};
314
315 # this builds a AOA, where the inner arrays are [ name => value_ref ]
3163850µs38304µs my $import_args = Data::OptList::mkopt([ @_ ]);
# spent 304µs making 38 calls to Data::OptList::mkopt, avg 8µs/call
317
318 # is this right? defaults first or collectors first? -- rjbs, 2006-06-24
3193843µs $import_args = [ [ -default => undef ] ] unless @$import_args;
320
3213841µs38648µs my $collection = _collect_collections($config, $import_args, $class, $into);
# spent 648µs making 38 calls to Sub::Exporter::_collect_collections, avg 17µs/call
322
3233836µs385.27ms my $to_import = _expand_groups($class, $config, $import_args, $collection);
# spent 5.27ms making 38 calls to Sub::Exporter::_expand_groups, avg 139µs/call
324
325 # now, finally $import_arg is really the "to do" list
32638249µs3824.5ms _do_import(
# spent 24.5ms making 38 calls to Sub::Exporter::_do_import, avg 644µs/call
327 {
328 class => $class,
329 col => $collection,
330 config => $config,
331 into => $into,
332 generator => $generator,
333 installer => $installer,
334 },
335 $to_import,
336 );
337616µs };
338
339613µs return $import;
340}
341
342
# spent 24.5ms (2.42+22.0) within Sub::Exporter::_do_import which was called 38 times, avg 644µs/call: # 38 times (2.42ms+22.0ms) by Sub::Exporter::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/Sub/Exporter.pm:337] at line 326, avg 644µs/call
sub _do_import {
343388µs my ($arg, $to_import) = @_;
344
345384µs my @todo;
346
3473821µs for my $pair (@$to_import) {
34836480µs my ($name, $import_arg) = @$pair;
349
3503642µs my ($generator, $as);
351
35236445µs1500ns if ($import_arg and Params::Util::_CODELIKE($import_arg)) { ## no critic
# spent 500ns making 1 call to Params::Util::_CODELIKE
353 # This is the case when a group generator has inserted name/code pairs.
354 $generator = sub { $import_arg };
355 $as = $name;
356 } else {
35736479µs $import_arg = { $import_arg ? %$import_arg : () };
358
359364106µs Carp::croak qq("$name" is not exported by the $arg->{class} module)
360 unless exists $arg->{config}{exports}{$name};
361
36236490µs $generator = $arg->{config}{exports}{$name};
363
364364112µs $as = exists $import_arg->{-as} ? (delete $import_arg->{-as}) : $name;
365 }
366
367364721µs3644.07ms my $code = $arg->{generator}->(
# spent 4.07ms making 364 calls to Sub::Exporter::default_generator, avg 11µs/call
368 {
369 class => $arg->{class},
370 name => $name,
371 arg => $import_arg,
372 col => $arg->{col},
373 generator => $generator,
374 }
375 );
376
377364305µs push @todo, $as, $code;
378 }
379
38038133µs3816.9ms $arg->{installer}->(
# spent 16.7ms making 26 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:137], avg 644µs/call # spent 201µs making 12 calls to Sub::Exporter::default_installer, avg 17µs/call
381 {
382 class => $arg->{class},
383 into => $arg->{into},
384 col => $arg->{col},
385 },
386 \@todo,
387 );
388}
389
390## Cute idea, possibly for future use: also supply an "unimport" for:
391## no Module::Whatever qw(arg arg arg);
392# sub _unexport {
393# my (undef, undef, undef, undef, undef, $as, $into) = @_;
394#
395# if (ref $as eq 'SCALAR') {
396# undef $$as;
397# } elsif (ref $as) {
398# Carp::croak "invalid reference type for $as: " . ref $as;
399# } else {
400# no strict 'refs';
401# delete &{$into . '::' . $as};
402# }
403# }
404
405
406
# spent 4.07ms (1.74+2.33) within Sub::Exporter::default_generator which was called 364 times, avg 11µs/call: # 364 times (1.74ms+2.33ms) by Sub::Exporter::_do_import at line 367, avg 11µs/call
sub default_generator {
40736438µs my ($arg) = @_;
408364160µs my ($class, $name, $generator) = @$arg{qw(class name generator)};
409
41036433µs if (not defined $generator) {
411314µs34µs my $code = $class->can($name)
# spent 4µs making 3 calls to UNIVERSAL::can, avg 1µs/call
412 or Carp::croak "can't locate exported subroutine $name via $class";
41336µs return $code;
414 }
415
416 # I considered making this "$class->$generator(" but it seems that
417 # overloading precedence would turn an overloaded-as-code generator object
418 # into a string before code. -- rjbs, 2006-06-11
4193611.32ms7222.33ms return $generator->($class, $name, $arg->{arg}, $arg->{col})
# spent 1.97ms making 176 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:379], avg 11µs/call # spent 149µs making 184 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:307], avg 808ns/call # spent 124µs making 361 calls to Params::Util::_CODELIKE, avg 343ns/call # spent 83µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:460]
420 if Params::Util::_CODELIKE($generator); ## no critic Private
421
422 # This "must" be a scalar reference, to a generator method name.
423 # -- rjbs, 2006-12-05
424 return $class->$$generator($name, $arg->{arg}, $arg->{col});
425}
426
427
428
# spent 14.1ms (1.61+12.5) within Sub::Exporter::default_installer which was called 38 times, avg 370µs/call: # 24 times (1.40ms+11.4ms) by Moose::Exporter::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Exporter.pm:137] at line 129 of Moose/Exporter.pm, avg 534µs/call # 12 times (48µs+153µs) by Sub::Exporter::_do_import at line 380, avg 17µs/call # 2 times (160µs+878µs) by Sub::Exporter::_do_import at line 110 of Moose/Exporter.pm, avg 519µs/call
sub default_installer {
429387µs my ($arg, $to_export) = @_;
430
43138322µs for (my $i = 0; $i < @$to_export; $i += 2) {
432362150µs my ($as, $code) = @$to_export[ $i, $i+1 ];
433
434 # Allow as isa ARRAY to push onto an array?
435 # Allow into isa HASH to install name=>code into hash?
436
437362111µs if (ref $as eq 'SCALAR') {
438 $$as = $code;
439 } elsif (ref $as) {
440 Carp::croak "invalid reference type for $as: " . ref $as;
441 } else {
442362557µs36212.5ms Sub::Install::reinstall_sub({
# spent 12.5ms making 362 calls to Sub::Install::__ANON__[Sub/Install.pm:132], avg 34µs/call
443 code => $code,
444 into => $arg->{into},
445 as => $as
446 });
447 }
448 }
449}
450
451sub default_exporter {
452 Carp::cluck "default_exporter is deprecated; call default_installer instead; the semantics are identical";
453 goto &default_installer;
454}
455
456
457setup_exporter({
458 exports => [
459 qw(setup_exporter build_exporter),
46013µs178µs
# spent 83µs (4+78) within Sub::Exporter::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/Sub/Exporter.pm:460] which was called: # once (4µs+78µs) by Sub::Exporter::default_generator at line 419
_import => sub { build_exporter($_[2]) },
# spent 78µs making 1 call to Sub::Exporter::build_exporter
46118µs1247µs ],
# spent 247µs making 1 call to Sub::Exporter::setup_exporter
462 groups => {
463 all => [ qw(setup_exporter build_export) ],
464 },
465 collectors => { -setup => \&_setup },
466});
467
468
# spent 6µs within Sub::Exporter::_setup which was called: # once (6µs+0s) by Sub::Exporter::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/Sub/Exporter.pm:159] at line 154
sub _setup {
4691300ns my ($value, $arg) = @_;
470
4711700ns if (ref $value eq 'HASH') {
47213µs push @{ $arg->{import_args} }, [ _import => { -as => 'import', %$value } ];
47313µs return 1;
474 } elsif (ref $value eq 'ARRAY') {
475 push @{ $arg->{import_args} },
476 [ _import => { -as => 'import', exports => $value } ];
477 return 1;
478 }
479 return;
480}
481
- -
48416µs"jn8:32"; # <-- magic true value
485
486__END__
 
# spent 2µs within Sub::Exporter::CORE:match which was called: # once (2µs+0s) by Sub::Exporter::_assert_collector_names_ok at line 227
sub Sub::Exporter::CORE:match; # opcode