← Index
NYTProf Performance Profile   « block view • line view • sub view »
For bin/pan_genome_post_analysis
  Run on Fri Mar 27 11:43:32 2015
Reported on Fri Mar 27 11:45:34 2015

Filename/Users/ap13/perl5/lib/perl5/Sub/Exporter.pm
StatementsExecuted 9836 statements in 22.6ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
314117.00ms10.2msSub::Exporter::::default_generatorSub::Exporter::default_generator
58113.27ms30.8msSub::Exporter::::_do_importSub::Exporter::_do_import
108212.32ms6.48msSub::Exporter::::_expand_groupsSub::Exporter::_expand_groups (recurses: max depth 2, inclusive time 5.59ms)
58322.20ms13.2msSub::Exporter::::default_installerSub::Exporter::default_installer
5837331.73ms41.3msSub::Exporter::::__ANON__[:337]Sub::Exporter::__ANON__[:337]
58111.16ms1.62msSub::Exporter::::_collect_collectionsSub::Exporter::_collect_collections
5011974µs5.31msSub::Exporter::::_expand_groupSub::Exporter::_expand_group (recurses: max depth 1, inclusive time 3.71ms)
41421825µs825µsSub::Exporter::::_group_nameSub::Exporter::_group_name
5811433µs433µsSub::Exporter::::_mk_collection_builderSub::Exporter::_mk_collection_builder
611246µs2.21msSub::Exporter::::_rewrite_build_configSub::Exporter::_rewrite_build_config
61171µs71µsSub::Exporter::::_key_intersectionSub::Exporter::_key_intersection
63265µs2.28msSub::Exporter::::build_exporterSub::Exporter::build_exporter
22243µs968µsSub::Exporter::::setup_exporterSub::Exporter::setup_exporter
61132µs39µsSub::Exporter::::_assert_collector_names_okSub::Exporter::_assert_collector_names_ok
11130µs30µsEval::Closure::::BEGIN@1Eval::Closure::BEGIN@1
11127µs27µsSub::Exporter::::BEGIN@217Sub::Exporter::BEGIN@217
11121µs35µsSub::Exporter::::BEGIN@11Sub::Exporter::BEGIN@11
11120µs40µsSub::Exporter::::BEGIN@12Sub::Exporter::BEGIN@12
11120µs27µsSub::Exporter::::__ANON__[:159]Sub::Exporter::__ANON__[:159]
11116µs34µsSub::Exporter::::BEGIN@13Sub::Exporter::BEGIN@13
11112µs18µsEval::Closure::::BEGIN@3Eval::Closure::BEGIN@3
11112µs30µsEval::Closure::::BEGIN@2Eval::Closure::BEGIN@2
1117µs7µsSub::Exporter::::CORE:matchSub::Exporter::CORE:match (opcode)
1116µs6µsSub::Exporter::::_setupSub::Exporter::_setup
1116µs6µsSub::Exporter::::BEGIN@10Sub::Exporter::BEGIN@10
1114µs112µsSub::Exporter::::__ANON__[:460]Sub::Exporter::__ANON__[:460]
0000s0sSub::Exporter::::__ANON__[:354]Sub::Exporter::__ANON__[:354]
0000s0sSub::Exporter::::default_exporterSub::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
1286µs130µs
# spent 30µs within Eval::Closure::BEGIN@1 which was called: # once (30µs+0s) by Eval::Closure::BEGIN@7 at line 1
use 5.006;
# spent 30µs making 1 call to Eval::Closure::BEGIN@1
2237µs249µs
# spent 30µs (12+19) within Eval::Closure::BEGIN@2 which was called: # once (12µs+19µs) by Eval::Closure::BEGIN@7 at line 2
use strict;
# spent 30µs making 1 call to Eval::Closure::BEGIN@2 # spent 19µs making 1 call to strict::import
3264µs224µs
# spent 18µs (12+6) within Eval::Closure::BEGIN@3 which was called: # once (12µs+6µs) by Eval::Closure::BEGIN@7 at line 3
use warnings;
# spent 18µs making 1 call to Eval::Closure::BEGIN@3 # spent 6µs making 1 call to warnings::import
4package Sub::Exporter;
5{
622µs $Sub::Exporter::VERSION = '0.984';
7}
8# ABSTRACT: a sophisticated exporter for custom-built routines
9
10244µs16µs
# spent 6µs within Sub::Exporter::BEGIN@10 which was called: # once (6µs+0s) by Eval::Closure::BEGIN@7 at line 10
use Carp ();
# spent 6µs making 1 call to Sub::Exporter::BEGIN@10
11369µs249µs
# spent 35µs (21+14) within Sub::Exporter::BEGIN@11 which was called: # once (21µs+14µs) by Eval::Closure::BEGIN@7 at line 11
use Data::OptList 0.100 ();
# spent 35µs making 1 call to Sub::Exporter::BEGIN@11 # spent 14µs making 1 call to UNIVERSAL::VERSION
12374µs260µs
# spent 40µs (20+20) within Sub::Exporter::BEGIN@12 which was called: # once (20µs+20µs) by Eval::Closure::BEGIN@7 at line 12
use Params::Util 0.14 (); # _CODELIKE
# spent 40µs making 1 call to Sub::Exporter::BEGIN@12 # spent 20µs making 1 call to UNIVERSAL::VERSION
1331.66ms252µs
# spent 34µs (16+18) within Sub::Exporter::BEGIN@13 which was called: # once (16µs+18µs) by Eval::Closure::BEGIN@7 at line 13
use Sub::Install 0.92 ();
# spent 34µs making 1 call to Sub::Exporter::BEGIN@13 # spent 18µ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 825µs within Sub::Exporter::_group_name which was called 414 times, avg 2µs/call: # 364 times (743µs+0s) by Sub::Exporter::_expand_groups at line 36, avg 2µs/call # 50 times (82µs+0s) by Sub::Exporter::_expand_group at line 76, avg 2µs/call
sub _group_name {
199281.11ms my ($name) = @_;
20
21 return if (index q{-:}, (substr $name, 0, 1)) == -1;
22 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 6.48ms (2.32+4.17) within Sub::Exporter::_expand_groups which was called 108 times, avg 60µs/call: # 58 times (930µs+5.55ms) by Sub::Exporter::__ANON__[/Users/ap13/perl5/lib/perl5/Sub/Exporter.pm:337] at line 323, avg 112µs/call # 50 times (1.38ms+-1.38ms) by Sub::Exporter::_expand_group at line 124, avg 0s/call
sub _expand_groups {
30648695µs my ($class, $config, $groups, $collection, $seen, $merge) = @_;
31 $seen ||= {};
32 $merge ||= {};
33 my @groups = @$groups;
34
35 for my $i (reverse 0 .. $#groups) {
367781.13ms364743µs if (my $group_name = _group_name($groups[$i][0])) {
# spent 743µs making 364 calls to Sub::Exporter::_group_name, avg 2µs/call
37 my $seen = { %$seen }; # faux-dynamic scoping
38
39505.31ms splice @groups, $i, 1,
# spent 9.02ms making 50 calls to Sub::Exporter::_expand_group, avg 180µs/call, recursion: max depth 1, sum of overlapping time 3.71ms
40 _expand_group($class, $config, $groups[$i], $collection, $seen, $merge);
41 } else {
42 # there's nothing to munge in this export's args
43 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
67 return \@groups;
68}
69
70# \@group is a name/value pair from an opt list.
71
# spent 5.31ms (974µs+4.33) within Sub::Exporter::_expand_group which was called 50 times, avg 106µs/call: # 50 times (974µs+4.33ms) by Sub::Exporter::_expand_groups at line 39, avg 106µs/call
sub _expand_group {
72450561µs my ($class, $config, $group, $collection, $seen, $merge) = @_;
73 $merge ||= {};
74
75 my ($group_name, $group_arg) = @$group;
765082µs $group_name = _group_name($group_name);
# spent 82µs making 50 calls to Sub::Exporter::_group_name, avg 2µs/call
77
78 Carp::croak qq(group "$group_name" is not exported by the $class module)
79 unless exists $config->{groups}{$group_name};
80
81 return if $seen->{$group_name}++;
82
83 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
94 my $exports = $config->{groups}{$group_name};
95
96100338µs100108µs if (
# spent 66µs making 50 calls to Params::Util::_CODELIKE, avg 1µs/call # spent 42µs making 50 calls to Params::Util::_SCALAR0, avg 836ns/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 {
120502.26ms $exports
# spent 2.26ms making 50 calls to Data::OptList::mkopt, avg 45µs/call
121 = Data::OptList::mkopt($exports, "$group_name exports");
122
123 return @{
124500s _expand_groups($class, $config, $exports, $collection, $seen, $merge)
# spent 5.59ms making 50 calls to Sub::Exporter::_expand_groups, avg 112µs/call, recursion: max depth 2, sum of overlapping time 5.59ms
125 };
126 }
127}
128
129
# spent 433µs within Sub::Exporter::_mk_collection_builder which was called 58 times, avg 7µs/call: # 58 times (433µs+0s) by Sub::Exporter::_collect_collections at line 175, avg 7µs/call
sub _mk_collection_builder {
130232476µs my ($col, $etc) = @_;
131 my ($config, $import_args, $class, $into) = @$etc;
132
133 my %seen;
134
# spent 27µs (20+7) within Sub::Exporter::__ANON__[/Users/ap13/perl5/lib/perl5/Sub/Exporter.pm:159] which was called: # once (20µs+7µs) by Sub::Exporter::_collect_collections at line 177
sub {
13556µs my ($collection) = @_;
136 my ($name, $value) = @$collection;
137
138 Carp::croak "collection $name provided multiple times in import"
139 if $seen{ $name }++;
140
141311µs 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";
15111µs11µs if (Params::Util::_SCALAR0($hook)) { ## no critic Private
# spent 1µs making 1 call to Params::Util::_SCALAR0
152 Carp::croak $error_msg unless $class->$$hook($value, $arg);
153 } else {
15416µs Carp::croak $error_msg unless $hook->($value, $arg);
# spent 6µs making 1 call to Sub::Exporter::_setup
155 }
156 }
157
158 $col->{ $name } = $value;
159 }
160}
161
162# Given a config and pre-canonicalized importer args, remove collections from
163# the args and return them.
164
# spent 1.62ms (1.16+459µs) within Sub::Exporter::_collect_collections which was called 58 times, avg 28µs/call: # 58 times (1.16ms+459µs) by Sub::Exporter::__ANON__[/Users/ap13/perl5/lib/perl5/Sub/Exporter.pm:337] at line 321, avg 28µs/call
sub _collect_collections {
1654061.13ms my ($config, $import_args, $class, $into) = @_;
166
167 my @collections
168 = map { splice @$import_args, $_, 1 }
169 grep { exists $config->{collectors}{ $import_args->[$_][0] } }
170 reverse 0 .. $#$import_args;
171
172 unshift @collections, [ INIT => {} ] if $config->{collectors}{INIT};
173
174 my $col = {};
17558433µs my $builder = _mk_collection_builder($col, \@_);
# spent 433µs making 58 calls to Sub::Exporter::_mk_collection_builder, avg 7µs/call
176 for my $collection (@collections) {
17712µs127µs $builder->($collection)
# spent 27µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:159]
178 }
179
180 return $col;
181}
182
183
184
# spent 968µs (43+924) within Sub::Exporter::setup_exporter which was called 2 times, avg 484µs/call: # once (27µs+572µs) by Moose::Util::MetaRole::BEGIN@10 at line 36 of Moose/Util.pm # once (16µs+352µs) by Eval::Closure::BEGIN@7 at line 461
sub setup_exporter {
1851238µs my ($config) = @_;
186
187 Carp::croak 'into and into_level may not both be supplied to exporter'
188 if exists $config->{into} and exists $config->{into_level};
189
190 my $as = delete $config->{as} || 'import';
191 my $into
192 = exists $config->{into} ? delete $config->{into}
193 : exists $config->{into_level} ? caller(delete $config->{into_level})
194 : caller(0);
195
1962773µs my $import = build_exporter($config);
# spent 773µs making 2 calls to Sub::Exporter::build_exporter, avg 387µs/call
197
1982151µs Sub::Install::reinstall_sub({
# spent 151µs making 2 calls to Sub::Install::__ANON__[Sub/Install.pm:132], avg 76µs/call
199 code => $import,
200 into => $into,
201 as => $as,
202 });
203}
204
205
206
# spent 71µs within Sub::Exporter::_key_intersection which was called 6 times, avg 12µs/call: # 6 times (71µs+0s) by Sub::Exporter::_rewrite_build_config at line 262, avg 12µs/call
sub _key_intersection {
2071875µs my ($x, $y) = @_;
208 my %seen = map { $_ => 1 } keys %$x;
209 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 27µs within Sub::Exporter::BEGIN@217 which was called: # once (27µs+0s) by Eval::Closure::BEGIN@7 at line 222
BEGIN {
218 %valid_config_key =
219130µs map { $_ => 1 }
220 qw(as collectors installer generator exports groups into into_level),
221 qw(exporter), # deprecated
22211.60ms127µs}
# spent 27µs making 1 call to Sub::Exporter::BEGIN@217
223
224
# spent 39µs (32+7) within Sub::Exporter::_assert_collector_names_ok which was called 6 times, avg 6µs/call: # 6 times (32µs+7µs) by Sub::Exporter::_rewrite_build_config at line 260, avg 6µs/call
sub _assert_collector_names_ok {
2251231µs my ($collectors) = @_;
226
227112µs17µs for my $reserved_name (grep { /\A[_A-Z]+\z/ } keys %$collectors) {
# spent 7µ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 2.21ms (246µs+1.97) within Sub::Exporter::_rewrite_build_config which was called 6 times, avg 369µs/call: # 6 times (246µs+1.97ms) by Sub::Exporter::build_exporter at line 290, avg 369µs/call
sub _rewrite_build_config {
23478148µs my ($config) = @_;
235
236 if (my @keys = grep { not exists $valid_config_key{$_} } keys %$config) {
237 Carp::croak "unknown options (@keys) passed to Sub::Exporter";
238 }
239
240 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.
244 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
249 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
252 for (qw(exports collectors)) {
2531260µs121.52ms $config->{$_} = Data::OptList::mkopt_hash(
# spent 1.52ms making 12 calls to Data::OptList::mkopt_hash, avg 126µs/call
254 $config->{$_},
255 $_,
256 [ 'CODE', 'SCALAR' ],
257 );
258 }
259
260639µs _assert_collector_names_ok($config->{collectors});
# spent 39µs making 6 calls to Sub::Exporter::_assert_collector_names_ok, avg 6µs/call
261
262671µs if (my @names = _key_intersection(@$config{qw(exports collectors)})) {
# spent 71µs making 6 calls to Sub::Exporter::_key_intersection, avg 12µs/call
263 Carp::croak "names (@names) used in both collections and exports";
264 }
265
2666340µs $config->{groups} = Data::OptList::mkopt_hash(
# spent 340µs making 6 calls to Data::OptList::mkopt_hash, avg 57µ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
278 $config->{groups}{default} ||= [];
279
280 # by default, build an all-inclusive 'all' group
281 $config->{groups}{all} ||= [ keys %{ $config->{exports} } ];
282
283 $config->{generator} ||= \&default_generator;
284 $config->{installer} ||= \&default_installer;
285}
286
287
# spent 2.28ms (65µs+2.21) within Sub::Exporter::build_exporter which was called 6 times, avg 380µs/call: # 3 times (37µs+1.36ms) by Moose::Exporter::_make_exporter at line 142 of Moose/Exporter.pm, avg 466µs/call # 2 times (23µs+750µs) by Sub::Exporter::setup_exporter at line 196, avg 387µs/call # once (6µs+102µs) by Sub::Exporter::__ANON__[/Users/ap13/perl5/lib/perl5/Sub/Exporter.pm:460] at line 460
sub build_exporter {
2882462µs my ($config) = @_;
289
29062.21ms _rewrite_build_config($config);
# spent 2.21ms making 6 calls to Sub::Exporter::_rewrite_build_config, avg 369µs/call
291
292
# spent 41.3ms (1.73+39.6) within Sub::Exporter::__ANON__[/Users/ap13/perl5/lib/perl5/Sub/Exporter.pm:337] which was called 58 times, avg 713µs/call: # 22 times (696µs+33.6ms) by Moose::Role::import or Moose::Util::TypeConstraints::import or Moose::import at line 527 of Moose/Exporter.pm, avg 1.56ms/call # once (36µs+284µs) by Class::MOP::Method::Generated::BEGIN@7 at line 7 of Class/MOP/Method/Generated.pm # once (24µs+291µs) by Eval::Closure::BEGIN@7 at line 10 of Eval/Closure.pm # once (47µs+262µs) by Moose::Meta::Method::Overridden::BEGIN@9 at line 9 of Moose/Meta/Method/Overridden.pm # once (32µs+240µs) by Moose::Meta::TypeConstraint::BEGIN@13 at line 13 of Moose/Meta/TypeConstraint.pm # once (40µs+231µs) by Moose::Util::MetaRole::BEGIN@10 at line 10 of Moose/Util/MetaRole.pm # once (35µs+223µs) by Moose::Exporter::BEGIN@15 at line 15 of Moose/Exporter.pm # once (35µs+204µs) by Moose::Meta::Method::Augmented::BEGIN@9 at line 9 of Moose/Meta/Method/Augmented.pm # once (48µs+188µs) by Moose::Util::BEGIN@10 at line 10 of Moose/Util.pm # once (43µs+189µs) by Moose::Exporter::BEGIN@12 at line 12 of Moose/Exporter.pm # once (32µs+198µs) by Moose::Meta::Role::Composite::BEGIN@9 at line 9 of Moose/Meta/Role/Composite.pm # once (29µs+182µs) by Moose::Meta::Role::Application::BEGIN@11 at line 11 of Moose/Meta/Role/Application.pm # once (31µs+171µs) by Moose::Meta::Class::Immutable::Trait::BEGIN@12 at line 12 of Moose/Meta/Class/Immutable/Trait.pm # once (31µs+170µs) by Moose::Meta::Method::Destructor::BEGIN@14 at line 14 of Moose/Meta/Method/Destructor.pm # once (30µs+169µs) by Moose::Meta::TypeCoercion::BEGIN@11 at line 11 of Moose/Meta/TypeCoercion.pm # once (34µs+165µs) by Moose::Meta::Method::Constructor::BEGIN@12 at line 12 of Moose/Meta/Method/Constructor.pm # once (30µs+166µs) by Moose::Meta::Method::Accessor::BEGIN@12 at line 12 of Moose/Meta/Method/Accessor.pm # once (29µs+164µs) by Moose::Meta::Role::Attribute::BEGIN@12 at line 12 of Moose/Meta/Role/Attribute.pm # once (26µs+152µs) by Moose::Meta::TypeConstraint::Parameterizable::BEGIN@12 at line 12 of Moose/Meta/TypeConstraint/Parameterizable.pm # once (25µs+152µs) by Moose::Meta::TypeConstraint::Enum::BEGIN@13 at line 13 of Moose/Meta/TypeConstraint/Enum.pm # once (26µs+149µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@11 at line 11 of Moose/Meta/TypeConstraint/Parameterized.pm # once (25µs+149µs) by Moose::Meta::Role::Application::RoleSummation::BEGIN@15 at line 15 of Moose/Meta/Role/Application/RoleSummation.pm # once (23µs+146µs) by Moose::Meta::Role::BEGIN@16 at line 16 of Moose/Meta/Role.pm # once (20µs+147µs) by Moose::Role::BEGIN@14 at line 14 of Moose/Role.pm # once (23µs+139µs) by Moose::Meta::Role::Application::ToRole::BEGIN@10 at line 10 of Moose/Meta/Role/Application/ToRole.pm # once (37µs+125µs) by Moose::Meta::Role::Method::Conflicting::BEGIN@7 at line 7 of Moose/Meta/Role/Method/Conflicting.pm # once (22µs+137µs) by Moose::Meta::TypeCoercion::Union::BEGIN@12 at line 12 of Moose/Meta/TypeCoercion/Union.pm # once (24µs+132µs) by Moose::Meta::TypeConstraint::DuckType::BEGIN@11 at line 11 of Moose/Meta/TypeConstraint/DuckType.pm # once (22µs+129µs) by Moose::Meta::Role::Application::ToClass::BEGIN@9 at line 9 of Moose/Meta/Role/Application/ToClass.pm # once (21µs+125µs) by Moose::Meta::TypeConstraint::Registry::BEGIN@12 at line 12 of Moose/Meta/TypeConstraint/Registry.pm # once (29µs+115µs) by Moose::Role::BEGIN@11 at line 11 of Moose/Role.pm # once (23µs+121µs) by Moose::Meta::TypeConstraint::BEGIN@20 at line 20 of Moose/Meta/TypeConstraint.pm # once (21µs+119µs) by Moose::Meta::Class::BEGIN@19 at line 19 of Moose/Meta/Class.pm # once (19µs+118µs) by Moose::Meta::Attribute::BEGIN@15 at line 15 of Moose/Meta/Attribute.pm # once (21µs+114µs) by Moose::Meta::Method::Delegation::BEGIN@12 at line 12 of Moose/Meta/Method/Delegation.pm # once (19µs+108µs) by Moose::Util::TypeConstraints::BEGIN@36 at line 36 of Moose/Util/TypeConstraints.pm # once (20µs+101µs) by Moose::BEGIN@41 at line 41 of Moose.pm
my $import = sub {
2936961.51ms my ($class) = shift;
294
295 # XXX: clean this up -- rjbs, 2006-03-16
296 my $special = (ref $_[0]) ? shift(@_) : {};
297 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
300 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
305 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
312 my $generator = delete $special->{generator} || $config->{generator};
313 my $installer = delete $special->{installer} || $config->{installer};
314
315 # this builds a AOA, where the inner arrays are [ name => value_ref ]
31658746µs my $import_args = Data::OptList::mkopt([ @_ ]);
# spent 746µs making 58 calls to Data::OptList::mkopt, avg 13µs/call
317
318 # is this right? defaults first or collectors first? -- rjbs, 2006-06-24
319 $import_args = [ [ -default => undef ] ] unless @$import_args;
320
321581.62ms my $collection = _collect_collections($config, $import_args, $class, $into);
# spent 1.62ms making 58 calls to Sub::Exporter::_collect_collections, avg 28µs/call
322
323586.48ms my $to_import = _expand_groups($class, $config, $import_args, $collection);
# spent 6.48ms making 58 calls to Sub::Exporter::_expand_groups, avg 112µs/call
324
325 # now, finally $import_arg is really the "to do" list
3265830.8ms _do_import(
# spent 30.8ms making 58 calls to Sub::Exporter::_do_import, avg 531µ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 );
337 };
338
339 return $import;
340}
341
342
# spent 30.8ms (3.27+27.5) within Sub::Exporter::_do_import which was called 58 times, avg 531µs/call: # 58 times (3.27ms+27.5ms) by Sub::Exporter::__ANON__[/Users/ap13/perl5/lib/perl5/Sub/Exporter.pm:337] at line 326, avg 531µs/call
sub _do_import {
343232435µs my ($arg, $to_import) = @_;
344
345 my @todo;
346
347 for my $pair (@$to_import) {
34815701.65ms my ($name, $import_arg) = @$pair;
349
350 my ($generator, $as);
351
3521256599µs1700ns if ($import_arg and Params::Util::_CODELIKE($import_arg)) { ## no critic
# spent 700ns 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 {
357 $import_arg = { $import_arg ? %$import_arg : () };
358
359 Carp::croak qq("$name" is not exported by the $arg->{class} module)
360 unless exists $arg->{config}{exports}{$name};
361
362 $generator = $arg->{config}{exports}{$name};
363
364 $as = exists $import_arg->{-as} ? (delete $import_arg->{-as}) : $name;
365 }
366
36731410.2ms my $code = $arg->{generator}->(
# spent 10.2ms making 314 calls to Sub::Exporter::default_generator, avg 33µs/call
368 {
369 class => $arg->{class},
370 name => $name,
371 arg => $import_arg,
372 col => $arg->{col},
373 generator => $generator,
374 }
375 );
376
377 push @todo, $as, $code;
378 }
379
3805816.1ms $arg->{installer}->(
# spent 14.0ms making 22 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:140], avg 636µs/call # spent 2.09ms making 36 calls to Sub::Exporter::default_installer, avg 58µ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 10.2ms (7.00+3.20) within Sub::Exporter::default_generator which was called 314 times, avg 33µs/call: # 314 times (7.00ms+3.20ms) by Sub::Exporter::_do_import at line 367, avg 33µs/call
sub default_generator {
40712256.75ms my ($arg) = @_;
408 my ($class, $name, $generator) = @$arg{qw(class name generator)};
409
41062290µs if (not defined $generator) {
4113156µs my $code = $class->can($name)
# spent 56µs making 31 calls to UNIVERSAL::can, avg 2µs/call
412 or Carp::croak "can't locate exported subroutine $name via $class";
413 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
4195663.14ms return $generator->($class, $name, $arg->{arg}, $arg->{col})
# spent 2.73ms making 160 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:389], avg 17µs/call # spent 164µs making 122 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:317], avg 1µs/call # spent 142µs making 283 calls to Params::Util::_CODELIKE, avg 501ns/call # spent 112µ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 13.2ms (2.20+11.0) within Sub::Exporter::default_installer which was called 58 times, avg 227µs/call: # 36 times (415µs+1.67ms) by Sub::Exporter::_do_import at line 380, avg 58µs/call # 20 times (1.58ms+8.28ms) by Moose::Exporter::__ANON__[/Users/ap13/perl5/lib/perl5/darwin-2level/Moose/Exporter.pm:140] at line 132 of Moose/Exporter.pm, avg 493µs/call # 2 times (205µs+1.01ms) by Sub::Exporter::_do_import at line 113 of Moose/Exporter.pm, avg 606µs/call
sub default_installer {
429116573µs my ($arg, $to_export) = @_;
430
431628468µs for (my $i = 0; $i < @$to_export; $i += 2) {
432 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
437314769µ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 {
44231411.0ms Sub::Install::reinstall_sub({
# spent 11.0ms making 314 calls to Sub::Install::__ANON__[Sub/Install.pm:132], avg 35µ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µs1108µs
# spent 112µs (4+108) within Sub::Exporter::__ANON__[/Users/ap13/perl5/lib/perl5/Sub/Exporter.pm:460] which was called: # once (4µs+108µs) by Sub::Exporter::default_generator at line 419
_import => sub { build_exporter($_[2]) },
# spent 108µs making 1 call to Sub::Exporter::build_exporter
461113µs1369µs ],
# spent 369µ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/ap13/perl5/lib/perl5/Sub/Exporter.pm:159] at line 154
sub _setup {
4692800ns my ($value, $arg) = @_;
470
47128µs 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
- -
484112µs"jn8:32"; # <-- magic true value
485
486__END__
 
# spent 7µs within Sub::Exporter::CORE:match which was called: # once (7µs+0s) by Sub::Exporter::_assert_collector_names_ok at line 227
sub Sub::Exporter::CORE:match; # opcode