Filename | /opt/flows/lib/lib/perl5/Sub/Exporter.pm |
Statements | Executed 1645 statements in 5.35ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 877µs | 5.12ms | BEGIN@11 | Sub::Exporter::
23 | 23 | 19 | 524µs | 4.36ms | __ANON__[:337] | Sub::Exporter::
23 | 1 | 1 | 450µs | 2.55ms | _do_import | Sub::Exporter::
23 | 1 | 1 | 370µs | 561µs | _collect_collections | Sub::Exporter::
23 | 1 | 1 | 284µs | 355µs | _expand_groups | Sub::Exporter::
23 | 1 | 1 | 264µs | 1.54ms | default_installer | Sub::Exporter::
32 | 1 | 1 | 203µs | 556µs | default_generator | Sub::Exporter::
4 | 1 | 1 | 124µs | 480µs | _rewrite_build_config | Sub::Exporter::
23 | 1 | 1 | 123µs | 123µs | _mk_collection_builder | Sub::Exporter::
32 | 1 | 1 | 72µs | 72µs | _group_name | Sub::Exporter::
3 | 1 | 1 | 46µs | 68µs | __ANON__[:159] | Sub::Exporter::
4 | 2 | 1 | 31µs | 511µs | build_exporter | Sub::Exporter::
4 | 1 | 1 | 25µs | 25µs | _key_intersection | Sub::Exporter::
1 | 1 | 1 | 19µs | 19µs | BEGIN@1 | Search::Elasticsearch::Util::
3 | 1 | 1 | 18µs | 18µs | _setup | Sub::Exporter::
4 | 1 | 1 | 17µs | 20µs | _assert_collector_names_ok | Sub::Exporter::
1 | 1 | 1 | 14µs | 14µs | BEGIN@217 | Sub::Exporter::
1 | 1 | 1 | 12µs | 21µs | BEGIN@12 | Sub::Exporter::
3 | 1 | 1 | 12µs | 296µs | __ANON__[:460] | Sub::Exporter::
1 | 1 | 1 | 12µs | 287µs | setup_exporter | Sub::Exporter::
1 | 1 | 1 | 9µs | 17µs | BEGIN@13 | Sub::Exporter::
1 | 1 | 1 | 9µs | 14µs | BEGIN@3.2 | Search::Elasticsearch::Util::
1 | 1 | 1 | 7µs | 21µs | BEGIN@2 | Search::Elasticsearch::Util::
1 | 1 | 1 | 4µs | 4µs | BEGIN@10 | Sub::Exporter::
1 | 1 | 1 | 3µs | 3µs | CORE:match (opcode) | Sub::Exporter::
0 | 0 | 0 | 0s | 0s | __ANON__[:354] | Sub::Exporter::
0 | 0 | 0 | 0s | 0s | _expand_group | Sub::Exporter::
0 | 0 | 0 | 0s | 0s | default_exporter | Sub::Exporter::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | 2 | 51µs | 1 | 19µs | # spent 19µs within Search::Elasticsearch::Util::BEGIN@1 which was called:
# once (19µs+0s) by Search::Elasticsearch::Util::BEGIN@7 at line 1 # spent 19µs making 1 call to Search::Elasticsearch::Util::BEGIN@1 |
2 | 2 | 27µs | 2 | 34µs | # spent 21µs (7+13) within Search::Elasticsearch::Util::BEGIN@2 which was called:
# once (7µs+13µs) by Search::Elasticsearch::Util::BEGIN@7 at line 2 # spent 21µs making 1 call to Search::Elasticsearch::Util::BEGIN@2
# spent 13µs making 1 call to strict::import |
3 | 2 | 46µs | 2 | 18µs | # spent 14µs (9+5) within Search::Elasticsearch::Util::BEGIN@3.2 which was called:
# once (9µs+5µs) by Search::Elasticsearch::Util::BEGIN@7 at line 3 # spent 14µs making 1 call to Search::Elasticsearch::Util::BEGIN@3.2
# spent 5µs making 1 call to warnings::import |
4 | package Sub::Exporter; | ||||
5 | { | ||||
6 | 2 | 1µs | $Sub::Exporter::VERSION = '0.987'; | ||
7 | } | ||||
8 | # ABSTRACT: a sophisticated exporter for custom-built routines | ||||
9 | |||||
10 | 2 | 28µs | 1 | 4µs | # spent 4µs within Sub::Exporter::BEGIN@10 which was called:
# once (4µs+0s) by Search::Elasticsearch::Util::BEGIN@7 at line 10 # spent 4µs making 1 call to Sub::Exporter::BEGIN@10 |
11 | 3 | 127µs | 2 | 5.13ms | # spent 5.12ms (877µs+4.24) within Sub::Exporter::BEGIN@11 which was called:
# once (877µs+4.24ms) by Search::Elasticsearch::Util::BEGIN@7 at line 11 # spent 5.12ms making 1 call to Sub::Exporter::BEGIN@11
# spent 11µs making 1 call to UNIVERSAL::VERSION |
12 | 3 | 44µs | 2 | 30µs | # spent 21µs (12+9) within Sub::Exporter::BEGIN@12 which was called:
# once (12µs+9µs) by Search::Elasticsearch::Util::BEGIN@7 at line 12 # spent 21µs making 1 call to Sub::Exporter::BEGIN@12
# spent 9µs making 1 call to UNIVERSAL::VERSION |
13 | 3 | 1.13ms | 2 | 25µs | # spent 17µs (9+8) within Sub::Exporter::BEGIN@13 which was called:
# once (9µs+8µs) by Search::Elasticsearch::Util::BEGIN@7 at line 13 # spent 17µs making 1 call to Sub::Exporter::BEGIN@13
# spent 8µ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 72µs within Sub::Exporter::_group_name which was called 32 times, avg 2µs/call:
# 32 times (72µs+0s) by Sub::Exporter::_expand_groups at line 36, avg 2µs/call | ||||
19 | 32 | 10µs | my ($name) = @_; | ||
20 | |||||
21 | 32 | 100µs | 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 355µs (284+72) within Sub::Exporter::_expand_groups which was called 23 times, avg 15µs/call:
# 23 times (284µs+72µs) by Sub::Exporter::__ANON__[/opt/flows/lib/lib/perl5/Sub/Exporter.pm:337] at line 323, avg 15µs/call | ||||
30 | 23 | 14µs | my ($class, $config, $groups, $collection, $seen, $merge) = @_; | ||
31 | 23 | 10µs | $seen ||= {}; | ||
32 | 23 | 6µs | $merge ||= {}; | ||
33 | 23 | 16µs | my @groups = @$groups; | ||
34 | |||||
35 | 23 | 46µs | for my $i (reverse 0 .. $#groups) { | ||
36 | 32 | 50µs | 32 | 72µs | if (my $group_name = _group_name($groups[$i][0])) { # spent 72µs making 32 calls to Sub::Exporter::_group_name, avg 2µs/call |
37 | my $seen = { %$seen }; # faux-dynamic scoping | ||||
38 | |||||
39 | splice @groups, $i, 1, | ||||
40 | _expand_group($class, $config, $groups[$i], $collection, $seen, $merge); | ||||
41 | } else { | ||||
42 | # there's nothing to munge in this export's args | ||||
43 | 32 | 55µ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 | |||||
67 | 23 | 72µs | return \@groups; | ||
68 | } | ||||
69 | |||||
70 | # \@group is a name/value pair from an opt list. | ||||
71 | sub _expand_group { | ||||
72 | my ($class, $config, $group, $collection, $seen, $merge) = @_; | ||||
73 | $merge ||= {}; | ||||
74 | |||||
75 | my ($group_name, $group_arg) = @$group; | ||||
76 | $group_name = _group_name($group_name); | ||||
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 | |||||
96 | if ( | ||||
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 { | ||||
120 | $exports | ||||
121 | = Data::OptList::mkopt($exports, "$group_name exports"); | ||||
122 | |||||
123 | return @{ | ||||
124 | _expand_groups($class, $config, $exports, $collection, $seen, $merge) | ||||
125 | }; | ||||
126 | } | ||||
127 | } | ||||
128 | |||||
129 | # spent 123µs within Sub::Exporter::_mk_collection_builder which was called 23 times, avg 5µs/call:
# 23 times (123µs+0s) by Sub::Exporter::_collect_collections at line 175, avg 5µs/call | ||||
130 | 23 | 8µs | my ($col, $etc) = @_; | ||
131 | 23 | 14µs | my ($config, $import_args, $class, $into) = @$etc; | ||
132 | |||||
133 | 23 | 3µs | my %seen; | ||
134 | # spent 68µs (46+22) within Sub::Exporter::__ANON__[/opt/flows/lib/lib/perl5/Sub/Exporter.pm:159] which was called 3 times, avg 23µs/call:
# 3 times (46µs+22µs) by Sub::Exporter::_collect_collections at line 177, avg 23µs/call | ||||
135 | 3 | 800ns | my ($collection) = @_; | ||
136 | 3 | 2µs | my ($name, $value) = @$collection; | ||
137 | |||||
138 | 3 | 3µs | Carp::croak "collection $name provided multiple times in import" | ||
139 | if $seen{ $name }++; | ||||
140 | |||||
141 | 3 | 5µs | if (ref(my $hook = $config->{collectors}{$name})) { | ||
142 | 3 | 6µs | my $arg = { | ||
143 | name => $name, | ||||
144 | config => $config, | ||||
145 | import_args => $import_args, | ||||
146 | class => $class, | ||||
147 | into => $into, | ||||
148 | }; | ||||
149 | |||||
150 | 3 | 3µs | my $error_msg = "collection $name failed validation"; | ||
151 | 3 | 17µs | 3 | 4µs | if (Params::Util::_SCALAR0($hook)) { ## no critic Private # spent 4µs making 3 calls to Params::Util::_SCALAR0, avg 1µs/call |
152 | Carp::croak $error_msg unless $class->$$hook($value, $arg); | ||||
153 | } else { | ||||
154 | 3 | 4µs | 3 | 18µs | Carp::croak $error_msg unless $hook->($value, $arg); # spent 18µs making 3 calls to Sub::Exporter::_setup, avg 6µs/call |
155 | } | ||||
156 | } | ||||
157 | |||||
158 | 3 | 9µs | $col->{ $name } = $value; | ||
159 | } | ||||
160 | 23 | 136µs | } | ||
161 | |||||
162 | # Given a config and pre-canonicalized importer args, remove collections from | ||||
163 | # the args and return them. | ||||
164 | # spent 561µs (370+191) within Sub::Exporter::_collect_collections which was called 23 times, avg 24µs/call:
# 23 times (370µs+191µs) by Sub::Exporter::__ANON__[/opt/flows/lib/lib/perl5/Sub/Exporter.pm:337] at line 321, avg 24µs/call | ||||
165 | 23 | 14µs | my ($config, $import_args, $class, $into) = @_; | ||
166 | |||||
167 | my @collections | ||||
168 | = map { splice @$import_args, $_, 1 } | ||||
169 | 23 | 84µs | grep { exists $config->{collectors}{ $import_args->[$_][0] } } | ||
170 | reverse 0 .. $#$import_args; | ||||
171 | |||||
172 | 23 | 8µs | unshift @collections, [ INIT => {} ] if $config->{collectors}{INIT}; | ||
173 | |||||
174 | 23 | 8µs | my $col = {}; | ||
175 | 23 | 35µs | 23 | 123µs | my $builder = _mk_collection_builder($col, \@_); # spent 123µs making 23 calls to Sub::Exporter::_mk_collection_builder, avg 5µs/call |
176 | 23 | 22µs | for my $collection (@collections) { | ||
177 | 3 | 6µs | 3 | 68µs | $builder->($collection) # spent 68µs making 3 calls to Sub::Exporter::__ANON__[/opt/flows/lib/lib/perl5/Sub/Exporter.pm:159], avg 23µs/call |
178 | } | ||||
179 | |||||
180 | 23 | 183µs | return $col; | ||
181 | } | ||||
182 | |||||
183 | |||||
184 | # spent 287µs (12+275) within Sub::Exporter::setup_exporter which was called:
# once (12µs+275µs) by Search::Elasticsearch::Util::BEGIN@7 at line 461 | ||||
185 | 1 | 600ns | my ($config) = @_; | ||
186 | |||||
187 | 1 | 600ns | 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 | 1 | 700ns | my $as = delete $config->{as} || 'import'; | ||
191 | 1 | 1µs | my $into | ||
192 | = exists $config->{into} ? delete $config->{into} | ||||
193 | : exists $config->{into_level} ? caller(delete $config->{into_level}) | ||||
194 | : caller(0); | ||||
195 | |||||
196 | 1 | 1µs | 1 | 227µs | my $import = build_exporter($config); # spent 227µs making 1 call to Sub::Exporter::build_exporter |
197 | |||||
198 | 1 | 6µs | 1 | 48µs | Sub::Install::reinstall_sub({ # spent 48µs making 1 call to Sub::Install::__ANON__[/opt/flows/lib/lib/perl5/Sub/Install.pm:118] |
199 | code => $import, | ||||
200 | into => $into, | ||||
201 | as => $as, | ||||
202 | }); | ||||
203 | } | ||||
204 | |||||
205 | |||||
206 | # spent 25µs within Sub::Exporter::_key_intersection which was called 4 times, avg 6µs/call:
# 4 times (25µs+0s) by Sub::Exporter::_rewrite_build_config at line 262, avg 6µs/call | ||||
207 | 4 | 2µs | my ($x, $y) = @_; | ||
208 | 4 | 14µs | my %seen = map { $_ => 1 } keys %$x; | ||
209 | 4 | 14µ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. | ||||
216 | 1 | 200ns | my %valid_config_key; | ||
217 | # spent 14µs within Sub::Exporter::BEGIN@217 which was called:
# once (14µs+0s) by Search::Elasticsearch::Util::BEGIN@7 at line 222 | ||||
218 | %valid_config_key = | ||||
219 | 1 | 15µs | map { $_ => 1 } | ||
220 | qw(as collectors installer generator exports groups into into_level), | ||||
221 | qw(exporter), # deprecated | ||||
222 | 1 | 1.27ms | 1 | 14µs | } # spent 14µs making 1 call to Sub::Exporter::BEGIN@217 |
223 | |||||
224 | # spent 20µs (17+3) within Sub::Exporter::_assert_collector_names_ok which was called 4 times, avg 5µs/call:
# 4 times (17µs+3µs) by Sub::Exporter::_rewrite_build_config at line 260, avg 5µs/call | ||||
225 | 4 | 1µs | my ($collectors) = @_; | ||
226 | |||||
227 | 5 | 24µs | 1 | 3µs | for my $reserved_name (grep { /\A[_A-Z]+\z/ } keys %$collectors) { # spent 3µ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 480µs (124+356) within Sub::Exporter::_rewrite_build_config which was called 4 times, avg 120µs/call:
# 4 times (124µs+356µs) by Sub::Exporter::build_exporter at line 290, avg 120µs/call | ||||
234 | 4 | 1µs | my ($config) = @_; | ||
235 | |||||
236 | 4 | 10µ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 | 4 | 2µ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. | ||||
244 | 4 | 1µ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 | 4 | 1µ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 | |||||
252 | 4 | 3µs | for (qw(exports collectors)) { | ||
253 | 8 | 28µs | 8 | 249µs | $config->{$_} = Data::OptList::mkopt_hash( # spent 249µs making 8 calls to Data::OptList::mkopt_hash, avg 31µs/call |
254 | $config->{$_}, | ||||
255 | $_, | ||||
256 | [ 'CODE', 'SCALAR' ], | ||||
257 | ); | ||||
258 | } | ||||
259 | |||||
260 | 4 | 6µs | 4 | 20µs | _assert_collector_names_ok($config->{collectors}); # spent 20µs making 4 calls to Sub::Exporter::_assert_collector_names_ok, avg 5µs/call |
261 | |||||
262 | 4 | 10µs | 4 | 25µs | if (my @names = _key_intersection(@$config{qw(exports collectors)})) { # spent 25µs making 4 calls to Sub::Exporter::_key_intersection, avg 6µs/call |
263 | Carp::croak "names (@names) used in both collections and exports"; | ||||
264 | } | ||||
265 | |||||
266 | 4 | 15µs | 4 | 63µs | $config->{groups} = Data::OptList::mkopt_hash( # spent 63µs making 4 calls to Data::OptList::mkopt_hash, avg 16µ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 | 4 | 4µs | $config->{groups}{default} ||= []; | ||
279 | |||||
280 | # by default, build an all-inclusive 'all' group | ||||
281 | 4 | 6µs | $config->{groups}{all} ||= [ keys %{ $config->{exports} } ]; | ||
282 | |||||
283 | 4 | 3µs | $config->{generator} ||= \&default_generator; | ||
284 | 4 | 12µs | $config->{installer} ||= \&default_installer; | ||
285 | } | ||||
286 | |||||
287 | sub build_exporter { | ||||
288 | 4 | 1µs | my ($config) = @_; | ||
289 | |||||
290 | 4 | 6µs | 4 | 480µs | _rewrite_build_config($config); # spent 480µs making 4 calls to Sub::Exporter::_rewrite_build_config, avg 120µs/call |
291 | |||||
292 | # spent 4.36ms (524µs+3.83) within Sub::Exporter::__ANON__[/opt/flows/lib/lib/perl5/Sub/Exporter.pm:337] which was called 23 times, avg 190µs/call:
# once (24µs+289µs) by Search::Elasticsearch::Util::BEGIN@7 at line 7 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Util.pm
# once (22µs+264µs) by Search::Elasticsearch::Util::API::QS::BEGIN@6 at line 6 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Util/API/QS.pm
# once (21µs+239µs) by Search::Elasticsearch::Role::Client::Direct::Main::BEGIN@6 at line 6 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Client/Direct/Main.pm
# once (36µs+216µs) by Search::Elasticsearch::Role::Serializer::JSON::BEGIN@6 at line 6 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Serializer/JSON.pm
# once (20µs+218µs) by Search::Elasticsearch::Util::API::Path::BEGIN@7 at line 7 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Util/API/Path.pm
# once (24µs+201µs) by Search::Elasticsearch::Bulk::BEGIN@6 at line 6 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Bulk.pm
# once (21µs+190µs) by Search::Elasticsearch::Logger::LogAny::BEGIN@5 at line 5 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Logger/LogAny.pm
# once (29µs+182µs) by Search::Elasticsearch::Cxn::Factory::BEGIN@4 at line 4 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Cxn/Factory.pm
# once (23µs+188µs) by Search::Elasticsearch::BEGIN@5 at line 5 of /opt/flows/lib/lib/perl5/Search/Elasticsearch.pm
# once (21µs+189µs) by Search::Elasticsearch::Role::Bulk::BEGIN@6 at line 6 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Bulk.pm
# once (20µs+184µs) by Search::Elasticsearch::Role::Transport::BEGIN@8 at line 8 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Transport.pm
# once (21µs+182µs) by Search::Elasticsearch::Role::Cxn::HTTP::BEGIN@6 at line 6 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Cxn/HTTP.pm
# once (21µs+125µs) by Search::Elasticsearch::Role::Cxn::BEGIN@8 at line 8 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Cxn.pm
# once (24µs+121µs) by Search::Elasticsearch::Role::Client::Direct::BEGIN@5 at line 5 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Client/Direct.pm
# once (24µs+120µs) by Search::Elasticsearch::Role::API::2_0::BEGIN@6 at line 6 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/API/2_0.pm
# once (22µs+116µs) by Search::Elasticsearch::Util::API::Path::BEGIN@6 at line 6 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Util/API/Path.pm
# once (22µs+116µs) by Search::Elasticsearch::Role::Logger::BEGIN@7 at line 7 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Logger.pm
# once (22µs+116µs) by Search::Elasticsearch::Transport::BEGIN@8 at line 8 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Transport.pm
# once (22µs+116µs) by Search::Elasticsearch::Role::API::2_0::BEGIN@5 at line 5 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/API/2_0.pm
# once (21µs+116µs) by Search::Elasticsearch::Role::Cxn::BEGIN@4 at line 4 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Cxn.pm
# once (21µs+116µs) by Search::Elasticsearch::CxnPool::Static::BEGIN@6 at line 6 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/CxnPool/Static.pm
# once (21µs+115µs) by Search::Elasticsearch::Role::CxnPool::BEGIN@8 at line 8 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/CxnPool.pm
# once (22µs+115µs) by Search::Elasticsearch::Role::CxnPool::BEGIN@4 at line 4 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/CxnPool.pm | ||||
293 | 23 | 18µs | my ($class) = shift; | ||
294 | |||||
295 | # XXX: clean this up -- rjbs, 2006-03-16 | ||||
296 | 23 | 21µs | my $special = (ref $_[0]) ? shift(@_) : {}; | ||
297 | 23 | 13µ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 | |||||
300 | 23 | 8µ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 | 23 | 36µ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 | |||||
312 | 23 | 16µs | my $generator = delete $special->{generator} || $config->{generator}; | ||
313 | 23 | 8µs | my $installer = delete $special->{installer} || $config->{installer}; | ||
314 | |||||
315 | # this builds a AOA, where the inner arrays are [ name => value_ref ] | ||||
316 | 23 | 56µs | 23 | 366µs | my $import_args = Data::OptList::mkopt([ @_ ]); # spent 366µs making 23 calls to Data::OptList::mkopt, avg 16µs/call |
317 | |||||
318 | # is this right? defaults first or collectors first? -- rjbs, 2006-06-24 | ||||
319 | 23 | 5µs | $import_args = [ [ -default => undef ] ] unless @$import_args; | ||
320 | |||||
321 | 23 | 39µs | 23 | 561µs | my $collection = _collect_collections($config, $import_args, $class, $into); # spent 561µs making 23 calls to Sub::Exporter::_collect_collections, avg 24µs/call |
322 | |||||
323 | 23 | 35µs | 23 | 355µs | my $to_import = _expand_groups($class, $config, $import_args, $collection); # spent 355µs making 23 calls to Sub::Exporter::_expand_groups, avg 15µs/call |
324 | |||||
325 | # now, finally $import_arg is really the "to do" list | ||||
326 | 23 | 189µs | 23 | 2.55ms | _do_import( # spent 2.55ms making 23 calls to Sub::Exporter::_do_import, avg 111µ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 | 4 | 15µs | }; | ||
338 | |||||
339 | 4 | 11µs | return $import; | ||
340 | } | ||||
341 | |||||
342 | # spent 2.55ms (450µs+2.10) within Sub::Exporter::_do_import which was called 23 times, avg 111µs/call:
# 23 times (450µs+2.10ms) by Sub::Exporter::__ANON__[/opt/flows/lib/lib/perl5/Sub/Exporter.pm:337] at line 326, avg 111µs/call | ||||
343 | 23 | 7µs | my ($arg, $to_import) = @_; | ||
344 | |||||
345 | 23 | 3µs | my @todo; | ||
346 | |||||
347 | 23 | 16µs | for my $pair (@$to_import) { | ||
348 | 32 | 12µs | my ($name, $import_arg) = @$pair; | ||
349 | |||||
350 | 32 | 4µs | my ($generator, $as); | ||
351 | |||||
352 | 32 | 20µs | 3 | 3µs | if ($import_arg and Params::Util::_CODELIKE($import_arg)) { ## no critic # spent 3µs making 3 calls to Params::Util::_CODELIKE, avg 1µs/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 { | ||||
357 | 32 | 17µs | $import_arg = { $import_arg ? %$import_arg : () }; | ||
358 | |||||
359 | 32 | 23µs | Carp::croak qq("$name" is not exported by the $arg->{class} module) | ||
360 | unless exists $arg->{config}{exports}{$name}; | ||||
361 | |||||
362 | 32 | 18µs | $generator = $arg->{config}{exports}{$name}; | ||
363 | |||||
364 | 32 | 30µs | $as = exists $import_arg->{-as} ? (delete $import_arg->{-as}) : $name; | ||
365 | } | ||||
366 | |||||
367 | 32 | 115µs | 32 | 556µs | my $code = $arg->{generator}->( # spent 556µs making 32 calls to Sub::Exporter::default_generator, avg 17µ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 | 32 | 47µs | push @todo, $as, $code; | ||
378 | } | ||||
379 | |||||
380 | 23 | 108µs | 23 | 1.54ms | $arg->{installer}->( # spent 1.54ms making 23 calls to Sub::Exporter::default_installer, avg 67µ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 556µs (203+353) within Sub::Exporter::default_generator which was called 32 times, avg 17µs/call:
# 32 times (203µs+353µs) by Sub::Exporter::_do_import at line 367, avg 17µs/call | ||||
407 | 32 | 7µs | my ($arg) = @_; | ||
408 | 32 | 33µs | my ($class, $name, $generator) = @$arg{qw(class name generator)}; | ||
409 | |||||
410 | 32 | 9µs | if (not defined $generator) { | ||
411 | 29 | 155µs | 29 | 55µs | my $code = $class->can($name) # spent 55µs making 29 calls to UNIVERSAL::can, avg 2µs/call |
412 | or Carp::croak "can't locate exported subroutine $name via $class"; | ||||
413 | 29 | 58µ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 | 3 | 20µs | 6 | 298µs | return $generator->($class, $name, $arg->{arg}, $arg->{col}) # spent 296µs making 3 calls to Sub::Exporter::__ANON__[/opt/flows/lib/lib/perl5/Sub/Exporter.pm:460], avg 99µs/call
# spent 1µs making 3 calls to Params::Util::_CODELIKE, avg 467ns/call |
420 | if Params::Util::_CODELIKE($generator); ## no critic Private | ||||
421 | |||||
422 | # This "must" be a scalar reference, to a generator method name. | ||||
423 | # -- rjbs, 2006-12-05 | ||||
424 | return $class->$$generator($name, $arg->{arg}, $arg->{col}); | ||||
425 | } | ||||
426 | |||||
427 | |||||
428 | # spent 1.54ms (264µs+1.28) within Sub::Exporter::default_installer which was called 23 times, avg 67µs/call:
# 23 times (264µs+1.28ms) by Sub::Exporter::_do_import at line 380, avg 67µs/call | ||||
429 | 23 | 8µs | my ($arg, $to_export) = @_; | ||
430 | |||||
431 | 23 | 111µs | for (my $i = 0; $i < @$to_export; $i += 2) { | ||
432 | 32 | 26µ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 | |||||
437 | 32 | 21µ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 | 32 | 96µs | 32 | 1.28ms | Sub::Install::reinstall_sub({ # spent 1.28ms making 32 calls to Sub::Install::__ANON__[/opt/flows/lib/lib/perl5/Sub/Install.pm:118], avg 40µs/call |
443 | code => $code, | ||||
444 | into => $arg->{into}, | ||||
445 | as => $as | ||||
446 | }); | ||||
447 | } | ||||
448 | } | ||||
449 | } | ||||
450 | |||||
451 | sub default_exporter { | ||||
452 | Carp::cluck "default_exporter is deprecated; call default_installer instead; the semantics are identical"; | ||||
453 | goto &default_installer; | ||||
454 | } | ||||
455 | |||||
456 | |||||
457 | setup_exporter({ | ||||
458 | exports => [ | ||||
459 | qw(setup_exporter build_exporter), | ||||
460 | 3 | 11µs | 3 | 284µs | # spent 296µs (12+284) within Sub::Exporter::__ANON__[/opt/flows/lib/lib/perl5/Sub/Exporter.pm:460] which was called 3 times, avg 99µs/call:
# 3 times (12µs+284µs) by Sub::Exporter::default_generator at line 419, avg 99µs/call # spent 284µs making 3 calls to Sub::Exporter::build_exporter, avg 95µs/call |
461 | 1 | 10µs | 1 | 287µs | ], # spent 287µ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 18µs within Sub::Exporter::_setup which was called 3 times, avg 6µs/call:
# 3 times (18µs+0s) by Sub::Exporter::__ANON__[/opt/flows/lib/lib/perl5/Sub/Exporter.pm:159] at line 154, avg 6µs/call | ||||
469 | 3 | 1µs | my ($value, $arg) = @_; | ||
470 | |||||
471 | 3 | 2µs | if (ref $value eq 'HASH') { | ||
472 | 3 | 10µs | push @{ $arg->{import_args} }, [ _import => { -as => 'import', %$value } ]; | ||
473 | 3 | 9µ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 | |||||
- - | |||||
484 | 1 | 7µs | "jn8:32"; # <-- magic true value | ||
485 | |||||
486 | __END__ | ||||
# spent 3µs within Sub::Exporter::CORE:match which was called:
# once (3µs+0s) by Sub::Exporter::_assert_collector_names_ok at line 227 |