← 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.pm
StatementsExecuted 1338 statements in 4.94ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
911380µs2.79msSub::Exporter::::_do_import Sub::Exporter::_do_import
1721309µs880µsSub::Exporter::::_expand_groups Sub::Exporter::_expand_groups (recurses: max depth 2, inclusive time 633µs)
932262µs1.67msSub::Exporter::::default_installer Sub::Exporter::default_installer
987257µs4.26msSub::Exporter::::__ANON__[:337] Sub::Exporter::__ANON__[:337]
3411252µs470µsSub::Exporter::::default_generator Sub::Exporter::default_generator
911172µs231µsSub::Exporter::::_collect_collections Sub::Exporter::_collect_collections
811164µs707µsSub::Exporter::::_expand_group Sub::Exporter::_expand_group (recurses: max depth 1, inclusive time 420µs)
411159µs1.64msSub::Exporter::::_rewrite_build_config Sub::Exporter::_rewrite_build_config
502191µs91µsSub::Exporter::::_group_name Sub::Exporter::_group_name
91159µs59µsSub::Exporter::::_mk_collection_builder Sub::Exporter::_mk_collection_builder
41144µs44µsSub::Exporter::::_key_intersection Sub::Exporter::_key_intersection
42242µs1.68msSub::Exporter::::build_exporter Sub::Exporter::build_exporter
22227µs672µsSub::Exporter::::setup_exporter Sub::Exporter::setup_exporter
41123µs25µsSub::Exporter::::_assert_collector_names_ok Sub::Exporter::_assert_collector_names_ok
11122µs22µsMoose::Exporter::::BEGIN@1Moose::Exporter::BEGIN@1
11114µs23µsSub::Exporter::::BEGIN@12 Sub::Exporter::BEGIN@12
11113µs24µsSub::Exporter::::BEGIN@11 Sub::Exporter::BEGIN@11
11113µs17µsMoose::Exporter::::BEGIN@3Moose::Exporter::BEGIN@3
11112µs12µsSub::Exporter::::BEGIN@217 Sub::Exporter::BEGIN@217
11110µs19µsSub::Exporter::::BEGIN@13 Sub::Exporter::BEGIN@13
1118µs23µsMoose::Exporter::::BEGIN@2.1Moose::Exporter::BEGIN@2.1
1114µs4µsSub::Exporter::::BEGIN@10 Sub::Exporter::BEGIN@10
1112µs2µsSub::Exporter::::CORE:match Sub::Exporter::CORE:match (opcode)
0000s0sSub::Exporter::::__ANON__[:159] Sub::Exporter::__ANON__[:159]
0000s0sSub::Exporter::::__ANON__[:354] Sub::Exporter::__ANON__[:354]
0000s0sSub::Exporter::::__ANON__[:460] Sub::Exporter::__ANON__[:460]
0000s0sSub::Exporter::::_setup Sub::Exporter::_setup
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
1257µs122µs
# spent 22µs within Moose::Exporter::BEGIN@1 which was called: # once (22µs+0s) by Moose::Exporter::BEGIN@17 at line 1
use 5.006;
# spent 22µs making 1 call to Moose::Exporter::BEGIN@1
2236µs238µs
# spent 23µs (8+15) within Moose::Exporter::BEGIN@2.1 which was called: # once (8µs+15µs) by Moose::Exporter::BEGIN@17 at line 2
use strict;
# spent 23µs making 1 call to Moose::Exporter::BEGIN@2.1 # spent 15µs making 1 call to strict::import
3253µs222µs
# spent 17µs (13+5) within Moose::Exporter::BEGIN@3 which was called: # once (13µs+5µs) by Moose::Exporter::BEGIN@17 at line 3
use warnings;
# spent 17µs making 1 call to Moose::Exporter::BEGIN@3 # spent 5µs making 1 call to warnings::import
4package Sub::Exporter;
5{
621µs $Sub::Exporter::VERSION = '0.987';
7}
8# ABSTRACT: a sophisticated exporter for custom-built routines
9
10230µs14µs
# spent 4µs within Sub::Exporter::BEGIN@10 which was called: # once (4µs+0s) by Moose::Exporter::BEGIN@17 at line 10
use Carp ();
# spent 4µs making 1 call to Sub::Exporter::BEGIN@10
11350µs235µs
# spent 24µs (13+11) within Sub::Exporter::BEGIN@11 which was called: # once (13µs+11µs) by Moose::Exporter::BEGIN@17 at line 11
use Data::OptList 0.100 ();
# spent 24µs making 1 call to Sub::Exporter::BEGIN@11 # spent 11µs making 1 call to UNIVERSAL::VERSION
12352µs233µs
# spent 23µs (14+10) within Sub::Exporter::BEGIN@12 which was called: # once (14µs+10µs) by Moose::Exporter::BEGIN@17 at line 12
use Params::Util 0.14 (); # _CODELIKE
# spent 23µs making 1 call to Sub::Exporter::BEGIN@12 # spent 10µs making 1 call to UNIVERSAL::VERSION
1331.24ms228µs
# spent 19µs (10+9) within Sub::Exporter::BEGIN@13 which was called: # once (10µs+9µs) by Moose::Exporter::BEGIN@17 at line 13
use Sub::Install 0.92 ();
# spent 19µs making 1 call to Sub::Exporter::BEGIN@13 # spent 9µ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 91µs within Sub::Exporter::_group_name which was called 50 times, avg 2µs/call: # 42 times (78µs+0s) by Sub::Exporter::_expand_groups at line 36, avg 2µs/call # 8 times (14µs+0s) by Sub::Exporter::_expand_group at line 76, avg 2µs/call
sub _group_name {
195010µs my ($name) = @_;
20
215082µs return if (index q{-:}, (substr $name, 0, 1)) == -1;
221642µ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 880µs (309+570) within Sub::Exporter::_expand_groups which was called 17 times, avg 52µs/call: # 9 times (141µs+739µs) by Sub::Exporter::__ANON__[/opt/perl-5.18.1/lib/site_perl/5.18.1/Sub/Exporter.pm:337] at line 323, avg 98µs/call # 8 times (168µs+-168µs) by Sub::Exporter::_expand_group at line 124, avg 0s/call
sub _expand_groups {
30178µs my ($class, $config, $groups, $collection, $seen, $merge) = @_;
31174µs $seen ||= {};
32173µs $merge ||= {};
331712µs my @groups = @$groups;
34
351730µs for my $i (reverse 0 .. $#groups) {
364262µs4278µs if (my $group_name = _group_name($groups[$i][0])) {
# spent 78µs making 42 calls to Sub::Exporter::_group_name, avg 2µs/call
37811µs my $seen = { %$seen }; # faux-dynamic scoping
38
39832µs8707µs splice @groups, $i, 1,
# spent 1.13ms making 8 calls to Sub::Exporter::_expand_group, avg 141µs/call, recursion: max depth 1, sum of overlapping time 420µs
40 _expand_group($class, $config, $groups[$i], $collection, $seen, $merge);
41 } else {
42 # there's nothing to munge in this export's args
433426µ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
671750µs return \@groups;
68}
69
70# \@group is a name/value pair from an opt list.
71
# spent 707µs (164+543) within Sub::Exporter::_expand_group which was called 8 times, avg 88µs/call: # 8 times (164µs+543µs) by Sub::Exporter::_expand_groups at line 39, avg 88µs/call
sub _expand_group {
7284µs my ($class, $config, $group, $collection, $seen, $merge) = @_;
7382µs $merge ||= {};
74
7583µs my ($group_name, $group_arg) = @$group;
7688µs814µs $group_name = _group_name($group_name);
# spent 14µs making 8 calls to Sub::Exporter::_group_name, avg 2µs/call
77
7886µs Carp::croak qq(group "$group_name" is not exported by the $class module)
79 unless exists $config->{groups}{$group_name};
80
8188µs return if $seen->{$group_name}++;
82
8382µ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
9485µs my $exports = $config->{groups}{$group_name};
95
96850µs1615µs if (
# spent 10µs making 8 calls to Params::Util::_CODELIKE, avg 1µs/call # spent 5µs making 8 calls to Params::Util::_SCALAR0, avg 638ns/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 {
120812µs8301µs $exports
# spent 301µs making 8 calls to Data::OptList::mkopt, avg 38µs/call
121 = Data::OptList::mkopt($exports, "$group_name exports");
122
123 return @{
124848µs80s _expand_groups($class, $config, $exports, $collection, $seen, $merge)
# spent 633µs making 8 calls to Sub::Exporter::_expand_groups, avg 79µs/call, recursion: max depth 2, sum of overlapping time 633µs
125 };
126 }
127}
128
129
# spent 59µs within Sub::Exporter::_mk_collection_builder which was called 9 times, avg 7µs/call: # 9 times (59µs+0s) by Sub::Exporter::_collect_collections at line 175, avg 7µs/call
sub _mk_collection_builder {
13093µs my ($col, $etc) = @_;
13196µs my ($config, $import_args, $class, $into) = @$etc;
132
13391µs my %seen;
134 sub {
135 my ($collection) = @_;
136 my ($name, $value) = @$collection;
137
138 Carp::croak "collection $name provided multiple times in import"
139 if $seen{ $name }++;
140
141 if (ref(my $hook = $config->{collectors}{$name})) {
142 my $arg = {
143 name => $name,
144 config => $config,
145 import_args => $import_args,
146 class => $class,
147 into => $into,
148 };
149
150 my $error_msg = "collection $name failed validation";
151 if (Params::Util::_SCALAR0($hook)) { ## no critic Private
152 Carp::croak $error_msg unless $class->$$hook($value, $arg);
153 } else {
154 Carp::croak $error_msg unless $hook->($value, $arg);
155 }
156 }
157
158 $col->{ $name } = $value;
159 }
160960µs}
161
162# Given a config and pre-canonicalized importer args, remove collections from
163# the args and return them.
164
# spent 231µs (172+59) within Sub::Exporter::_collect_collections which was called 9 times, avg 26µs/call: # 9 times (172µs+59µs) by Sub::Exporter::__ANON__[/opt/perl-5.18.1/lib/site_perl/5.18.1/Sub/Exporter.pm:337] at line 321, avg 26µs/call
sub _collect_collections {
16595µs my ($config, $import_args, $class, $into) = @_;
166
167 my @collections
168 = map { splice @$import_args, $_, 1 }
169937µs grep { exists $config->{collectors}{ $import_args->[$_][0] } }
170 reverse 0 .. $#$import_args;
171
17294µs unshift @collections, [ INIT => {} ] if $config->{collectors}{INIT};
173
174910µs my $col = {};
175916µs959µs my $builder = _mk_collection_builder($col, \@_);
# spent 59µs making 9 calls to Sub::Exporter::_mk_collection_builder, avg 7µs/call
17697µs for my $collection (@collections) {
177 $builder->($collection)
178 }
179
180984µs return $col;
181}
182
183
184
# spent 672µs (27+645) within Sub::Exporter::setup_exporter which was called 2 times, avg 336µs/call: # once (14µs+330µs) by Moose::Exporter::BEGIN@17 at line 461 # once (13µs+315µs) by Moose::Meta::Class::BEGIN@28 at line 40 of Moose/Util.pm
sub setup_exporter {
18521µs my ($config) = @_;
186
18721µs Carp::croak 'into and into_level may not both be supplied to exporter'
188 if exists $config->{into} and exists $config->{into_level};
189
19022µ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
19623µs2535µs my $import = build_exporter($config);
# spent 535µs making 2 calls to Sub::Exporter::build_exporter, avg 268µs/call
197
198214µs2110µs Sub::Install::reinstall_sub({
# spent 110µs making 2 calls to Sub::Install::__ANON__[Sub/Install.pm:57], avg 55µs/call
199 code => $import,
200 into => $into,
201 as => $as,
202 });
203}
204
205
206
# spent 44µs within Sub::Exporter::_key_intersection which was called 4 times, avg 11µs/call: # 4 times (44µs+0s) by Sub::Exporter::_rewrite_build_config at line 262, avg 11µs/call
sub _key_intersection {
20741µs my ($x, $y) = @_;
208430µs my %seen = map { $_ => 1 } keys %$x;
209417µ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 12µs within Sub::Exporter::BEGIN@217 which was called: # once (12µs+0s) by Moose::Exporter::BEGIN@17 at line 222
BEGIN {
218 %valid_config_key =
219114µs map { $_ => 1 }
220 qw(as collectors installer generator exports groups into into_level),
221 qw(exporter), # deprecated
22211.38ms112µs}
# spent 12µs making 1 call to Sub::Exporter::BEGIN@217
223
224
# spent 25µs (23+2) within Sub::Exporter::_assert_collector_names_ok which was called 4 times, avg 6µs/call: # 4 times (23µs+2µs) by Sub::Exporter::_rewrite_build_config at line 260, avg 6µs/call
sub _assert_collector_names_ok {
22541µs my ($collectors) = @_;
226
227527µ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.64ms (159µs+1.48) within Sub::Exporter::_rewrite_build_config which was called 4 times, avg 410µs/call: # 4 times (159µs+1.48ms) by Sub::Exporter::build_exporter at line 290, avg 410µs/call
sub _rewrite_build_config {
23441µs my ($config) = @_;
235
236416µs if (my @keys = grep { not exists $valid_config_key{$_} } keys %$config) {
237 Carp::croak "unknown options (@keys) passed to Sub::Exporter";
238 }
239
24042µ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.
24442µ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
24941µ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
25244µs for (qw(exports collectors)) {
253840µs81.18ms $config->{$_} = Data::OptList::mkopt_hash(
# spent 1.18ms making 8 calls to Data::OptList::mkopt_hash, avg 148µs/call
254 $config->{$_},
255 $_,
256 [ 'CODE', 'SCALAR' ],
257 );
258 }
259
26048µs425µs _assert_collector_names_ok($config->{collectors});
# spent 25µs making 4 calls to Sub::Exporter::_assert_collector_names_ok, avg 6µs/call
261
262412µs444µs if (my @names = _key_intersection(@$config{qw(exports collectors)})) {
# spent 44µs making 4 calls to Sub::Exporter::_key_intersection, avg 11µs/call
263 Carp::croak "names (@names) used in both collections and exports";
264 }
265
266416µs4233µs $config->{groups} = Data::OptList::mkopt_hash(
# spent 233µs making 4 calls to Data::OptList::mkopt_hash, avg 58µ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
27843µs $config->{groups}{default} ||= [];
279
280 # by default, build an all-inclusive 'all' group
28149µs $config->{groups}{all} ||= [ keys %{ $config->{exports} } ];
282
28343µs $config->{generator} ||= \&default_generator;
284413µs $config->{installer} ||= \&default_installer;
285}
286
287
# spent 1.68ms (42µs+1.64) within Sub::Exporter::build_exporter which was called 4 times, avg 421µs/call: # 2 times (25µs+1.12ms) by Moose::Exporter::_make_exporter at line 139 of Moose/Exporter.pm, avg 575µs/call # 2 times (18µs+518µs) by Sub::Exporter::setup_exporter at line 196, avg 268µs/call
sub build_exporter {
28841µs my ($config) = @_;
289
29045µs41.64ms _rewrite_build_config($config);
# spent 1.64ms making 4 calls to Sub::Exporter::_rewrite_build_config, avg 410µs/call
291
292
# spent 4.26ms (257µs+4.01) within Sub::Exporter::__ANON__[/opt/perl-5.18.1/lib/site_perl/5.18.1/Sub/Exporter.pm:337] which was called 9 times, avg 474µs/call: # 2 times (63µs+3.08ms) by Moose::Exporter::__ANON__[/opt/perl-5.18.1/lib/site_perl/5.18.1/darwin-thread-multi-2level/Moose/Exporter.pm:519] at line 518 of Moose/Exporter.pm, avg 1.57ms/call # once (32µs+209µs) by Moose::Meta::TypeConstraint::DuckType::BEGIN@16 at line 16 of Moose/Meta/TypeConstraint/DuckType.pm # once (23µs+153µs) by Moose::Meta::Role::BEGIN@24 at line 24 of Moose/Meta/Role.pm # once (26µs+139µs) by Moose::Meta::Role::Application::ToClass::BEGIN@14 at line 14 of Moose/Meta/Role/Application/ToClass.pm # once (33µs+120µs) by Moose::Meta::Role::Method::Conflicting::BEGIN@13 at line 13 of Moose/Meta/Role/Method/Conflicting.pm # once (30µs+112µs) by Moose::Exporter::BEGIN@17 at line 17 of Moose/Exporter.pm # once (26µs+105µs) by Moose::Util::BEGIN@15 at line 15 of Moose/Util.pm # once (23µs+88µs) by Moose::Meta::Class::BEGIN@28 at line 28 of Moose/Meta/Class.pm
my $import = sub {
29396µs my ($class) = shift;
294
295 # XXX: clean this up -- rjbs, 2006-03-16
29698µs my $special = (ref $_[0]) ? shift(@_) : {};
29794µ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
30093µ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
305918µ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
31297µs my $generator = delete $special->{generator} || $config->{generator};
31395µs my $installer = delete $special->{installer} || $config->{installer};
314
315 # this builds a AOA, where the inner arrays are [ name => value_ref ]
316920µs9109µs my $import_args = Data::OptList::mkopt([ @_ ]);
# spent 109µs making 9 calls to Data::OptList::mkopt, avg 12µs/call
317
318 # is this right? defaults first or collectors first? -- rjbs, 2006-06-24
319914µs $import_args = [ [ -default => undef ] ] unless @$import_args;
320
321916µs9231µs my $collection = _collect_collections($config, $import_args, $class, $into);
# spent 231µs making 9 calls to Sub::Exporter::_collect_collections, avg 26µs/call
322
323916µs9880µs my $to_import = _expand_groups($class, $config, $import_args, $collection);
# spent 880µs making 9 calls to Sub::Exporter::_expand_groups, avg 98µs/call
324
325 # now, finally $import_arg is really the "to do" list
326988µs92.79ms _do_import(
# spent 2.79ms making 9 calls to Sub::Exporter::_do_import, avg 310µ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 );
337421µs };
338
339414µs return $import;
340}
341
342
# spent 2.79ms (380µs+2.41) within Sub::Exporter::_do_import which was called 9 times, avg 310µs/call: # 9 times (380µs+2.41ms) by Sub::Exporter::__ANON__[/opt/perl-5.18.1/lib/site_perl/5.18.1/Sub/Exporter.pm:337] at line 326, avg 310µs/call
sub _do_import {
34392µs my ($arg, $to_import) = @_;
344
34592µs my @todo;
346
34797µs for my $pair (@$to_import) {
3483411µs my ($name, $import_arg) = @$pair;
349
350341µs my ($generator, $as);
351
352346µs if ($import_arg and Params::Util::_CODELIKE($import_arg)) { ## no critic
353 # This is the case when a group generator has inserted name/code pairs.
354 $generator = sub { $import_arg };
355 $as = $name;
356 } else {
3573411µs $import_arg = { $import_arg ? %$import_arg : () };
358
3593420µs Carp::croak qq("$name" is not exported by the $arg->{class} module)
360 unless exists $arg->{config}{exports}{$name};
361
3623416µs $generator = $arg->{config}{exports}{$name};
363
3643417µs $as = exists $import_arg->{-as} ? (delete $import_arg->{-as}) : $name;
365 }
366
36734112µs34470µs my $code = $arg->{generator}->(
# spent 470µs making 34 calls to Sub::Exporter::default_generator, avg 14µs/call
368 {
369 class => $arg->{class},
370 name => $name,
371 arg => $import_arg,
372 col => $arg->{col},
373 generator => $generator,
374 }
375 );
376
3773445µs push @todo, $as, $code;
378 }
379
380948µs91.13ms $arg->{installer}->(
# spent 906µs making 2 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:137], avg 453µs/call # spent 224µs making 7 calls to Sub::Exporter::default_installer, avg 32µ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 470µs (252+219) within Sub::Exporter::default_generator which was called 34 times, avg 14µs/call: # 34 times (252µs+219µs) by Sub::Exporter::_do_import at line 367, avg 14µs/call
sub default_generator {
407346µs my ($arg) = @_;
4083427µs my ($class, $name, $generator) = @$arg{qw(class name generator)};
409
410345µs if (not defined $generator) {
411323µs36µs my $code = $class->can($name)
# spent 6µs making 3 calls to UNIVERSAL::can, avg 2µs/call
412 or Carp::croak "can't locate exported subroutine $name via $class";
413312µ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
41931186µs62213µs return $generator->($class, $name, $arg->{arg}, $arg->{col})
# spent 164µs making 8 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:379], avg 21µs/call # spent 32µs making 23 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:307], avg 1µs/call # spent 17µs making 31 calls to Params::Util::_CODELIKE, avg 535ns/call
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 1.67ms (262µs+1.40) within Sub::Exporter::default_installer which was called 9 times, avg 185µs/call: # 7 times (47µs+177µs) by Sub::Exporter::_do_import at line 380, avg 32µs/call # once (120µs+688µs) by Sub::Exporter::_do_import at line 110 of Moose/Exporter.pm # once (94µs+540µs) by Moose::Exporter::__ANON__[/opt/perl-5.18.1/lib/site_perl/5.18.1/darwin-thread-multi-2level/Moose/Exporter.pm:137] at line 129 of Moose/Exporter.pm
sub default_installer {
42993µs my ($arg, $to_export) = @_;
430
431979µs for (my $i = 0; $i < @$to_export; $i += 2) {
4323424µ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
4373422µ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 {
4423494µs341.40ms Sub::Install::reinstall_sub({
# spent 1.40ms making 34 calls to Sub::Install::__ANON__[Sub/Install.pm:57], avg 41µ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),
460 _import => sub { build_exporter($_[2]) },
461111µs1344µs ],
# spent 344µ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
468sub _setup {
469 my ($value, $arg) = @_;
470
471 if (ref $value eq 'HASH') {
472 push @{ $arg->{import_args} }, [ _import => { -as => 'import', %$value } ];
473 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
- -
48419µ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