← Index
NYTProf Performance Profile   « line view »
For script/ponapi
  Run on Wed Feb 10 15:51:26 2016
Reported on Thu Feb 11 09:43:09 2016

Filename/usr/local/share/perl/5.18.2/Sub/Exporter.pm
StatementsExecuted 27053 statements in 29.9ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
941118.23ms17.0msSub::Exporter::::default_generatorSub::Exporter::default_generator
118116.17ms76.4msSub::Exporter::::_do_importSub::Exporter::_do_import
258214.52ms16.7msSub::Exporter::::_expand_groupsSub::Exporter::_expand_groups (recurses: max depth 2, inclusive time 15.9ms)
118323.99ms30.8msSub::Exporter::::default_installerSub::Exporter::default_installer
11852482.68ms100msSub::Exporter::::__ANON__[:337]Sub::Exporter::__ANON__[:337]
140112.08ms15.0msSub::Exporter::::_expand_groupSub::Exporter::_expand_group (recurses: max depth 1, inclusive time 11.8ms)
118111.84ms3.34msSub::Exporter::::_collect_collectionsSub::Exporter::_collect_collections
1221211.46ms1.46msSub::Exporter::::_group_nameSub::Exporter::_group_name
11811700µs700µsSub::Exporter::::_mk_collection_builderSub::Exporter::_mk_collection_builder
1111320µs2.30msSub::Exporter::::_rewrite_build_configSub::Exporter::_rewrite_build_config
1011147µs802µsSub::Exporter::::__ANON__[:159]Sub::Exporter::__ANON__[:159]
113285µs2.38msSub::Exporter::::build_exporterSub::Exporter::build_exporter
111179µs79µsSub::Exporter::::_key_intersectionSub::Exporter::_key_intersection
111148µs57µsSub::Exporter::::_assert_collector_names_okSub::Exporter::_assert_collector_names_ok
61134µs34µsSub::Exporter::::_setupSub::Exporter::_setup
22226µs572µsSub::Exporter::::setup_exporterSub::Exporter::setup_exporter
61120µs791µsSub::Exporter::::__ANON__[:460]Sub::Exporter::__ANON__[:460]
11111µs11µsApp::Cmd::::BEGIN@1.2 App::Cmd::BEGIN@1.2
7119µs9µsSub::Exporter::::CORE:matchSub::Exporter::CORE:match (opcode)
1119µs9µsSub::Exporter::::BEGIN@217Sub::Exporter::BEGIN@217
1119µs19µsSub::Exporter::::BEGIN@12Sub::Exporter::BEGIN@12
1118µs15µsSub::Exporter::::BEGIN@11Sub::Exporter::BEGIN@11
1116µs12µsSub::Exporter::::BEGIN@13Sub::Exporter::BEGIN@13
1116µs9µsApp::Cmd::::BEGIN@3 App::Cmd::BEGIN@3
1115µs14µsApp::Cmd::::BEGIN@2.3 App::Cmd::BEGIN@2.3
1113µs3µsSub::Exporter::::BEGIN@10Sub::Exporter::BEGIN@10
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
1240µs111µs
# spent 11µs within App::Cmd::BEGIN@1.2 which was called: # once (11µs+0s) by App::Cmd::BEGIN@15 at line 1
use 5.006;
# spent 11µs making 1 call to App::Cmd::BEGIN@1.2
2217µs223µs
# spent 14µs (5+9) within App::Cmd::BEGIN@2.3 which was called: # once (5µs+9µs) by App::Cmd::BEGIN@15 at line 2
use strict;
# spent 14µs making 1 call to App::Cmd::BEGIN@2.3 # spent 9µs making 1 call to strict::import
3232µs212µs
# spent 9µs (6+3) within App::Cmd::BEGIN@3 which was called: # once (6µs+3µs) by App::Cmd::BEGIN@15 at line 3
use warnings;
# spent 9µs making 1 call to App::Cmd::BEGIN@3 # spent 3µs making 1 call to warnings::import
4package Sub::Exporter;
5{
62900ns $Sub::Exporter::VERSION = '0.987';
7}
8# ABSTRACT: a sophisticated exporter for custom-built routines
9
10219µs13µs
# spent 3µs within Sub::Exporter::BEGIN@10 which was called: # once (3µs+0s) by App::Cmd::BEGIN@15 at line 10
use Carp ();
# spent 3µs making 1 call to Sub::Exporter::BEGIN@10
11331µs221µs
# spent 15µs (8+7) within Sub::Exporter::BEGIN@11 which was called: # once (8µs+7µs) by App::Cmd::BEGIN@15 at line 11
use Data::OptList 0.100 ();
# spent 15µs making 1 call to Sub::Exporter::BEGIN@11 # spent 6µs making 1 call to UNIVERSAL::VERSION
12335µs230µs
# spent 19µs (9+11) within Sub::Exporter::BEGIN@12 which was called: # once (9µs+11µs) by App::Cmd::BEGIN@15 at line 12
use Params::Util 0.14 (); # _CODELIKE
# spent 19µs making 1 call to Sub::Exporter::BEGIN@12 # spent 11µs making 1 call to UNIVERSAL::VERSION
133802µs217µs
# spent 12µs (6+5) within Sub::Exporter::BEGIN@13 which was called: # once (6µs+5µs) by App::Cmd::BEGIN@15 at line 13
use Sub::Install 0.92 ();
# spent 12µs making 1 call to Sub::Exporter::BEGIN@13 # spent 5µ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 1.46ms within Sub::Exporter::_group_name which was called 1221 times, avg 1µs/call: # 1081 times (1.29ms+0s) by Sub::Exporter::_expand_groups at line 36, avg 1µs/call # 140 times (169µs+0s) by Sub::Exporter::_expand_group at line 76, avg 1µs/call
sub _group_name {
191221247µs my ($name) = @_;
20
2112211.75ms return if (index q{-:}, (substr $name, 0, 1)) == -1;
22280535µ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 16.7ms (4.52+12.2) within Sub::Exporter::_expand_groups which was called 258 times, avg 65µs/call: # 140 times (3.15ms+-3.15ms) by Sub::Exporter::_expand_group at line 124, avg 0s/call # 118 times (1.37ms+15.3ms) by Sub::Exporter::__ANON__[/usr/local/share/perl/5.18.2/Sub/Exporter.pm:337] at line 323, avg 142µs/call
sub _expand_groups {
30258122µs my ($class, $config, $groups, $collection, $seen, $merge) = @_;
3125874µs $seen ||= {};
3225848µs $merge ||= {};
33258184µs my @groups = @$groups;
34
35258462µs for my $i (reverse 0 .. $#groups) {
3610811.10ms10811.29ms if (my $group_name = _group_name($groups[$i][0])) {
# spent 1.29ms making 1081 calls to Sub::Exporter::_group_name, avg 1µs/call
37140173µs my $seen = { %$seen }; # faux-dynamic scoping
38
39140394µs14015.0ms splice @groups, $i, 1,
# spent 26.8ms making 140 calls to Sub::Exporter::_expand_group, avg 191µs/call, recursion: max depth 1, sum of overlapping time 11.8ms
40 _expand_group($class, $config, $groups[$i], $collection, $seen, $merge);
41 } else {
42 # there's nothing to munge in this export's args
43941646µ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
67258560µs return \@groups;
68}
69
70# \@group is a name/value pair from an opt list.
71
# spent 15.0ms (2.08+12.9) within Sub::Exporter::_expand_group which was called 140 times, avg 107µs/call: # 140 times (2.08ms+12.9ms) by Sub::Exporter::_expand_groups at line 39, avg 107µs/call
sub _expand_group {
7214059µs my ($class, $config, $group, $collection, $seen, $merge) = @_;
7314023µs $merge ||= {};
74
7514047µs my ($group_name, $group_arg) = @$group;
7614097µs140169µs $group_name = _group_name($group_name);
# spent 169µs making 140 calls to Sub::Exporter::_group_name, avg 1µs/call
77
7814097µs Carp::croak qq(group "$group_name" is not exported by the $class module)
79 unless exists $config->{groups}{$group_name};
80
81140106µs return if $seen->{$group_name}++;
82
8314025µ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
9414084µs my $exports = $config->{groups}{$group_name};
95
96140720µs280221µs if (
# spent 145µs making 140 calls to Params::Util::_CODELIKE, avg 1µs/call # spent 76µs making 140 calls to Params::Util::_SCALAR0, avg 541ns/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 {
120140157µs1408.43ms $exports
# spent 8.43ms making 140 calls to Data::OptList::mkopt, avg 60µs/call
121 = Data::OptList::mkopt($exports, "$group_name exports");
122
123 return @{
124140498µs1400s _expand_groups($class, $config, $exports, $collection, $seen, $merge)
# spent 15.9ms making 140 calls to Sub::Exporter::_expand_groups, avg 113µs/call, recursion: max depth 2, sum of overlapping time 15.9ms
125 };
126 }
127}
128
129
# spent 700µs within Sub::Exporter::_mk_collection_builder which was called 118 times, avg 6µs/call: # 118 times (700µs+0s) by Sub::Exporter::_collect_collections at line 175, avg 6µs/call
sub _mk_collection_builder {
13011843µs my ($col, $etc) = @_;
131118101µs my ($config, $import_args, $class, $into) = @$etc;
132
13311823µs my %seen;
134
# spent 802µs (147+655) within Sub::Exporter::__ANON__[/usr/local/share/perl/5.18.2/Sub/Exporter.pm:159] which was called 10 times, avg 80µs/call: # 10 times (147µs+655µs) by Sub::Exporter::_collect_collections at line 177, avg 80µs/call
sub {
135102µs my ($collection) = @_;
136105µs my ($name, $value) = @$collection;
137
138109µs Carp::croak "collection $name provided multiple times in import"
139 if $seen{ $name }++;
140
1411011µs if (ref(my $hook = $config->{collectors}{$name})) {
1421018µs my $arg = {
143 name => $name,
144 config => $config,
145 import_args => $import_args,
146 class => $class,
147 into => $into,
148 };
149
150109µs my $error_msg = "collection $name failed validation";
1511062µs14621µs if (Params::Util::_SCALAR0($hook)) { ## no critic Private
# spent 400µs making 1 call to App::Cmd::Setup::_make_app_class # spent 206µs making 3 calls to App::Cmd::_setup_command, avg 69µs/call # spent 15µs making 10 calls to Params::Util::_SCALAR0, avg 1µs/call
152 Carp::croak $error_msg unless $class->$$hook($value, $arg);
153 } else {
15467µs634µs Carp::croak $error_msg unless $hook->($value, $arg);
# spent 34µs making 6 calls to Sub::Exporter::_setup, avg 6µs/call
155 }
156 }
157
1581027µs $col->{ $name } = $value;
159 }
160118682µs}
161
162# Given a config and pre-canonicalized importer args, remove collections from
163# the args and return them.
164
# spent 3.34ms (1.84+1.50) within Sub::Exporter::_collect_collections which was called 118 times, avg 28µs/call: # 118 times (1.84ms+1.50ms) by Sub::Exporter::__ANON__[/usr/local/share/perl/5.18.2/Sub/Exporter.pm:337] at line 321, avg 28µs/call
sub _collect_collections {
16511871µs my ($config, $import_args, $class, $into) = @_;
166
167 my @collections
168 = map { splice @$import_args, $_, 1 }
169118434µs grep { exists $config->{collectors}{ $import_args->[$_][0] } }
170 reverse 0 .. $#$import_args;
171
17211868µs unshift @collections, [ INIT => {} ] if $config->{collectors}{INIT};
173
17411842µs my $col = {};
175118196µs118700µs my $builder = _mk_collection_builder($col, \@_);
# spent 700µs making 118 calls to Sub::Exporter::_mk_collection_builder, avg 6µs/call
176118111µs for my $collection (@collections) {
1771016µs10802µs $builder->($collection)
# spent 802µs making 10 calls to Sub::Exporter::__ANON__[Sub/Exporter.pm:159], avg 80µs/call
178 }
179
180118861µs return $col;
181}
182
183
184
# spent 572µs (26+546) within Sub::Exporter::setup_exporter which was called 2 times, avg 286µs/call: # once (12µs+293µs) by Moose::Util::MetaRole::BEGIN@10 at line 36 of Moose/Util.pm # once (14µs+253µs) by App::Cmd::BEGIN@15 at line 461
sub setup_exporter {
1852900ns 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';
19123µ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µs2446µs my $import = build_exporter($config);
# spent 446µs making 2 calls to Sub::Exporter::build_exporter, avg 223µs/call
197
198211µs299µs Sub::Install::reinstall_sub({
# spent 99µs making 2 calls to Sub::Install::__ANON__[Sub/Install.pm:118], avg 50µs/call
199 code => $import,
200 into => $into,
201 as => $as,
202 });
203}
204
205
206
# spent 79µs within Sub::Exporter::_key_intersection which was called 11 times, avg 7µs/call: # 11 times (79µs+0s) by Sub::Exporter::_rewrite_build_config at line 262, avg 7µs/call
sub _key_intersection {
207114µs my ($x, $y) = @_;
2081149µs my %seen = map { $_ => 1 } keys %$x;
2091137µ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 App::Cmd::BEGIN@15 at line 222
BEGIN {
218 %valid_config_key =
21919µs map { $_ => 1 }
220 qw(as collectors installer generator exports groups into into_level),
221 qw(exporter), # deprecated
2221923µs19µs}
# spent 9µs making 1 call to Sub::Exporter::BEGIN@217
223
224
# spent 57µs (48+9) within Sub::Exporter::_assert_collector_names_ok which was called 11 times, avg 5µs/call: # 11 times (48µs+9µs) by Sub::Exporter::_rewrite_build_config at line 260, avg 5µs/call
sub _assert_collector_names_ok {
225114µs my ($collectors) = @_;
226
2271864µs79µs for my $reserved_name (grep { /\A[_A-Z]+\z/ } keys %$collectors) {
# spent 9µs making 7 calls to Sub::Exporter::CORE:match, avg 1µs/call
228 Carp::croak "unknown reserved collector name: $reserved_name"
229 if $reserved_name ne 'INIT';
230 }
231}
232
233
# spent 2.30ms (320µs+1.98) within Sub::Exporter::_rewrite_build_config which was called 11 times, avg 209µs/call: # 11 times (320µs+1.98ms) by Sub::Exporter::build_exporter at line 290, avg 209µs/call
sub _rewrite_build_config {
234113µs my ($config) = @_;
235
2361131µs if (my @keys = grep { not exists $valid_config_key{$_} } keys %$config) {
237 Carp::croak "unknown options (@keys) passed to Sub::Exporter";
238 }
239
240117µ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.
244115µ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
249116µ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
252118µs for (qw(exports collectors)) {
2532272µs221.55ms $config->{$_} = Data::OptList::mkopt_hash(
# spent 1.55ms making 22 calls to Data::OptList::mkopt_hash, avg 71µs/call
254 $config->{$_},
255 $_,
256 [ 'CODE', 'SCALAR' ],
257 );
258 }
259
2601118µs1157µs _assert_collector_names_ok($config->{collectors});
# spent 57µs making 11 calls to Sub::Exporter::_assert_collector_names_ok, avg 5µs/call
261
2621124µs1179µs if (my @names = _key_intersection(@$config{qw(exports collectors)})) {
# spent 79µs making 11 calls to Sub::Exporter::_key_intersection, avg 7µs/call
263 Carp::croak "names (@names) used in both collections and exports";
264 }
265
2661135µs11292µs $config->{groups} = Data::OptList::mkopt_hash(
# spent 292µs making 11 calls to Data::OptList::mkopt_hash, avg 27µ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
2781110µs $config->{groups}{default} ||= [];
279
280 # by default, build an all-inclusive 'all' group
2811120µs $config->{groups}{all} ||= [ keys %{ $config->{exports} } ];
282
2831112µs $config->{generator} ||= \&default_generator;
2841126µs $config->{installer} ||= \&default_installer;
285}
286
287
# spent 2.38ms (85µs+2.30) within Sub::Exporter::build_exporter which was called 11 times, avg 217µs/call: # 6 times (45µs+726µs) by Sub::Exporter::__ANON__[/usr/local/share/perl/5.18.2/Sub/Exporter.pm:460] at line 460, avg 128µs/call # 3 times (27µs+1.14ms) by Moose::Exporter::_make_exporter at line 142 of Moose/Exporter.pm, avg 389µs/call # 2 times (13µs+433µs) by Sub::Exporter::setup_exporter at line 196, avg 223µs/call
sub build_exporter {
288114µs my ($config) = @_;
289
2901112µs112.30ms _rewrite_build_config($config);
# spent 2.30ms making 11 calls to Sub::Exporter::_rewrite_build_config, avg 209µs/call
291
292
# spent 100ms (2.68+97.5) within Sub::Exporter::__ANON__[/usr/local/share/perl/5.18.2/Sub/Exporter.pm:337] which was called 118 times, avg 849µs/call: # 67 times (1.61ms+90.4ms) by Moose::Role::import or Moose::Util::TypeConstraints::import or Moose::import at line 527 of Moose/Exporter.pm, avg 1.37ms/call # once (15µs+455µs) by PONAPI::CLI::BEGIN@5 at line 93 of App/Cmd/Setup.pm # once (31µs+344µs) by HTTP::Headers::ActionPack::Util::BEGIN@17 at line 17 of HTTP/Headers/ActionPack/Util.pm # once (19µs+343µs) by Getopt::Long::Descriptive::BEGIN@268 at line 272 of Getopt/Long/Descriptive.pm # once (26µs+308µs) by Sub::Exporter::Util::BEGIN@198 at line 198 of Sub/Exporter/Util.pm # once (29µs+255µs) by HTTP::Headers::ActionPack::PriorityList::BEGIN@13 at line 13 of HTTP/Headers/ActionPack/PriorityList.pm # once (17µs+250µs) by App::Cmd::BEGIN@15 at line 24 of App/Cmd.pm # once (15µs+251µs) by App::Cmd::Setup::BEGIN@82 at line 82 of App/Cmd/Setup.pm # once (19µs+223µs) by String::RewritePrefix::BEGIN@11 at line 11 of String/RewritePrefix.pm # once (22µs+186µs) by HTTP::Headers::ActionPack::Core::BaseHeaderType::BEGIN@15 at line 15 of HTTP/Headers/ActionPack/Core/BaseHeaderType.pm # once (24µs+162µs) by Moose::Util::TypeConstraints::BEGIN@36 at line 36 of Moose/Util/TypeConstraints.pm # once (26µs+155µs) by PONAPI::CLI::Command::manual::BEGIN@4 at line 4 of lib/PONAPI/CLI/Command/manual.pm # once (27µs+153µs) by Moose::Meta::TypeConstraint::Enum::BEGIN@13 at line 13 of Moose/Meta/TypeConstraint/Enum.pm # once (27µs+145µs) by Moose::Meta::Method::Accessor::BEGIN@12 at line 12 of Moose/Meta/Method/Accessor.pm # once (27µs+140µs) by Moose::Meta::TypeCoercion::BEGIN@11 at line 11 of Moose/Meta/TypeCoercion.pm # once (26µs+136µs) by Moose::Meta::Role::Attribute::BEGIN@12 at line 12 of Moose/Meta/Role/Attribute.pm # once (26µs+135µs) by Moose::Meta::Role::Composite::BEGIN@9 at line 9 of Moose/Meta/Role/Composite.pm # once (24µs+136µs) by Moose::Meta::Method::Overridden::BEGIN@9 at line 9 of Moose/Meta/Method/Overridden.pm # once (25µs+134µs) by Moose::Meta::TypeConstraint::BEGIN@20 at line 20 of Moose/Meta/TypeConstraint.pm # once (18µs+141µs) by PONAPI::CLI::Command::demo::BEGIN@4 at line 4 of lib/PONAPI/CLI/Command/demo.pm # once (24µs+133µs) by HTTP::Headers::ActionPack::Core::BaseHeaderList::BEGIN@14 at line 14 of HTTP/Headers/ActionPack/Core/BaseHeaderList.pm # once (25µs+130µs) by Moose::Meta::Role::Application::BEGIN@11 at line 11 of Moose/Meta/Role/Application.pm # once (38µs+116µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@11 at line 11 of Moose/Meta/TypeConstraint/Parameterized.pm # once (25µs+129µs) by Moose::Meta::TypeConstraint::Parameterizable::BEGIN@12 at line 12 of Moose/Meta/TypeConstraint/Parameterizable.pm # once (24µs+129µs) by Moose::Meta::Role::BEGIN@16 at line 16 of Moose/Meta/Role.pm # once (21µs+130µs) by Moose::Meta::TypeConstraint::Registry::BEGIN@12 at line 12 of Moose/Meta/TypeConstraint/Registry.pm # once (23µs+128µs) by Moose::Meta::TypeConstraint::DuckType::BEGIN@11 at line 11 of Moose/Meta/TypeConstraint/DuckType.pm # once (21µs+122µs) by Moose::Meta::Role::Application::ToClass::BEGIN@9 at line 9 of Moose/Meta/Role/Application/ToClass.pm # once (18µs+116µs) by PONAPI::CLI::Command::gen::BEGIN@4 at line 4 of lib/PONAPI/CLI/Command/gen.pm # once (18µs+110µs) by Moose::Role::BEGIN@14 at line 14 of Moose/Role.pm # once (19µs+106µs) by Moose::Meta::Role::Application::RoleSummation::BEGIN@15 at line 15 of Moose/Meta/Role/Application/RoleSummation.pm # once (25µs+100µs) by Moose::Util::BEGIN@10 at line 10 of Moose/Util.pm # once (18µs+104µs) by Moose::Meta::Role::Application::ToRole::BEGIN@10 at line 10 of Moose/Meta/Role/Application/ToRole.pm # once (15µs+103µs) by Moose::Meta::Method::Delegation::BEGIN@12 at line 12 of Moose/Meta/Method/Delegation.pm # once (27µs+89µs) by Moose::Role::BEGIN@11 at line 11 of Moose/Role.pm # once (15µs+100µs) by Moose::Util::MetaRole::BEGIN@10 at line 10 of Moose/Util/MetaRole.pm # once (22µs+90µs) by Moose::BEGIN@41 at line 41 of Moose.pm # once (22µs+85µs) by Moose::Meta::Role::Method::Conflicting::BEGIN@7 at line 7 of Moose/Meta/Role/Method/Conflicting.pm # once (17µs+89µs) by Moose::Meta::TypeCoercion::Union::BEGIN@12 at line 12 of Moose/Meta/TypeCoercion/Union.pm # once (16µs+86µs) by Moose::Meta::Attribute::BEGIN@15 at line 15 of Moose/Meta/Attribute.pm # once (15µs+86µs) by Moose::Meta::Class::Immutable::Trait::BEGIN@12 at line 12 of Moose/Meta/Class/Immutable/Trait.pm # once (18µs+81µs) by Moose::Meta::Method::Accessor::Native::BEGIN@12 at line 12 of Moose/Meta/Method/Accessor/Native.pm # once (15µs+82µs) by Moose::Meta::Method::Constructor::BEGIN@12 at line 12 of Moose/Meta/Method/Constructor.pm # once (15µs+82µs) by Moose::Meta::Method::Augmented::BEGIN@9 at line 9 of Moose/Meta/Method/Augmented.pm # once (15µs+80µs) by Moose::Meta::Class::BEGIN@19 at line 19 of Moose/Meta/Class.pm # once (18µs+78µs) by PONAPI::Exception::BEGIN@5 at line 5 of lib/PONAPI/Exception.pm # once (17µs+78µs) by Moose::Meta::Attribute::Native::Trait::BEGIN@7 at line 7 of Moose/Meta/Attribute/Native/Trait.pm # once (14µs+79µs) by Moose::Meta::Method::Destructor::BEGIN@14 at line 14 of Moose/Meta/Method/Destructor.pm # once (14µs+78µs) by Moose::Exporter::BEGIN@15 at line 15 of Moose/Exporter.pm # once (16µs+73µs) by main::BEGIN@9 at line 9 of script/ponapi # once (18µs+68µs) by Moose::Meta::Method::Accessor::Native::Writer::BEGIN@8 at line 8 of Moose/Meta/Method/Accessor/Native/Writer.pm # once (16µs+64µs) by Moose::Exporter::BEGIN@12 at line 12 of Moose/Exporter.pm
my $import = sub {
29311879µs my ($class) = shift;
294
295 # XXX: clean this up -- rjbs, 2006-03-16
29611881µs my $special = (ref $_[0]) ? shift(@_) : {};
29711862µ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
30011841µ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
305118253µ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
312118107µs my $generator = delete $special->{generator} || $config->{generator};
31311873µs my $installer = delete $special->{installer} || $config->{installer};
314
315 # this builds a AOA, where the inner arrays are [ name => value_ref ]
316118203µs1181.09ms my $import_args = Data::OptList::mkopt([ @_ ]);
# spent 1.09ms making 118 calls to Data::OptList::mkopt, avg 9µs/call
317
318 # is this right? defaults first or collectors first? -- rjbs, 2006-06-24
319118137µs $import_args = [ [ -default => undef ] ] unless @$import_args;
320
321118215µs1183.34ms my $collection = _collect_collections($config, $import_args, $class, $into);
# spent 3.34ms making 118 calls to Sub::Exporter::_collect_collections, avg 28µs/call
322
323118186µs11816.7ms my $to_import = _expand_groups($class, $config, $import_args, $collection);
# spent 16.7ms making 118 calls to Sub::Exporter::_expand_groups, avg 142µs/call
324
325 # now, finally $import_arg is really the "to do" list
326118942µs11876.4ms _do_import(
# spent 76.4ms making 118 calls to Sub::Exporter::_do_import, avg 647µ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 );
3371145µs };
338
3391128µs return $import;
340}
341
342
# spent 76.4ms (6.17+70.2) within Sub::Exporter::_do_import which was called 118 times, avg 647µs/call: # 118 times (6.17ms+70.2ms) by Sub::Exporter::__ANON__[/usr/local/share/perl/5.18.2/Sub/Exporter.pm:337] at line 326, avg 647µs/call
sub _do_import {
34311847µs my ($arg, $to_import) = @_;
344
34511827µs my @todo;
346
347118101µs for my $pair (@$to_import) {
348941250µs my ($name, $import_arg) = @$pair;
349
35094175µs my ($generator, $as);
351
352941223µs65µs if ($import_arg and Params::Util::_CODELIKE($import_arg)) { ## no critic
# spent 5µs making 6 calls to Params::Util::_CODELIKE, avg 817ns/call
353 # This is the case when a group generator has inserted name/code pairs.
354 $generator = sub { $import_arg };
355 $as = $name;
356 } else {
357941272µs $import_arg = { $import_arg ? %$import_arg : () };
358
359941426µs Carp::croak qq("$name" is not exported by the $arg->{class} module)
360 unless exists $arg->{config}{exports}{$name};
361
362941344µs $generator = $arg->{config}{exports}{$name};
363
364941442µs $as = exists $import_arg->{-as} ? (delete $import_arg->{-as}) : $name;
365 }
366
3679412.02ms94117.0ms my $code = $arg->{generator}->(
# spent 17.0ms making 941 calls to Sub::Exporter::default_generator, avg 18µs/call
368 {
369 class => $arg->{class},
370 name => $name,
371 arg => $import_arg,
372 col => $arg->{col},
373 generator => $generator,
374 }
375 );
376
377941857µs push @todo, $as, $code;
378 }
379
380118512µs11852.3ms $arg->{installer}->(
# spent 50.3ms making 67 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:140], avg 751µs/call # spent 2.01ms making 51 calls to Sub::Exporter::default_installer, avg 39µ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 17.0ms (8.23+8.79) within Sub::Exporter::default_generator which was called 941 times, avg 18µs/call: # 941 times (8.23ms+8.79ms) by Sub::Exporter::_do_import at line 367, avg 18µs/call
sub default_generator {
407941179µs my ($arg) = @_;
408941550µs my ($class, $name, $generator) = @$arg{qw(class name generator)};
409
410941118µs if (not defined $generator) {
41137188µs3768µs my $code = $class->can($name)
# spent 68µs making 37 calls to UNIVERSAL::can, avg 2µs/call
412 or Carp::croak "can't locate exported subroutine $name via $class";
4133790µ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
4199043.76ms18088.73ms return $generator->($class, $name, $arg->{arg}, $arg->{col})
# spent 7.13ms making 504 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:389], avg 14µs/call # spent 791µs making 6 calls to Sub::Exporter::__ANON__[Sub/Exporter.pm:460], avg 132µs/call # spent 423µs making 394 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:317], avg 1µs/call # spent 378µs making 904 calls to Params::Util::_CODELIKE, avg 418ns/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 30.8ms (3.99+26.8) within Sub::Exporter::default_installer which was called 118 times, avg 261µs/call: # 65 times (3.50ms+24.4ms) by Moose::Exporter::__ANON__[/usr/local/lib/perl/5.18.2/Moose/Exporter.pm:140] at line 132 of Moose/Exporter.pm, avg 429µs/call # 51 times (362µs+1.65ms) by Sub::Exporter::_do_import at line 380, avg 39µs/call # 2 times (134µs+753µs) by Sub::Exporter::_do_import at line 113 of Moose/Exporter.pm, avg 443µs/call
sub default_installer {
42911839µs my ($arg, $to_export) = @_;
430
4311181.05ms for (my $i = 0; $i < @$to_export; $i += 2) {
432939419µ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
437939388µ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 {
4429391.61ms93926.8ms Sub::Install::reinstall_sub({
# spent 26.8ms making 939 calls to Sub::Install::__ANON__[Sub/Install.pm:118], avg 29µ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),
460618µs6770µs
# spent 791µs (20+770) within Sub::Exporter::__ANON__[/usr/local/share/perl/5.18.2/Sub/Exporter.pm:460] which was called 6 times, avg 132µs/call: # 6 times (20µs+770µs) by Sub::Exporter::default_generator at line 419, avg 132µs/call
_import => sub { build_exporter($_[2]) },
# spent 770µs making 6 calls to Sub::Exporter::build_exporter, avg 128µs/call
46118µs1268µs ],
# spent 268µ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 34µs within Sub::Exporter::_setup which was called 6 times, avg 6µs/call: # 6 times (34µs+0s) by Sub::Exporter::__ANON__[/usr/local/share/perl/5.18.2/Sub/Exporter.pm:159] at line 154, avg 6µs/call
sub _setup {
46962µs my ($value, $arg) = @_;
470
47164µs if (ref $value eq 'HASH') {
472620µs push @{ $arg->{import_args} }, [ _import => { -as => 'import', %$value } ];
473617µ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
- -
48415µs"jn8:32"; # <-- magic true value
485
486__END__
 
# spent 9µs within Sub::Exporter::CORE:match which was called 7 times, avg 1µs/call: # 7 times (9µs+0s) by Sub::Exporter::_assert_collector_names_ok at line 227, avg 1µs/call
sub Sub::Exporter::CORE:match; # opcode