← Index
NYTProf Performance Profile   « line view »
For /home/ss5/perl5/perlbrew/perls/perl-5.22.0/bin/benchmarkanything-storage
  Run on Mon Jan 29 16:55:34 2018
Reported on Mon Jan 29 16:57:06 2018

Filename/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Sub/Exporter.pm
StatementsExecuted 3991 statements in 6.10ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
525147955µs7.45msSub::Exporter::::__ANON__[:337]Sub::Exporter::__ANON__[:337]
5211832µs4.08msSub::Exporter::::_do_importSub::Exporter::_do_import
5211668µs910µsSub::Exporter::::_collect_collectionsSub::Exporter::_collect_collections
6021520µs931µsSub::Exporter::::_expand_groupsSub::Exporter::_expand_groups (recurses: max depth 2, inclusive time 260µs)
5232424µs2.42msSub::Exporter::::default_installerSub::Exporter::default_installer
8511366µs712µsSub::Exporter::::default_generatorSub::Exporter::default_generator
5211200µs200µsSub::Exporter::::_mk_collection_builderSub::Exporter::_mk_collection_builder
10121171µs171µsSub::Exporter::::_group_nameSub::Exporter::_group_name
611130µs954µsSub::Exporter::::_rewrite_build_configSub::Exporter::_rewrite_build_config
811103µs335µsSub::Exporter::::_expand_groupSub::Exporter::_expand_group (recurses: max depth 1, inclusive time 171µs)
63240µs995µsSub::Exporter::::build_exporterSub::Exporter::build_exporter
61137µs37µsSub::Exporter::::_key_intersectionSub::Exporter::_key_intersection
21128µs42µsSub::Exporter::::__ANON__[:159]Sub::Exporter::__ANON__[:159]
61119µs20µsSub::Exporter::::_assert_collector_names_okSub::Exporter::_assert_collector_names_ok
22216µs349µsSub::Exporter::::setup_exporterSub::Exporter::setup_exporter
11112µs12µsSub::Exporter::::BEGIN@217Sub::Exporter::BEGIN@217
21112µs12µsSub::Exporter::::_setupSub::Exporter::_setup
1119µs9µsMoose::Util::::BEGIN@1 Moose::Util::BEGIN@1
1117µs11µsSub::Exporter::::BEGIN@12Sub::Exporter::BEGIN@12
1117µs13µsSub::Exporter::::BEGIN@11Sub::Exporter::BEGIN@11
2116µs159µsSub::Exporter::::__ANON__[:460]Sub::Exporter::__ANON__[:460]
1115µs6µsMoose::Util::::BEGIN@2 Moose::Util::BEGIN@2
1114µs8µsSub::Exporter::::BEGIN@13Sub::Exporter::BEGIN@13
1114µs7µsMoose::Util::::BEGIN@3 Moose::Util::BEGIN@3
1112µs2µsSub::Exporter::::BEGIN@10Sub::Exporter::BEGIN@10
1111µs1µsSub::Exporter::::CORE:matchSub::Exporter::CORE:match (opcode)
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
1227µs19µs
# spent 9µs within Moose::Util::BEGIN@1 which was called: # once (9µs+0s) by Moose::Util::BEGIN@10 at line 1
use 5.006;
# spent 9µs making 1 call to Moose::Util::BEGIN@1
2212µs27µs
# spent 6µs (5+1) within Moose::Util::BEGIN@2 which was called: # once (5µs+1µs) by Moose::Util::BEGIN@10 at line 2
use strict;
# spent 6µs making 1 call to Moose::Util::BEGIN@2 # spent 1µs making 1 call to strict::import
3227µs29µs
# spent 7µs (4+3) within Moose::Util::BEGIN@3 which was called: # once (4µs+3µs) by Moose::Util::BEGIN@10 at line 3
use warnings;
# spent 7µs making 1 call to Moose::Util::BEGIN@3 # spent 3µs making 1 call to warnings::import
4package Sub::Exporter;
5{
622µs $Sub::Exporter::VERSION = '0.987';
7}
8# ABSTRACT: a sophisticated exporter for custom-built routines
9
10214µs12µs
# spent 2µs within Sub::Exporter::BEGIN@10 which was called: # once (2µs+0s) by Moose::Util::BEGIN@10 at line 10
use Carp ();
# spent 2µs making 1 call to Sub::Exporter::BEGIN@10
11325µs220µs
# spent 13µs (7+7) within Sub::Exporter::BEGIN@11 which was called: # once (7µs+7µs) by Moose::Util::BEGIN@10 at line 11
use Data::OptList 0.100 ();
# spent 13µs making 1 call to Sub::Exporter::BEGIN@11 # spent 7µs making 1 call to UNIVERSAL::VERSION
12320µs215µs
# spent 11µs (7+4) within Sub::Exporter::BEGIN@12 which was called: # once (7µs+4µs) by Moose::Util::BEGIN@10 at line 12
use Params::Util 0.14 (); # _CODELIKE
# spent 11µs making 1 call to Sub::Exporter::BEGIN@12 # spent 4µs making 1 call to UNIVERSAL::VERSION
133660µs211µs
# spent 8µs (4+3) within Sub::Exporter::BEGIN@13 which was called: # once (4µs+3µs) by Moose::Util::BEGIN@10 at line 13
use Sub::Install 0.92 ();
# spent 8µs making 1 call to Sub::Exporter::BEGIN@13 # spent 3µ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 171µs within Sub::Exporter::_group_name which was called 101 times, avg 2µs/call: # 93 times (164µs+0s) by Sub::Exporter::_expand_groups at line 36, avg 2µs/call # 8 times (6µs+0s) by Sub::Exporter::_expand_group at line 76, avg 762ns/call
sub _group_name {
1910120µs my ($name) = @_;
20
21101189µs return if (index q{-:}, (substr $name, 0, 1)) == -1;
221622µ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 931µs (520+411) within Sub::Exporter::_expand_groups which was called 60 times, avg 16µs/call: # 52 times (446µs+484µs) by Sub::Exporter::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Sub/Exporter.pm:337] at line 323, avg 18µs/call # 8 times (73µs+-73µs) by Sub::Exporter::_expand_group at line 124, avg 0s/call
sub _expand_groups {
306032µs my ($class, $config, $groups, $collection, $seen, $merge) = @_;
316018µs $seen ||= {};
326014µs $merge ||= {};
336032µs my @groups = @$groups;
34
356066µs for my $i (reverse 0 .. $#groups) {
369396µs93164µs if (my $group_name = _group_name($groups[$i][0])) {
# spent 164µs making 93 calls to Sub::Exporter::_group_name, avg 2µs/call
3788µs my $seen = { %$seen }; # faux-dynamic scoping
38
39819µs8335µs splice @groups, $i, 1,
# spent 506µs making 8 calls to Sub::Exporter::_expand_group, avg 63µs/call, recursion: max depth 1, sum of overlapping time 171µs
40 _expand_group($class, $config, $groups[$i], $collection, $seen, $merge);
41 } else {
42 # there's nothing to munge in this export's args
438591µ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
6760118µs return \@groups;
68}
69
70# \@group is a name/value pair from an opt list.
71
# spent 335µs (103+232) within Sub::Exporter::_expand_group which was called 8 times, avg 42µs/call: # 8 times (103µs+232µs) by Sub::Exporter::_expand_groups at line 39, avg 42µs/call
sub _expand_group {
7283µs my ($class, $config, $group, $collection, $seen, $merge) = @_;
7382µs $merge ||= {};
74
7583µs my ($group_name, $group_arg) = @$group;
7685µs86µs $group_name = _group_name($group_name);
# spent 6µs making 8 calls to Sub::Exporter::_group_name, avg 762ns/call
77
78 Carp::croak qq(group "$group_name" is not exported by the $class module)
7984µs 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
9484µs my $exports = $config->{groups}{$group_name};
95
96833µs169µs if (
# spent 6µs making 8 calls to Params::Util::_CODELIKE, avg 762ns/call # spent 3µs making 8 calls to Params::Util::_SCALAR0, avg 338ns/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 {
120811µs8129µs $exports
# spent 129µs making 8 calls to Data::OptList::mkopt, avg 16µs/call
121 = Data::OptList::mkopt($exports, "$group_name exports");
122
123 return @{
124828µs80s _expand_groups($class, $config, $exports, $collection, $seen, $merge)
# spent 260µs making 8 calls to Sub::Exporter::_expand_groups, avg 32µs/call, recursion: max depth 2, sum of overlapping time 260µs
125 };
126 }
127}
128
129
# spent 200µs within Sub::Exporter::_mk_collection_builder which was called 52 times, avg 4µs/call: # 52 times (200µs+0s) by Sub::Exporter::_collect_collections at line 175, avg 4µs/call
sub _mk_collection_builder {
1305217µs my ($col, $etc) = @_;
1315236µs my ($config, $import_args, $class, $into) = @$etc;
132
133529µs my %seen;
134
# spent 42µs (28+14) within Sub::Exporter::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Sub/Exporter.pm:159] which was called 2 times, avg 21µs/call: # 2 times (28µs+14µs) by Sub::Exporter::_collect_collections at line 177, avg 21µs/call
sub {
1352800ns my ($collection) = @_;
1362900ns my ($name, $value) = @$collection;
137
138 Carp::croak "collection $name provided multiple times in import"
13923µs if $seen{ $name }++;
140
14122µs if (ref(my $hook = $config->{collectors}{$name})) {
14225µs my $arg = {
143 name => $name,
144 config => $config,
145 import_args => $import_args,
146 class => $class,
147 into => $into,
148 };
149
15022µs my $error_msg = "collection $name failed validation";
15129µs22µs if (Params::Util::_SCALAR0($hook)) { ## no critic Private
# spent 2µs making 2 calls to Params::Util::_SCALAR0, avg 1µs/call
152 Carp::croak $error_msg unless $class->$$hook($value, $arg);
153 } else {
15423µs212µs Carp::croak $error_msg unless $hook->($value, $arg);
# spent 12µs making 2 calls to Sub::Exporter::_setup, avg 6µs/call
155 }
156 }
157
15826µs $col->{ $name } = $value;
159 }
16052176µs}
161
162# Given a config and pre-canonicalized importer args, remove collections from
163# the args and return them.
164
# spent 910µs (668+243) within Sub::Exporter::_collect_collections which was called 52 times, avg 18µs/call: # 52 times (668µs+243µs) by Sub::Exporter::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Sub/Exporter.pm:337] at line 321, avg 18µs/call
sub _collect_collections {
1655227µs my ($config, $import_args, $class, $into) = @_;
166
167 my @collections
168 = map { splice @$import_args, $_, 1 }
16952147µs grep { exists $config->{collectors}{ $import_args->[$_][0] } }
170 reverse 0 .. $#$import_args;
171
1725223µs unshift @collections, [ INIT => {} ] if $config->{collectors}{INIT};
173
1745219µs my $col = {};
1755273µs52200µs my $builder = _mk_collection_builder($col, \@_);
# spent 200µs making 52 calls to Sub::Exporter::_mk_collection_builder, avg 4µs/call
1765242µs for my $collection (@collections) {
17723µs242µs $builder->($collection)
# spent 42µs making 2 calls to Sub::Exporter::__ANON__[Sub/Exporter.pm:159], avg 21µs/call
178 }
179
18052334µs return $col;
181}
182
183
184
# spent 349µs (16+333) within Sub::Exporter::setup_exporter which was called 2 times, avg 175µs/call: # once (9µs+192µs) by Moose::Util::BEGIN@10 at line 461 # once (7µs+141µs) by Moose::Util::MetaRole::BEGIN@10 at line 36 of Moose/Util.pm
sub setup_exporter {
1852800ns my ($config) = @_;
186
187 Carp::croak 'into and into_level may not both be supplied to exporter'
1882900ns if exists $config->{into} and exists $config->{into_level};
189
19021µs 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})
19421µs : caller(0);
195
19622µs2266µs my $import = build_exporter($config);
# spent 266µs making 2 calls to Sub::Exporter::build_exporter, avg 133µs/call
197
19829µs268µs Sub::Install::reinstall_sub({
# spent 68µs making 2 calls to Sub::Install::__ANON__[Sub/Install.pm:118], avg 34µs/call
199 code => $import,
200 into => $into,
201 as => $as,
202 });
203}
204
205
206
# spent 37µs within Sub::Exporter::_key_intersection which was called 6 times, avg 6µs/call: # 6 times (37µs+0s) by Sub::Exporter::_rewrite_build_config at line 262, avg 6µs/call
sub _key_intersection {
20762µs my ($x, $y) = @_;
208624µs my %seen = map { $_ => 1 } keys %$x;
209615µ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.
2161200nsmy %valid_config_key;
217
# spent 12µs within Sub::Exporter::BEGIN@217 which was called: # once (12µs+0s) by Moose::Util::BEGIN@10 at line 222
BEGIN {
218 %valid_config_key =
219113µs map { $_ => 1 }
220 qw(as collectors installer generator exports groups into into_level),
221 qw(exporter), # deprecated
2221724µs112µs}
# spent 12µs making 1 call to Sub::Exporter::BEGIN@217
223
224
# spent 20µs (19+1) within Sub::Exporter::_assert_collector_names_ok which was called 6 times, avg 3µs/call: # 6 times (19µs+1µs) by Sub::Exporter::_rewrite_build_config at line 260, avg 3µs/call
sub _assert_collector_names_ok {
22561µs my ($collectors) = @_;
226
227723µs11µs for my $reserved_name (grep { /\A[_A-Z]+\z/ } keys %$collectors) {
# spent 1µ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 954µs (130+824) within Sub::Exporter::_rewrite_build_config which was called 6 times, avg 159µs/call: # 6 times (130µs+824µs) by Sub::Exporter::build_exporter at line 290, avg 159µ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
240 Carp::croak q(into and into_level may not both be supplied to exporter)
24162µs 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
249 Carp::croak q(into and into_level may not both be supplied to exporter)
25061µs if exists $config->{into} and exists $config->{into_level};
251
25264µs for (qw(exports collectors)) {
253 $config->{$_} = Data::OptList::mkopt_hash(
2541230µs12641µs $config->{$_},
# spent 641µs making 12 calls to Data::OptList::mkopt_hash, avg 53µs/call
255 $_,
256 [ 'CODE', 'SCALAR' ],
257 );
258 }
259
26068µs620µs _assert_collector_names_ok($config->{collectors});
# spent 20µs making 6 calls to Sub::Exporter::_assert_collector_names_ok, avg 3µs/call
261
262612µs637µs if (my @names = _key_intersection(@$config{qw(exports collectors)})) {
# spent 37µs making 6 calls to Sub::Exporter::_key_intersection, avg 6µs/call
263 Carp::croak "names (@names) used in both collections and exports";
264 }
265
266 $config->{groups} = Data::OptList::mkopt_hash(
267 $config->{groups},
268612µs6125µs 'groups',
# spent 125µs making 6 calls to Data::OptList::mkopt_hash, avg 21µs/call
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
28363µs $config->{generator} ||= \&default_generator;
284621µs $config->{installer} ||= \&default_installer;
285}
286
287
# spent 995µs (40+954) within Sub::Exporter::build_exporter which was called 6 times, avg 166µs/call: # 2 times (21µs+556µs) by Moose::Exporter::_make_exporter at line 142 of Moose/Exporter.pm, avg 288µs/call # 2 times (7µs+258µs) by Sub::Exporter::setup_exporter at line 196, avg 133µs/call # 2 times (12µs+140µs) by Sub::Exporter::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Sub/Exporter.pm:460] at line 460, avg 76µs/call
sub build_exporter {
28862µs my ($config) = @_;
289
29067µs6954µs _rewrite_build_config($config);
# spent 954µs making 6 calls to Sub::Exporter::_rewrite_build_config, avg 159µs/call
291
292
# spent 7.45ms (955µs+6.50) within Sub::Exporter::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Sub/Exporter.pm:337] which was called 52 times, avg 143µs/call: # 2 times (39µs+1.24ms) by Moose::Util::TypeConstraints::import or Moose::import at line 527 of Moose/Exporter.pm, avg 641µs/call # once (37µs+277µs) by Search::Elasticsearch::Role::Transport::BEGIN@8 at line 8 of Search/Elasticsearch/Role/Transport.pm # once (23µs+238µs) by String::RewritePrefix::BEGIN@11 at line 11 of String/RewritePrefix.pm # once (39µs+220µs) by Search::Elasticsearch::Role::CxnPool::BEGIN@4 at line 4 of Search/Elasticsearch/Role/CxnPool.pm # once (22µs+231µs) by Search::Elasticsearch::Util::BEGIN@7 at line 7 of Search/Elasticsearch/Util.pm # once (39µs+183µs) by Search::Elasticsearch::CxnPool::Static::BEGIN@6 at line 6 of Search/Elasticsearch/CxnPool/Static.pm # once (23µs+183µs) by Search::Elasticsearch::Role::Cxn::BEGIN@4 at line 4 of Search/Elasticsearch/Role/Cxn.pm # once (30µs+151µs) by Moose::Meta::TypeCoercion::Union::BEGIN@12 at line 12 of Moose/Meta/TypeCoercion/Union.pm # once (21µs+138µs) by Search::Elasticsearch::Client::5_0::Direct::BEGIN@7 at line 7 of Search/Elasticsearch/Client/5_0/Direct.pm # once (23µs+136µs) by Search::Elasticsearch::Transport::BEGIN@8 at line 8 of Search/Elasticsearch/Transport.pm # once (24µs+131µs) by Moose::Meta::Method::Accessor::BEGIN@12 at line 12 of Moose/Meta/Method/Accessor.pm # once (22µs+129µs) by Moose::Meta::TypeConstraint::Parameterizable::BEGIN@12 at line 12 of Moose/Meta/TypeConstraint/Parameterizable.pm # once (22µs+126µs) by Moose::Meta::Role::Attribute::BEGIN@12 at line 12 of Moose/Meta/Role/Attribute.pm # once (15µs+132µs) by Search::Elasticsearch::Role::Client::Direct::BEGIN@5 at line 5 of Search/Elasticsearch/Role/Client/Direct.pm # once (22µs+121µs) by Search::Elasticsearch::Role::Cxn::BEGIN@12 at line 12 of Search/Elasticsearch/Role/Cxn.pm # once (22µs+121µs) by Moose::Meta::TypeConstraint::Enum::BEGIN@13 at line 13 of Moose/Meta/TypeConstraint/Enum.pm # once (23µs+116µs) by Moose::Meta::TypeCoercion::BEGIN@11 at line 11 of Moose/Meta/TypeCoercion.pm # once (23µs+114µs) by Moose::Meta::Role::Composite::BEGIN@9 at line 9 of Moose/Meta/Role/Composite.pm # once (20µs+113µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@11 at line 11 of Moose/Meta/TypeConstraint/Parameterized.pm # once (17µs+115µs) by Search::Elasticsearch::Cxn::Factory::BEGIN@4 at line 4 of Search/Elasticsearch/Cxn/Factory.pm # once (19µs+110µs) by Moose::Meta::Role::Application::BEGIN@11 at line 11 of Moose/Meta/Role/Application.pm # once (18µs+105µs) by Moose::Meta::TypeConstraint::BEGIN@20 at line 20 of Moose/Meta/TypeConstraint.pm # once (18µs+101µs) by Moose::Util::TypeConstraints::BEGIN@36 at line 36 of Moose/Util/TypeConstraints.pm # once (14µs+103µs) by Search::Elasticsearch::Logger::LogAny::BEGIN@5 at line 5 of Search/Elasticsearch/Logger/LogAny.pm # once (20µs+94µs) by Search::Elasticsearch::Role::CxnPool::BEGIN@8 at line 8 of Search/Elasticsearch/Role/CxnPool.pm # once (13µs+99µs) by Search::Elasticsearch::BEGIN@5 at line 5 of Search/Elasticsearch.pm # once (21µs+85µs) by Moose::Meta::Role::Application::ToRole::BEGIN@10 at line 10 of Moose/Meta/Role/Application/ToRole.pm # once (18µs+85µs) by Search::Elasticsearch::Role::Serializer::JSON::BEGIN@6 at line 6 of Search/Elasticsearch/Role/Serializer/JSON.pm # once (15µs+74µs) by Search::Elasticsearch::Role::API::BEGIN@7 at line 7 of Search/Elasticsearch/Role/API.pm # once (12µs+77µs) by Moose::Meta::Role::BEGIN@16 at line 16 of Moose/Meta/Role.pm # once (14µs+74µs) by Moose::Meta::Method::Delegation::BEGIN@12 at line 12 of Moose/Meta/Method/Delegation.pm # once (13µs+70µs) by Moose::Meta::Method::Overridden::BEGIN@9 at line 9 of Moose/Meta/Method/Overridden.pm # once (20µs+63µs) by Moose::Meta::Role::Method::Conflicting::BEGIN@7 at line 7 of Moose/Meta/Role/Method/Conflicting.pm # once (15µs+68µs) by Moose::Meta::TypeConstraint::DuckType::BEGIN@11 at line 11 of Moose/Meta/TypeConstraint/DuckType.pm # once (13µs+68µs) by Moose::Meta::Class::BEGIN@19 at line 19 of Moose/Meta/Class.pm # once (14µs+67µs) by Moose::Meta::Method::Constructor::BEGIN@12 at line 12 of Moose/Meta/Method/Constructor.pm # once (13µs+68µs) by Moose::Meta::TypeConstraint::Registry::BEGIN@12 at line 12 of Moose/Meta/TypeConstraint/Registry.pm # once (14µs+67µs) by Search::Elasticsearch::Role::Logger::BEGIN@7 at line 7 of Search/Elasticsearch/Role/Logger.pm # once (11µs+69µs) by Moose::Util::MetaRole::BEGIN@10 at line 10 of Moose/Util/MetaRole.pm # once (13µs+67µs) by Moose::Meta::Attribute::BEGIN@15 at line 15 of Moose/Meta/Attribute.pm # once (13µs+67µs) by Moose::Meta::Role::Application::RoleSummation::BEGIN@15 at line 15 of Moose/Meta/Role/Application/RoleSummation.pm # once (12µs+66µs) by Moose::Meta::Role::Application::ToClass::BEGIN@9 at line 9 of Moose/Meta/Role/Application/ToClass.pm # once (12µs+65µs) by Moose::Meta::Method::Augmented::BEGIN@9 at line 9 of Moose/Meta/Method/Augmented.pm # once (13µs+63µs) by Search::Elasticsearch::Client::5_0::Role::API::BEGIN@6 at line 6 of Search/Elasticsearch/Client/5_0/Role/API.pm # once (12µs+64µs) by Moose::Meta::Class::Immutable::Trait::BEGIN@12 at line 12 of Moose/Meta/Class/Immutable/Trait.pm # once (12µs+63µs) by Moose::Meta::Method::Destructor::BEGIN@14 at line 14 of Moose/Meta/Method/Destructor.pm # once (16µs+57µs) by CHI::BEGIN@6 at line 6 of CHI.pm # once (15µs+58µs) by Moose::Util::BEGIN@10 at line 10 of Moose/Util.pm # once (11µs+61µs) by Moose::Exporter::BEGIN@15 at line 15 of Moose/Exporter.pm # once (12µs+54µs) by Moose::BEGIN@41 at line 41 of Moose.pm # once (13µs+47µs) by Moose::Exporter::BEGIN@12 at line 12 of Moose/Exporter.pm
my $import = sub {
2935230µs my ($class) = shift;
294
295 # XXX: clean this up -- rjbs, 2006-03-16
2965239µs my $special = (ref $_[0]) ? shift(@_) : {};
297 Carp::croak q(into and into_level may not both be supplied to exporter)
2985221µs if exists $special->{into} and exists $special->{into_level};
299
3005214µ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
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})
3105282µs : caller(0);
311
3125242µs my $generator = delete $special->{generator} || $config->{generator};
3135222µs my $installer = delete $special->{installer} || $config->{installer};
314
315 # this builds a AOA, where the inner arrays are [ name => value_ref ]
31652115µs52577µs my $import_args = Data::OptList::mkopt([ @_ ]);
# spent 577µs making 52 calls to Data::OptList::mkopt, avg 11µs/call
317
318 # is this right? defaults first or collectors first? -- rjbs, 2006-06-24
3195222µs $import_args = [ [ -default => undef ] ] unless @$import_args;
320
3215273µs52910µs my $collection = _collect_collections($config, $import_args, $class, $into);
# spent 910µs making 52 calls to Sub::Exporter::_collect_collections, avg 18µs/call
322
3235270µs52931µs my $to_import = _expand_groups($class, $config, $import_args, $collection);
# spent 931µs making 52 calls to Sub::Exporter::_expand_groups, avg 18µs/call
324
325 # now, finally $import_arg is really the "to do" list
32652324µs524.08ms _do_import(
# spent 4.08ms making 52 calls to Sub::Exporter::_do_import, avg 78µ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 );
337612µs };
338
339611µs return $import;
340}
341
342
# spent 4.08ms (832µs+3.24) within Sub::Exporter::_do_import which was called 52 times, avg 78µs/call: # 52 times (832µs+3.24ms) by Sub::Exporter::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Sub/Exporter.pm:337] at line 326, avg 78µs/call
sub _do_import {
3435216µs my ($arg, $to_import) = @_;
344
3455210µs my @todo;
346
3475235µs for my $pair (@$to_import) {
3488543µs my ($name, $import_arg) = @$pair;
349
350859µs my ($generator, $as);
351
3528533µs22µs if ($import_arg and Params::Util::_CODELIKE($import_arg)) { ## no critic
# spent 2µs making 2 calls to Params::Util::_CODELIKE, avg 900ns/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 {
3578529µs $import_arg = { $import_arg ? %$import_arg : () };
358
359 Carp::croak qq("$name" is not exported by the $arg->{class} module)
3608558µs unless exists $arg->{config}{exports}{$name};
361
3628530µs $generator = $arg->{config}{exports}{$name};
363
3648552µs $as = exists $import_arg->{-as} ? (delete $import_arg->{-as}) : $name;
365 }
366
367 my $code = $arg->{generator}->(
368 {
369 class => $arg->{class},
370 name => $name,
371 arg => $import_arg,
372 col => $arg->{col},
37385222µs85712µs generator => $generator,
# spent 712µs making 85 calls to Sub::Exporter::default_generator, avg 8µs/call
374 }
375 );
376
3778571µs push @todo, $as, $code;
378 }
379
380 $arg->{installer}->(
381 {
382 class => $arg->{class},
383 into => $arg->{into},
384 col => $arg->{col},
385 },
38652176µs522.24ms \@todo,
# spent 1.93ms making 50 calls to Sub::Exporter::default_installer, avg 39µs/call # spent 315µs making 2 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:140], avg 157µs/call
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 712µs (366+346) within Sub::Exporter::default_generator which was called 85 times, avg 8µs/call: # 85 times (366µs+346µs) by Sub::Exporter::_do_import at line 373, avg 8µs/call
sub default_generator {
4078519µs my ($arg) = @_;
4088558µs my ($class, $name, $generator) = @$arg{qw(class name generator)};
409
4108516µs if (not defined $generator) {
41153205µs5382µs my $code = $class->can($name)
# spent 82µs making 53 calls to UNIVERSAL::can, avg 2µs/call
412 or Carp::croak "can't locate exported subroutine $name via $class";
4135399µ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
419 return $generator->($class, $name, $arg->{arg}, $arg->{col})
42032101µs64264µs if Params::Util::_CODELIKE($generator); ## no critic Private
# spent 159µs making 2 calls to Sub::Exporter::__ANON__[Sub/Exporter.pm:460], avg 79µs/call # spent 79µs making 8 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:389], avg 10µs/call # spent 21µs making 22 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:317], avg 955ns/call # spent 6µs making 32 calls to Params::Util::_CODELIKE, avg 188ns/call
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 2.42ms (424µs+1.99) within Sub::Exporter::default_installer which was called 52 times, avg 46µs/call: # 50 times (344µs+1.58ms) by Sub::Exporter::_do_import at line 386, avg 39µs/call # once (46µs+243µs) by Sub::Exporter::_do_import at line 113 of Moose/Exporter.pm # once (33µs+168µs) by Moose::Exporter::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Moose/Exporter.pm:140] at line 132 of Moose/Exporter.pm
sub default_installer {
4295215µs my ($arg, $to_export) = @_;
430
43152163µs for (my $i = 0; $i < @$to_export; $i += 2) {
4328550µ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
4378539µ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 {
442 Sub::Install::reinstall_sub({
443 code => $code,
444 into => $arg->{into},
44585140µs851.99ms as => $as
# spent 1.99ms making 85 calls to Sub::Install::__ANON__[Sub/Install.pm:118], avg 23µs/call
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),
46027µs2152µs
# spent 159µs (6+152) within Sub::Exporter::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Sub/Exporter.pm:460] which was called 2 times, avg 79µs/call: # 2 times (6µs+152µs) by Sub::Exporter::default_generator at line 420, avg 79µs/call
_import => sub { build_exporter($_[2]) },
# spent 152µs making 2 calls to Sub::Exporter::build_exporter, avg 76µs/call
46117µs1201µs ],
# spent 201µ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 12µs within Sub::Exporter::_setup which was called 2 times, avg 6µs/call: # 2 times (12µs+0s) by Sub::Exporter::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Sub/Exporter.pm:159] at line 154, avg 6µs/call
sub _setup {
4692700ns my ($value, $arg) = @_;
470
47121µs if (ref $value eq 'HASH') {
47227µs push @{ $arg->{import_args} }, [ _import => { -as => 'import', %$value } ];
47325µ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 1µs within Sub::Exporter::CORE:match which was called: # once (1µs+0s) by Sub::Exporter::_assert_collector_names_ok at line 227
sub Sub::Exporter::CORE:match; # opcode