Profile of Moose/Exporter.pm

← 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:10 2016

Filename | /usr/local/lib/perl/5.18.2/Moose/Exporter.pm
Statements | Executed 21820 statements in 38.7ms

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
504 | 1 | 1 | 4.28ms | 7.13ms | Moose::Exporter::::__ANON__[:389]Moose::Exporter::__ANON__[:389]
67 | 1 | 1 | 4.19ms | 50.3ms | Moose::Exporter::::__ANON__[:140]Moose::Exporter::__ANON__[:140]
62 | 1 | 1 | 4.16ms | 4.27ms | Moose::Exporter::::_remove_keywordsMoose::Exporter::_remove_keywords
1 | 1 | 1 | 3.45ms | 72.7ms | Moose::Exporter::::BEGIN@8Moose::Exporter::BEGIN@8
504 | 1 | 1 | 2.04ms | 2.04ms | Moose::Exporter::::_late_curry_wrapperMoose::Exporter::_late_curry_wrapper
67 | 1 | 1 | 1.01ms | 1.01ms | Moose::Exporter::::_collect_metarolesMoose::Exporter::_collect_metaroles
67 | 1 | 1 | 703µs | 2.27ms | Moose::Exporter::::_apply_metarolesMoose::Exporter::_apply_metaroles
67 | 1 | 1 | 701µs | 978µs | Moose::Exporter::::_strip_traitsMoose::Exporter::_strip_traits
1 | 1 | 1 | 612µs | 3.74ms | Moose::Exporter::::BEGIN@10Moose::Exporter::BEGIN@10
141 | 1 | 1 | 597µs | 1.33ms | Moose::Exporter::::__ANON__[:252]Moose::Exporter::__ANON__[:252]
394 | 1 | 1 | 423µs | 423µs | Moose::Exporter::::__ANON__[:317]Moose::Exporter::__ANON__[:317]
67 | 1 | 1 | 422µs | 505µs | Moose::Exporter::::_strip_meta_nameMoose::Exporter::_strip_meta_name
67 | 1 | 1 | 422µs | 521µs | Moose::Exporter::::_strip_metaclassMoose::Exporter::_strip_metaclass
134 | 2 | 1 | 368µs | 844µs | Moose::Exporter::::__ANON__[:39]Moose::Exporter::__ANON__[:39]
3 | 1 | 1 | 354µs | 556µs | Moose::Exporter::::_make_sub_exporter_paramsMoose::Exporter::_make_sub_exporter_params
67 | 1 | 1 | 207µs | 207µs | Moose::Exporter::::_get_callerMoose::Exporter::_get_caller
3 | 1 | 1 | 186µs | 2.46ms | Moose::Exporter::::build_import_methodsMoose::Exporter::build_import_methods
44 | 3 | 1 | 120µs | 120µs | Moose::Exporter::::_sub_from_packageMoose::Exporter::_sub_from_package
124 | 1 | 1 | 111µs | 111µs | Moose::Exporter::::_flag_as_reexportMoose::Exporter::_flag_as_reexport (xsub)
122 | 1 | 1 | 111µs | 111µs | Moose::Exporter::::_export_is_flaggedMoose::Exporter::_export_is_flagged (xsub)
16 | 1 | 1 | 44µs | 44µs | Moose::Exporter::::_make_wrapped_sub_with_metaMoose::Exporter::_make_wrapped_sub_with_meta
3 | 1 | 1 | 40µs | 40µs | Moose::Exporter::::_make_init_metaMoose::Exporter::_make_init_meta
3 | 3 | 3 | 37µs | 89µs | Moose::Exporter::::importMoose::Exporter::import
3 | 1 | 1 | 35µs | 115µs | Moose::Exporter::::_follow_alsoMoose::Exporter::_follow_also
3 | 1 | 1 | 34µs | 1.20ms | Moose::Exporter::::_make_exporterMoose::Exporter::_make_exporter
3 | 3 | 3 | 34µs | 2.50ms | Moose::Exporter::::setup_import_methodsMoose::Exporter::setup_import_methods
3 | 1 | 1 | 30µs | 51µs | Moose::Exporter::::_die_if_cycle_found_in_also_list_for_packageMoose::Exporter::_die_if_cycle_found_in_also_list_for_package
28 | 1 | 1 | 26µs | 26µs | Moose::Exporter::::CORE:matchMoose::Exporter::CORE:match (opcode)
3 | 1 | 1 | 22µs | 22µs | Moose::Exporter::::_make_import_subMoose::Exporter::_make_import_sub
6 | 2 | 1 | 15µs | 15µs | Moose::Exporter::::_also_list_for_packageMoose::Exporter::_also_list_for_package
3 | 1 | 1 | 14µs | 14µs | Moose::Exporter::::_make_unimport_subMoose::Exporter::_make_unimport_sub
1 | 1 | 1 | 13µs | 47µs | Moose::Exporter::::BEGIN@11Moose::Exporter::BEGIN@11
1 | 1 | 1 | 13µs | 26µs | Moose::Exporter::::BEGIN@136Moose::Exporter::BEGIN@136
3 | 1 | 1 | 13µs | 16µs | Moose::Exporter::::_follow_also_realMoose::Exporter::_follow_also_real
3 | 1 | 1 | 13µs | 13µs | Moose::Exporter::::_parse_trait_aliasesMoose::Exporter::_parse_trait_aliases
1 | 1 | 1 | 10µs | 97µs | Moose::Exporter::::BEGIN@12Moose::Exporter::BEGIN@12
1 | 1 | 1 | 9µs | 47µs | Moose::Exporter::::BEGIN@9Moose::Exporter::BEGIN@9
1 | 1 | 1 | 9µs | 19µs | Moose::Exporter::::BEGIN@4Moose::Exporter::BEGIN@4
1 | 1 | 1 | 8µs | 17µs | Moose::Exporter::::BEGIN@725Moose::Exporter::BEGIN@725
3 | 1 | 1 | 8µs | 8µs | Moose::Exporter::::_die_if_also_list_cycles_back_to_existing_stackMoose::Exporter::_die_if_also_list_cycles_back_to_existing_stack
1 | 1 | 1 | 7µs | 20µs | Moose::Exporter::::BEGIN@135Moose::Exporter::BEGIN@135
1 | 1 | 1 | 7µs | 27µs | Moose::Exporter::::BEGIN@7Moose::Exporter::BEGIN@7
1 | 1 | 1 | 7µs | 16µs | Moose::Exporter::::BEGIN@331Moose::Exporter::BEGIN@331
1 | 1 | 1 | 6µs | 25µs | Moose::Exporter::::BEGIN@13Moose::Exporter::BEGIN@13
1 | 1 | 1 | 6µs | 13µs | Moose::Exporter::::BEGIN@735Moose::Exporter::BEGIN@735
1 | 1 | 1 | 6µs | 9µs | Moose::Exporter::::BEGIN@5Moose::Exporter::BEGIN@5
1 | 1 | 1 | 5µs | 98µs | Moose::Exporter::::BEGIN@15Moose::Exporter::BEGIN@15
0 | 0 | 0 | 0s | 0s | Moose::Exporter::::__ANON__[:228]Moose::Exporter::__ANON__[:228]
0 | 0 | 0 | 0s | 0s | Moose::Exporter::::__ANON__[:366]Moose::Exporter::__ANON__[:366]
0 | 0 | 0 | 0s | 0s | Moose::Exporter::::__ANON__[:398]Moose::Exporter::__ANON__[:398]
0 | 0 | 0 | 0s | 0s | Moose::Exporter::::__ANON__[:420]Moose::Exporter::__ANON__[:420]
0 | 0 | 0 | 0s | 0s | Moose::Exporter::::__ANON__[:528]Moose::Exporter::__ANON__[:528]
0 | 0 | 0 | 0s | 0s | Moose::Exporter::::__ANON__[:532]Moose::Exporter::__ANON__[:532]
0 | 0 | 0 | 0s | 0s | Moose::Exporter::::__ANON__[:546]Moose::Exporter::__ANON__[:546]
0 | 0 | 0 | 0s | 0s | Moose::Exporter::::__ANON__[:558]Moose::Exporter::__ANON__[:558]
0 | 0 | 0 | 0s | 0s | Moose::Exporter::::__ANON__[:715]Moose::Exporter::__ANON__[:715]
0 | 0 | 0 | 0s | 0s | Moose::Exporter::::__ANON__[:787]Moose::Exporter::__ANON__[:787]
0 | 0 | 0 | 0s | 0s | Moose::Exporter::::_apply_meta_traitsMoose::Exporter::_apply_meta_traits
0 | 0 | 0 | 0s | 0s | Moose::Exporter::::_curry_wrapperMoose::Exporter::_curry_wrapper
0 | 0 | 0 | 0s | 0s | Moose::Exporter::::_make_wrapped_subMoose::Exporter::_make_wrapped_sub

Call graph for these subroutines as a Graphviz dot language file.

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | package Moose::Exporter;
2 | 1 | 600ns |  |  | our $VERSION = '2.1604';
3 |  |  |  |  |
4 | 2 | 20µs | 2 | 29µs | # spent 19µs (9+10) within Moose::Exporter::BEGIN@4 which was called: # once (9µs+10µs) by Moose::BEGIN@15 at line 4 use strict; # spent 19µs making 1 call to Moose::Exporter::BEGIN@4 # spent 10µs making 1 call to strict::import
5 | 2 | 19µs | 2 | 13µs | # spent 9µs (6+4) within Moose::Exporter::BEGIN@5 which was called: # once (6µs+4µs) by Moose::BEGIN@15 at line 5 use warnings; # spent 9µs making 1 call to Moose::Exporter::BEGIN@5 # spent 4µs making 1 call to warnings::import
6 |  |  |  |  |
7 | 2 | 20µs | 2 | 48µs | # spent 27µs (7+20) within Moose::Exporter::BEGIN@7 which was called: # once (7µs+20µs) by Moose::BEGIN@15 at line 7 use Class::Load qw(is_class_loaded); # spent 27µs making 1 call to Moose::Exporter::BEGIN@7 # spent 20µs making 1 call to Exporter::import
8 | 2 | 120µs | 1 | 72.7ms | # spent 72.7ms (3.45+69.3) within Moose::Exporter::BEGIN@8 which was called: # once (3.45ms+69.3ms) by Moose::BEGIN@15 at line 8 use Class::MOP; # spent 72.7ms making 1 call to Moose::Exporter::BEGIN@8
9 | 2 | 25µs | 2 | 85µs | # spent 47µs (9+38) within Moose::Exporter::BEGIN@9 which was called: # once (9µs+38µs) by Moose::BEGIN@15 at line 9 use List::MoreUtils qw( first_index uniq ); # spent 47µs making 1 call to Moose::Exporter::BEGIN@9 # spent 38µs making 1 call to Exporter::import
10 | 2 | 140µs | 1 | 3.74ms | # spent 3.74ms (612µs+3.12) within Moose::Exporter::BEGIN@10 which was called: # once (612µs+3.12ms) by Moose::BEGIN@15 at line 10 use Moose::Util::MetaRole; # spent 3.74ms making 1 call to Moose::Exporter::BEGIN@10
11 | 3 | 40µs | 3 | 81µs | # spent 47µs (13+34) within Moose::Exporter::BEGIN@11 which was called: # once (13µs+34µs) by Moose::BEGIN@15 at line 11 use Scalar::Util 1.11 qw(reftype); # spent 47µs making 1 call to Moose::Exporter::BEGIN@11 # spent 24µs making 1 call to Exporter::import # spent 9µs making 1 call to UNIVERSAL::VERSION
12 | 3 | 36µs | 3 | 185µs | # spent 97µs (10+88) within Moose::Exporter::BEGIN@12 which was called: # once (10µs+88µs) by Moose::BEGIN@15 at line 12 use Sub::Exporter 0.980; # spent 97µs making 1 call to Moose::Exporter::BEGIN@12 # spent 80µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337] # spent 8µs making 1 call to UNIVERSAL::VERSION
13 | 2 | 21µs | 2 | 43µs | # spent 25µs (6+18) within Moose::Exporter::BEGIN@13 which was called: # once (6µs+18µs) by Moose::BEGIN@15 at line 13 use Sub::Name qw(subname); # spent 25µs making 1 call to Moose::Exporter::BEGIN@13 # spent 18µs making 1 call to Exporter::import
14 |  |  |  |  |
15 | 2 | 357µs | 2 | 190µs | # spent 98µs (5+92) within Moose::Exporter::BEGIN@15 which was called: # once (5µs+92µs) by Moose::BEGIN@15 at line 15 use Moose::Util 'throw_exception'; # spent 98µs making 1 call to Moose::Exporter::BEGIN@15 # spent 92µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337]
16 |  |  |  |  |
17 | 1 | 200ns |  |  | my %EXPORT_SPEC;
18 |  |  |  |  |
19 |  |  |  |  | # spent 2.50ms (34µs+2.46) within Moose::Exporter::setup_import_methods which was called 3 times, avg 833µs/call: # once (13µs+946µs) by Moose::Meta::Attribute::BEGIN@16 at line 38 of Moose/Util/TypeConstraints.pm # once (10µs+761µs) by PONAPI::Builder::BEGIN@4 at line 94 of Moose/Role.pm # once (11µs+758µs) by PONAPI::Server::ConfigReader::BEGIN@4 at line 132 of Moose.pm sub setup_import_methods {
20 | 3 | 6µs |  |  | my ( $class, %args ) = @_;
21 |  |  |  |  |
22 | 3 | 5µs |  |  | $args{exporting_package} ||= caller();
23 |  |  |  |  |
24 | 3 | 24µs | 3 | 2.46ms | $class->build_import_methods( # spent 2.46ms making 3 calls to Moose::Exporter::build_import_methods, avg 822µs/call
25 |  |  |  |  | %args,
26 |  |  |  |  | install => [qw(import unimport init_meta)]
27 |  |  |  |  | );
28 |  |  |  |  | }
29 |  |  |  |  |
30 |  |  |  |  | # A reminder to intrepid Moose hackers
31 |  |  |  |  | # there may be more than one level of exporter
32 |  |  |  |  | # don't make doy cry. -- perigrin
33 |  |  |  |  |
34 |  |  |  |  | # spent 2.46ms (186µs+2.28) within Moose::Exporter::build_import_methods which was called 3 times, avg 822µs/call: # 3 times (186µs+2.28ms) by Moose::Exporter::setup_import_methods at line 24, avg 822µs/call sub build_import_methods {
35 | 3 | 5µs |  |  | my ( $class, %args ) = @_;
36 |  |  |  |  |
37 | 3 | 3µs |  |  | my $exporting_package = $args{exporting_package} ||= caller();
38 |  |  |  |  |
39 | 137 | 338µs | 134 | 476µs | # spent 844µs (368+476) within Moose::Exporter::__ANON__[/usr/local/lib/perl/5.18.2/Moose/Exporter.pm:39] which was called 134 times, avg 6µs/call: # 67 times (228µs+242µs) by Moose::Exporter::_apply_metaroles at line 575, avg 7µs/call # 67 times (140µs+233µs) by Moose::Exporter::__ANON__[/usr/local/lib/perl/5.18.2/Moose/Exporter.pm:140] at line 111, avg 6µs/call my $meta_lookup = $args{meta_lookup} || sub { Class::MOP::class_of(shift) }; # spent 476µs making 134 calls to Class::MOP::class_of, avg 4µs/call
40 |  |  |  |  |
41 | 3 | 3µs |  |  | $EXPORT_SPEC{$exporting_package} = \%args;
42 |  |  |  |  |
43 | 3 | 9µs | 3 | 115µs | my @exports_from = $class->_follow_also($exporting_package); # spent 115µs making 3 calls to Moose::Exporter::_follow_also, avg 38µs/call
44 |  |  |  |  |
45 | 3 | 2µs |  |  | my $export_recorder = {};
46 | 3 | 1µs |  |  | my $is_reexport = {};
47 |  |  |  |  |
48 | 3 | 14µs | 3 | 556µs | my $exports = $class->_make_sub_exporter_params( # spent 556µs making 3 calls to Moose::Exporter::_make_sub_exporter_params, avg 185µs/call
49 |  |  |  |  | [ $exporting_package, @exports_from ],
50 |  |  |  |  | $export_recorder,
51 |  |  |  |  | $is_reexport,
52 |  |  |  |  | $args{meta_lookup}, # so that we don't pass through the default
53 |  |  |  |  | );
54 |  |  |  |  |
55 | 3 | 11µs | 3 | 1.20ms | my $exporter = $class->_make_exporter( # spent 1.20ms making 3 calls to Moose::Exporter::_make_exporter, avg 401µs/call
56 |  |  |  |  | $exports,
57 |  |  |  |  | $is_reexport,
58 |  |  |  |  | $meta_lookup,
59 |  |  |  |  | );
60 |  |  |  |  |
61 | 3 | 600ns |  |  | my %methods;
62 | 3 | 12µs | 3 | 22µs | $methods{import} = $class->_make_import_sub( # spent 22µs making 3 calls to Moose::Exporter::_make_import_sub, avg 7µs/call
63 |  |  |  |  | $exporting_package,
64 |  |  |  |  | $exporter,
65 |  |  |  |  | \@exports_from,
66 |  |  |  |  | $is_reexport,
67 |  |  |  |  | $meta_lookup,
68 |  |  |  |  | );
69 |  |  |  |  |
70 | 3 | 9µs | 3 | 14µs | $methods{unimport} = $class->_make_unimport_sub( # spent 14µs making 3 calls to Moose::Exporter::_make_unimport_sub, avg 5µs/call
71 |  |  |  |  | $exporting_package,
72 |  |  |  |  | $exports,
73 |  |  |  |  | $export_recorder,
74 |  |  |  |  | $is_reexport,
75 |  |  |  |  | $meta_lookup,
76 |  |  |  |  | );
77 |  |  |  |  |
78 | 3 | 11µs | 3 | 40µs | $methods{init_meta} = $class->_make_init_meta( # spent 40µs making 3 calls to Moose::Exporter::_make_init_meta, avg 13µs/call
79 |  |  |  |  | $exporting_package,
80 |  |  |  |  | \%args,
81 |  |  |  |  | $meta_lookup,
82 |  |  |  |  | );
83 |  |  |  |  |
84 | 3 | 10µs | 3 | 87µs | my $package = Class::MOP::Package->initialize($exporting_package); # spent 87µs making 3 calls to Class::MOP::Package::initialize, avg 29µs/call
85 | 3 | 6µs |  |  | for my $to_install ( @{ $args{install} || [] } ) {
86 | 9 | 4µs |  |  | my $symbol = '&' . $to_install;
87 |  |  |  |  |
88 |  |  |  |  | next
89 | 9 | 13µs | 6 | 137µs | unless $methods{$to_install} # spent 137µs making 6 calls to Class::MOP::Package::has_package_symbol, avg 23µs/call
90 |  |  |  |  | && !$package->has_package_symbol($symbol);
91 | 6 | 46µs | 12 | 107µs | $package->add_package_symbol( # spent 92µs making 6 calls to Class::MOP::Package::add_package_symbol, avg 15µs/call # spent 15µs making 6 calls to Sub::Name::subname, avg 3µs/call
92 |  |  |  |  | $symbol,
93 |  |  |  |  | subname(
94 |  |  |  |  | $exporting_package . '::' . $to_install, $methods{$to_install}
95 |  |  |  |  | )
96 |  |  |  |  | );
97 |  |  |  |  | }
98 |  |  |  |  |
99 | 3 | 12µs |  |  | return ( $methods{import}, $methods{unimport}, $methods{init_meta} );
100 |  |  |  |  | }
101 |  |  |  |  |
102 |  |  |  |  | # spent 1.20ms (34µs+1.17) within Moose::Exporter::_make_exporter which was called 3 times, avg 401µs/call: # 3 times (34µs+1.17ms) by Moose::Exporter::build_import_methods at line 55, avg 401µs/call sub _make_exporter {
103 | 3 | 2µs |  |  | my ($class, $exports, $is_reexport, $meta_lookup) = @_;
104 |  |  |  |  |
105 |  |  |  |  | return Sub::Exporter::build_exporter(
106 |  |  |  |  | {
107 |  |  |  |  | exports => $exports,
108 |  |  |  |  | groups => { default => [':all'] },
109 |  |  |  |  | # spent 50.3ms (4.19+46.1) within Moose::Exporter::__ANON__[/usr/local/lib/perl/5.18.2/Moose/Exporter.pm:140] which was called 67 times, avg 751µs/call: # 67 times (4.19ms+46.1ms) by Sub::Exporter::_do_import at line 380 of Sub/Exporter.pm, avg 751µs/call installer => sub {
110 | 67 | 30µs |  |  | my ($arg, $to_export) = @_;
111 | 67 | 77µs | 67 | 374µs | my $meta = $meta_lookup->($arg->{into}); # spent 374µs making 67 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:39], avg 6µs/call
112 |  |  |  |  |
113 | 67 | 27µs | 2 | 886µs | goto &Sub::Exporter::default_installer unless $meta; # spent 886µs making 2 calls to Sub::Exporter::default_installer, avg 443µs/call
114 |  |  |  |  |
115 |  |  |  |  | # don't overwrite existing symbols with our magically flagged
116 |  |  |  |  | # version of it if we would install the same sub that's already
117 |  |  |  |  | # in the importer
118 |  |  |  |  |
119 | 65 | 19µs |  |  | my @filtered_to_export;
120 | 65 | 10µs |  |  | my %installed;
121 | 65 | 365µs |  |  | for (my $i = 0; $i < @{ $to_export }; $i += 2) {
122 | 862 | 359µs |  |  | my ($as, $cv) = @{ $to_export }[$i, $i + 1];
123 |  |  |  |  |
124 | 862 | 919µs | 864 | 17.7ms | next if !ref($as) # spent 17.7ms making 862 calls to Class::MOP::Package::has_package_symbol, avg 21µs/call # spent 12µs making 2 calls to Class::MOP::Package::get_package_symbol, avg 6µs/call
125 |  |  |  |  | && $meta->has_package_symbol('&' . $as)
126 |  |  |  |  | && $meta->get_package_symbol('&' . $as) == $cv;
127 |  |  |  |  |
128 | 860 | 260µs |  |  | push @filtered_to_export, $as, $cv;
129 | 860 | 529µs |  |  | $installed{$as} = 1 unless ref $as;
130 |  |  |  |  | }
131 |  |  |  |  |
132 | 65 | 101µs | 65 | 27.9ms | Sub::Exporter::default_installer($arg, \@filtered_to_export); # spent 27.9ms making 65 calls to Sub::Exporter::default_installer, avg 429µs/call
133 |  |  |  |  |
134 | 65 | 317µs |  |  | for my $name ( keys %{$is_reexport} ) {
135 | 2 | 23µs | 2 | 33µs | # spent 20µs (7+13) within Moose::Exporter::BEGIN@135 which was called: # once (7µs+13µs) by Moose::BEGIN@15 at line 135 no strict 'refs'; # spent 20µs making 1 call to Moose::Exporter::BEGIN@135 # spent 13µs making 1 call to strict::unimport
136 | 2 | 731µs | 2 | 39µs | # spent 26µs (13+13) within Moose::Exporter::BEGIN@136 which was called: # once (13µs+13µs) by Moose::BEGIN@15 at line 136 no warnings 'once'; # spent 26µs making 1 call to Moose::Exporter::BEGIN@136 # spent 13µs making 1 call to warnings::unimport
137 | 126 | 34µs |  |  | next unless exists $installed{$name};
138 | 124 | 566µs | 124 | 111µs | _flag_as_reexport( \*{ join q{::}, $arg->{into}, $name } ); # spent 111µs making 124 calls to Moose::Exporter::_flag_as_reexport, avg 895ns/call
139 |  |  |  |  | }
140 |  |  |  |  | },
141 |  |  |  |  | }
142 | 3 | 33µs | 3 | 1.17ms | ); # spent 1.17ms making 3 calls to Sub::Exporter::build_exporter, avg 389µs/call
143 |  |  |  |  | }
144 |  |  |  |  |
145 |  |  |  |  | # spent 115µs (35+80) within Moose::Exporter::_follow_also which was called 3 times, avg 38µs/call: # 3 times (35µs+80µs) by Moose::Exporter::build_import_methods at line 43, avg 38µs/call sub _follow_also {
146 | 3 | 3µs |  |  | my $class = shift;
147 | 3 | 800ns |  |  | my $exporting_package = shift;
148 |  |  |  |  |
149 | 3 | 6µs | 3 | 51µs | _die_if_cycle_found_in_also_list_for_package($exporting_package); # spent 51µs making 3 calls to Moose::Exporter::_die_if_cycle_found_in_also_list_for_package, avg 17µs/call
150 |  |  |  |  |
151 | 3 | 33µs | 6 | 29µs | return uniq( _follow_also_real($exporting_package) ); # spent 16µs making 3 calls to Moose::Exporter::_follow_also_real, avg 5µs/call # spent 13µs making 3 calls to List::MoreUtils::uniq, avg 4µs/call
152 |  |  |  |  | }
153 |  |  |  |  |
154 |  |  |  |  | # spent 16µs (13+3) within Moose::Exporter::_follow_also_real which was called 3 times, avg 5µs/call: # 3 times (13µs+3µs) by Moose::Exporter::_follow_also at line 151, avg 5µs/call sub _follow_also_real {
155 | 3 | 900ns |  |  | my $exporting_package = shift;
156 | 3 | 2µs | 3 | 3µs | my @also = _also_list_for_package($exporting_package); # spent 3µs making 3 calls to Moose::Exporter::_also_list_for_package, avg 1µs/call
157 |  |  |  |  |
158 | 3 | 8µs |  |  | return map { $_, _follow_also_real($_) } @also;
159 |  |  |  |  | }
160 |  |  |  |  |
161 |  |  |  |  | # spent 15µs within Moose::Exporter::_also_list_for_package which was called 6 times, avg 3µs/call: # 3 times (12µs+0s) by Moose::Exporter::_die_if_cycle_found_in_also_list_for_package at line 183, avg 4µs/call # 3 times (3µs+0s) by Moose::Exporter::_follow_also_real at line 156, avg 1µs/call sub _also_list_for_package {
162 | 6 | 2µs |  |  | my $package = shift;
163 |  |  |  |  |
164 | 6 | 3µs |  |  | if ( !exists $EXPORT_SPEC{$package} ) {
165 |  |  |  |  | my $loaded = is_class_loaded($package);
166 |  |  |  |  |
167 |  |  |  |  | throw_exception( PackageDoesNotUseMooseExporter => package => $package,
168 |  |  |  |  | is_loaded => $loaded
169 |  |  |  |  | );
170 |  |  |  |  | }
171 |  |  |  |  |
172 | 6 | 4µs |  |  | my $also = $EXPORT_SPEC{$package}{also};
173 |  |  |  |  |
174 | 6 | 22µs |  |  | return unless defined $also;
175 |  |  |  |  |
176 |  |  |  |  | return ref $also ? @$also : $also;
177 |  |  |  |  | }
178 |  |  |  |  |
179 |  |  |  |  | # this is no Tarjan algorithm, but for the list sizes expected,
180 |  |  |  |  | # brute force will probably be fine (and more maintainable)
181 |  |  |  |  | # spent 51µs (30+20) within Moose::Exporter::_die_if_cycle_found_in_also_list_for_package which was called 3 times, avg 17µs/call: # 3 times (30µs+20µs) by Moose::Exporter::_follow_also at line 149, avg 17µs/call sub _die_if_cycle_found_in_also_list_for_package {
182 | 3 | 900ns |  |  | my $package = shift;
183 | 3 | 20µs | 6 | 20µs | _die_if_also_list_cycles_back_to_existing_stack( # spent 12µs making 3 calls to Moose::Exporter::_also_list_for_package, avg 4µs/call # spent 8µs making 3 calls to Moose::Exporter::_die_if_also_list_cycles_back_to_existing_stack, avg 3µs/call
184 |  |  |  |  | [ _also_list_for_package($package) ],
185 |  |  |  |  | [$package],
186 |  |  |  |  | );
187 |  |  |  |  | }
188 |  |  |  |  |
189 |  |  |  |  | # spent 8µs within Moose::Exporter::_die_if_also_list_cycles_back_to_existing_stack which was called 3 times, avg 3µs/call: # 3 times (8µs+0s) by Moose::Exporter::_die_if_cycle_found_in_also_list_for_package at line 183, avg 3µs/call sub _die_if_also_list_cycles_back_to_existing_stack {
190 | 3 | 1µs |  |  | my ( $also_list, $existing_stack ) = @_;
191 |  |  |  |  |
192 | 3 | 10µs |  |  | return unless @$also_list && @$existing_stack;
193 |  |  |  |  |
194 |  |  |  |  | for my $also_member (@$also_list) {
195 |  |  |  |  | for my $stack_member (@$existing_stack) {
196 |  |  |  |  | next unless $also_member eq $stack_member;
197 |  |  |  |  |
198 |  |  |  |  | throw_exception( CircularReferenceInAlso => also_parameter => $also_member,
199 |  |  |  |  | stack => $existing_stack
200 |  |  |  |  | );
201 |  |  |  |  | }
202 |  |  |  |  |
203 |  |  |  |  | _die_if_also_list_cycles_back_to_existing_stack(
204 |  |  |  |  | [ _also_list_for_package($also_member) ],
205 |  |  |  |  | [ $also_member, @$existing_stack ],
206 |  |  |  |  | );
207 |  |  |  |  | }
208 |  |  |  |  | }
209 |  |  |  |  |
210 |  |  |  |  | # spent 13µs within Moose::Exporter::_parse_trait_aliases which was called 3 times, avg 4µs/call: # 3 times (13µs+0s) by Moose::Exporter::_make_sub_exporter_params at line 281, avg 4µs/call sub _parse_trait_aliases {
211 | 3 | 1µs |  |  | my $class = shift;
212 | 3 | 2µs |  |  | my ($package, $aliases) = @_;
213 |  |  |  |  |
214 | 3 | 400ns |  |  | my @ret;
215 | 3 | 3µs |  |  | for my $alias (@$aliases) {
216 |  |  |  |  | my $name;
217 |  |  |  |  | if (ref($alias)) {
218 |  |  |  |  | reftype($alias) eq 'ARRAY'
219 |  |  |  |  | or throw_exception( InvalidArgumentsToTraitAliases => class_name => $class,
220 |  |  |  |  | package_name => $package,
221 |  |  |  |  | alias => $alias
222 |  |  |  |  | );
223 |  |  |  |  | ($alias, $name) = @$alias;
224 |  |  |  |  | }
225 |  |  |  |  | else {
226 |  |  |  |  | ($name = $alias) =~ s/.*:://;
227 |  |  |  |  | }
228 |  |  |  |  | push @ret, subname "${package}::${name}" => sub () { $alias };
229 |  |  |  |  | }
230 |  |  |  |  |
231 | 3 | 9µs |  |  | return @ret;
232 |  |  |  |  | }
233 |  |  |  |  |
234 |  |  |  |  | # spent 556µs (354+202) within Moose::Exporter::_make_sub_exporter_params which was called 3 times, avg 185µs/call: # 3 times (354µs+202µs) by Moose::Exporter::build_import_methods at line 48, avg 185µs/call sub _make_sub_exporter_params {
235 | 3 | 900ns |  |  | my $class = shift;
236 | 3 | 900ns |  |  | my $packages = shift;
237 | 3 | 600ns |  |  | my $export_recorder = shift;
238 | 3 | 400ns |  |  | my $is_reexport = shift;
239 | 3 | 3µs |  |  | my $meta_lookup_override = shift;
240 |  |  |  |  |
241 | 3 | 700ns |  |  | my %exports;
242 | 3 | 500ns |  |  | my $current_meta_lookup;
243 |  |  |  |  |
244 | 3 | 4µs |  |  | for my $package ( @{$packages} ) {
245 | 3 | 1µs |  |  | my $args = $EXPORT_SPEC{$package}
246 |  |  |  |  | or die "The $package package does not use Moose::Exporter\n";
247 |  |  |  |  |
248 | 3 | 3µs |  |  | $current_meta_lookup = $meta_lookup_override || $args->{meta_lookup};
249 | 3 | 500ns |  |  | $meta_lookup_override = $current_meta_lookup;
250 |  |  |  |  |
251 |  |  |  |  | my $meta_lookup = $current_meta_lookup
252 | 144 | 640µs | 141 | 734µs | # spent 1.33ms (597µs+734µs) within Moose::Exporter::__ANON__[/usr/local/lib/perl/5.18.2/Moose/Exporter.pm:252] which was called 141 times, avg 9µs/call: # 141 times (597µs+734µs) by Moose::Role::around or Moose::Role::before or Moose::Role::has or Moose::Role::override or Moose::Role::requires or Moose::Role::with or Moose::extends or Moose::has or Moose::override or Moose::with at line 418, avg 9µs/call || sub { Class::MOP::class_of(shift) }; # spent 734µs making 141 calls to Class::MOP::class_of, avg 5µs/call
253 |  |  |  |  |
254 | 3 | 4µs |  |  | for my $name ( @{ $args->{with_meta} } ) {
255 | 16 | 18µs | 16 | 41µs | my $sub = $class->_sub_from_package( $package, $name ) # spent 41µs making 16 calls to Moose::Exporter::_sub_from_package, avg 3µs/call
256 |  |  |  |  | or next;
257 |  |  |  |  |
258 | 16 | 7µs |  |  | my $fq_name = $package . '::' . $name;
259 |  |  |  |  |
260 | 16 | 31µs | 16 | 44µs | $exports{$name} = $class->_make_wrapped_sub_with_meta( # spent 44µs making 16 calls to Moose::Exporter::_make_wrapped_sub_with_meta, avg 3µs/call
261 |  |  |  |  | $fq_name,
262 |  |  |  |  | $sub,
263 |  |  |  |  | $export_recorder,
264 |  |  |  |  | $meta_lookup,
265 |  |  |  |  | ) unless exists $exports{$name};
266 |  |  |  |  | }
267 |  |  |  |  |
268 | 3 | 4µs |  |  | for my $name ( @{ $args->{with_caller} } ) {
269 |  |  |  |  | my $sub = $class->_sub_from_package( $package, $name )
270 |  |  |  |  | or next;
271 |  |  |  |  |
272 |  |  |  |  | my $fq_name = $package . '::' . $name;
273 |  |  |  |  |
274 |  |  |  |  | $exports{$name} = $class->_make_wrapped_sub(
275 |  |  |  |  | $fq_name,
276 |  |  |  |  | $sub,
277 |  |  |  |  | $export_recorder,
278 |  |  |  |  | ) unless exists $exports{$name};
279 |  |  |  |  | }
280 |  |  |  |  |
281 | 3 | 10µs | 3 | 13µs | my @extra_exports = $class->_parse_trait_aliases( # spent 13µs making 3 calls to Moose::Exporter::_parse_trait_aliases, avg 4µs/call
282 |  |  |  |  | $package, $args->{trait_aliases},
283 |  |  |  |  | );
284 | 3 | 7µs |  |  | for my $name ( @{ $args->{as_is} }, @extra_exports ) {
285 | 28 | 2µs |  |  | my ( $sub, $coderef_name );
286 |  |  |  |  |
287 | 28 | 71µs | 28 | 26µs | if ( ref $name ) { # spent 26µs making 28 calls to Moose::Exporter::CORE:match, avg 936ns/call
288 |  |  |  |  | $sub = $name;
289 |  |  |  |  |
290 |  |  |  |  | my $coderef_pkg;
291 |  |  |  |  | ( $coderef_pkg, $coderef_name )
292 |  |  |  |  | = Class::MOP::get_code_info($name);
293 |  |  |  |  |
294 |  |  |  |  | if ( $coderef_pkg ne $package ) {
295 |  |  |  |  | $is_reexport->{$coderef_name} = 1;
296 |  |  |  |  | }
297 |  |  |  |  | }
298 |  |  |  |  | elsif ( $name =~ /^(.*)::([^:]+)$/ ) {
299 | 4 | 13µs | 4 | 13µs | $sub = $class->_sub_from_package( "$1", "$2" ) # spent 13µs making 4 calls to Moose::Exporter::_sub_from_package, avg 3µs/call
300 |  |  |  |  | or next;
301 |  |  |  |  |
302 | 4 | 2µs |  |  | $coderef_name = "$2";
303 |  |  |  |  |
304 | 4 | 4µs |  |  | if ( $1 ne $package ) {
305 |  |  |  |  | $is_reexport->{$coderef_name} = 1;
306 |  |  |  |  | }
307 |  |  |  |  | }
308 |  |  |  |  | else {
309 | 24 | 26µs | 24 | 65µs | $sub = $class->_sub_from_package( $package, $name ) # spent 65µs making 24 calls to Moose::Exporter::_sub_from_package, avg 3µs/call
310 |  |  |  |  | or next;
311 |  |  |  |  |
312 | 24 | 7µs |  |  | $coderef_name = $name;
313 |  |  |  |  | }
314 |  |  |  |  |
315 | 28 | 22µs |  |  | $export_recorder->{$sub} = 1;
316 |  |  |  |  |
317 | 394 | 675µs |  |  | # spent 423µs within Moose::Exporter::__ANON__[/usr/local/lib/perl/5.18.2/Moose/Exporter.pm:317] which was called 394 times, avg 1µs/call: # 394 times (423µs+0s) by Sub::Exporter::default_generator at line 419 of Sub/Exporter.pm, avg 1µs/call $exports{$coderef_name} = sub { $sub }
318 | 28 | 56µs |  |  | unless exists $exports{$coderef_name};
319 |  |  |  |  | }
320 |  |  |  |  | }
321 |  |  |  |  |
322 | 3 | 9µs |  |  | return \%exports;
323 |  |  |  |  | }
324 |  |  |  |  |
325 |  |  |  |  | # spent 120µs within Moose::Exporter::_sub_from_package which was called 44 times, avg 3µs/call: # 24 times (65µs+0s) by Moose::Exporter::_make_sub_exporter_params at line 309, avg 3µs/call # 16 times (41µs+0s) by Moose::Exporter::_make_sub_exporter_params at line 255, avg 3µs/call # 4 times (13µs+0s) by Moose::Exporter::_make_sub_exporter_params at line 299, avg 3µs/call sub _sub_from_package {
326 | 44 | 9µs |  |  | my $sclass = shift;
327 | 44 | 5µs |  |  | my $package = shift;
328 | 44 | 6µs |  |  | my $name = shift;
329 |  |  |  |  |
330 | 44 | 12µs |  |  | my $sub = do {
331 | 2 | 1.33ms | 2 | 25µs | # spent 16µs (7+9) within Moose::Exporter::BEGIN@331 which was called: # once (7µs+9µs) by Moose::BEGIN@15 at line 331 no strict 'refs'; # spent 16µs making 1 call to Moose::Exporter::BEGIN@331 # spent 9µs making 1 call to strict::unimport
332 | 44 | 48µs |  |  | \&{ $package . '::' . $name };
333 |  |  |  |  | };
334 |  |  |  |  |
335 | 44 | 83µs |  |  | return $sub if defined &$sub;
336 |  |  |  |  |
337 |  |  |  |  | Carp::cluck "Trying to export undefined sub ${package}::${name}";
338 |  |  |  |  |
339 |  |  |  |  | return;
340 |  |  |  |  | }
341 |  |  |  |  |
342 | 1 | 0s |  |  | our $CALLER;
343 |  |  |  |  |
344 |  |  |  |  | sub _make_wrapped_sub {
345 |  |  |  |  | my $self = shift;
346 |  |  |  |  | my $fq_name = shift;
347 |  |  |  |  | my $sub = shift;
348 |  |  |  |  | my $export_recorder = shift;
349 |  |  |  |  |
350 |  |  |  |  | # We need to set the package at import time, so that when
351 |  |  |  |  | # package Foo imports has(), we capture "Foo" as the
352 |  |  |  |  | # package. This lets other packages call Foo::has() and get
353 |  |  |  |  | # the right package. This is done for backwards compatibility
354 |  |  |  |  | # with existing production code, not because this is a good
355 |  |  |  |  | # idea ;)
356 |  |  |  |  | return sub {
357 |  |  |  |  | my $caller = $CALLER;
358 |  |  |  |  |
359 |  |  |  |  | my $wrapper = $self->_curry_wrapper( $sub, $fq_name, $caller );
360 |  |  |  |  |
361 |  |  |  |  | my $sub = subname( $fq_name => $wrapper );
362 |  |  |  |  |
363 |  |  |  |  | $export_recorder->{$sub} = 1;
364 |  |  |  |  |
365 |  |  |  |  | return $sub;
366 |  |  |  |  | };
367 |  |  |  |  | }
368 |  |  |  |  |
369 |  |  |  |  | # spent 44µs within Moose::Exporter::_make_wrapped_sub_with_meta which was called 16 times, avg 3µs/call: # 16 times (44µs+0s) by Moose::Exporter::_make_sub_exporter_params at line 260, avg 3µs/call sub _make_wrapped_sub_with_meta {
370 | 16 | 4µs |  |  | my $self = shift;
371 | 16 | 3µs |  |  | my $fq_name = shift;
372 | 16 | 2µs |  |  | my $sub = shift;
373 | 16 | 1µs |  |  | my $export_recorder = shift;
374 | 16 | 2µs |  |  | my $meta_lookup = shift;
375 |  |  |  |  |
376 |  |  |  |  | # spent 7.13ms (4.28+2.86) within Moose::Exporter::__ANON__[/usr/local/lib/perl/5.18.2/Moose/Exporter.pm:389] which was called 504 times, avg 14µs/call: # 504 times (4.28ms+2.86ms) by Sub::Exporter::default_generator at line 419 of Sub/Exporter.pm, avg 14µs/call return sub {
377 | 504 | 100µs |  |  | my $caller = $CALLER;
378 |  |  |  |  |
379 | 504 | 565µs | 504 | 2.04ms | my $wrapper = $self->_late_curry_wrapper( # spent 2.04ms making 504 calls to Moose::Exporter::_late_curry_wrapper, avg 4µs/call
380 |  |  |  |  | $sub, $fq_name,
381 |  |  |  |  | $meta_lookup => $caller
382 |  |  |  |  | );
383 |  |  |  |  |
384 | 504 | 1.61ms | 504 | 822µs | my $sub = subname( $fq_name => $wrapper ); # spent 822µs making 504 calls to Sub::Name::subname, avg 2µs/call
385 |  |  |  |  |
386 | 504 | 1.63ms |  |  | $export_recorder->{$sub} = 1;
387 |  |  |  |  |
388 | 504 | 4.69ms |  |  | return $sub;
389 | 16 | 50µs |  |  | };
390 |  |  |  |  | }
391 |  |  |  |  |
392 |  |  |  |  | sub _curry_wrapper {
393 |  |  |  |  | my $class = shift;
394 |  |  |  |  | my $sub = shift;
395 |  |  |  |  | my $fq_name = shift;
396 |  |  |  |  | my @extra = @_;
397 |  |  |  |  |
398 |  |  |  |  | my $wrapper = sub { $sub->( @extra, @_ ) };
399 |  |  |  |  | if ( my $proto = prototype $sub ) {
400 |  |  |  |  |
401 |  |  |  |  | # XXX - Perl's prototype sucks. Use & to make set_prototype
402 |  |  |  |  | # ignore the fact that we're passing "private variables"
403 |  |  |  |  | &Scalar::Util::set_prototype( $wrapper, $proto );
404 |  |  |  |  | }
405 |  |  |  |  | return $wrapper;
406 |  |  |  |  | }
407 |  |  |  |  |
408 |  |  |  |  | # spent 2.04ms within Moose::Exporter::_late_curry_wrapper which was called 504 times, avg 4µs/call: # 504 times (2.04ms+0s) by Moose::Exporter::__ANON__[/usr/local/lib/perl/5.18.2/Moose/Exporter.pm:389] at line 379, avg 4µs/call sub _late_curry_wrapper {
409 | 504 | 101µs |  |  | my $class = shift;
410 | 504 | 93µs |  |  | my $sub = shift;
411 | 504 | 106µs |  |  | my $fq_name = shift;
412 | 504 | 51µs |  |  | my $extra = shift;
413 | 504 | 187µs |  |  | my @ex_args = @_;
414 |  |  |  |  |
415 |  |  |  |  | my $wrapper = sub {
416 |  |  |  |  |
417 |  |  |  |  | # resolve curried arguments at runtime via this closure
418 | 141 | 354µs | 141 | 1.33ms | my @curry = ( $extra->(@ex_args) ); # spent 1.33ms making 141 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:252], avg 9µs/call
419 | 141 | 665µs | 141 | 1.62s | return $sub->( @curry, @_ ); # spent 591ms making 14 calls to Moose::extends, avg 42.2ms/call # spent 555ms making 18 calls to Moose::with, avg 30.8ms/call, recursion: max depth 1, sum of overlapping time 7.62ms # spent 375ms making 47 calls to Moose::has, avg 7.99ms/call # spent 142ms making 14 calls to Moose::Role::with, avg 10.2ms/call, recursion: max depth 2, sum of overlapping time 40.5ms # spent 1.57ms making 15 calls to Moose::Role::has, avg 105µs/call # spent 642µs making 20 calls to Moose::Role::requires, avg 32µs/call # spent 296µs making 1 call to Moose::override # spent 210µs making 7 calls to Moose::Role::around, avg 30µs/call # spent 97µs making 3 calls to Moose::Role::override, avg 32µs/call # spent 59µs making 2 calls to Moose::Role::before, avg 30µs/call
420 | 504 | 909µs |  |  | };
421 |  |  |  |  |
422 | 504 | 156µs |  |  | if ( my $proto = prototype $sub ) {
423 |  |  |  |  |
424 |  |  |  |  | # XXX - Perl's prototype sucks. Use & to make set_prototype
425 |  |  |  |  | # ignore the fact that we're passing "private variables"
426 |  |  |  |  | &Scalar::Util::set_prototype( $wrapper, $proto );
427 |  |  |  |  | }
428 | 504 | 1.02ms |  |  | return $wrapper;
429 |  |  |  |  | }
430 |  |  |  |  |
431 |  |  |  |  | # spent 22µs within Moose::Exporter::_make_import_sub which was called 3 times, avg 7µs/call: # 3 times (22µs+0s) by Moose::Exporter::build_import_methods at line 62, avg 7µs/call sub _make_import_sub {
432 | 3 | 500ns |  |  | shift;
433 | 3 | 900ns |  |  | my $exporting_package = shift;
434 | 3 | 600ns |  |  | my $exporter = shift;
435 | 3 | 600ns |  |  | my $exports_from = shift;
436 | 3 | 600ns |  |  | my $is_reexport = shift;
437 | 3 | 700ns |  |  | my $meta_lookup = shift;
438 |  |  |  |  |
439 |  |  |  |  | return sub {
440 |  |  |  |  |
441 |  |  |  |  | # I think we could use Sub::Exporter's collector feature
442 |  |  |  |  | # to do this, but that would be rather gross, since that
443 |  |  |  |  | # feature isn't really designed to return a value to the
444 |  |  |  |  | # caller of the exporter sub.
445 |  |  |  |  | #
446 |  |  |  |  | # Also, this makes sure we preserve backwards compat for
447 |  |  |  |  | # _get_caller, so it always sees the arguments in the
448 |  |  |  |  | # expected order.
449 | 67 | 16µs |  |  | my $traits;
450 | 67 | 213µs | 67 | 978µs | ( $traits, @_ ) = _strip_traits(@_); # spent 978µs making 67 calls to Moose::Exporter::_strip_traits, avg 15µs/call
451 |  |  |  |  |
452 | 67 | 13µs |  |  | my $metaclass;
453 | 67 | 160µs | 67 | 521µs | ( $metaclass, @_ ) = _strip_metaclass(@_); # spent 521µs making 67 calls to Moose::Exporter::_strip_metaclass, avg 8µs/call
454 | 67 | 25µs |  |  | $metaclass
455 |  |  |  |  | = Moose::Util::resolve_metaclass_alias( 'Class' => $metaclass )
456 |  |  |  |  | if defined $metaclass && length $metaclass;
457 |  |  |  |  |
458 | 67 | 16µs |  |  | my $meta_name;
459 | 67 | 175µs | 67 | 505µs | ( $meta_name, @_ ) = _strip_meta_name(@_); # spent 505µs making 67 calls to Moose::Exporter::_strip_meta_name, avg 8µs/call
460 |  |  |  |  |
461 |  |  |  |  | # Normally we could look at $_[0], but in some weird cases
462 |  |  |  |  | # (involving goto &Moose::import), $_[0] ends as something
463 |  |  |  |  | # else (like Squirrel).
464 | 67 | 26µs |  |  | my $class = $exporting_package;
465 |  |  |  |  |
466 | 67 | 117µs | 67 | 207µs | $CALLER = _get_caller(@_); # spent 207µs making 67 calls to Moose::Exporter::_get_caller, avg 3µs/call
467 |  |  |  |  |
468 |  |  |  |  | # this works because both pragmas set $^H (see perldoc
469 |  |  |  |  | # perlvar) which affects the current compilation -
470 |  |  |  |  | # i.e. the file who use'd us - which is why we don't need
471 |  |  |  |  | # to do anything special to make it affect that file
472 |  |  |  |  | # rather than this one (which is already compiled)
473 |  |  |  |  |
474 | 67 | 133µs | 67 | 744µs | strict->import; # spent 744µs making 67 calls to strict::import, avg 11µs/call
475 | 67 | 131µs | 67 | 413µs | warnings->import; # spent 413µs making 67 calls to warnings::import, avg 6µs/call
476 |  |  |  |  |
477 | 67 | 9µs |  |  | my $did_init_meta;
478 | 134 | 471µs | 67 | 142µs | for my $c ( grep { $_->can('init_meta') } $class, @{$exports_from} ) { # spent 142µs making 67 calls to UNIVERSAL::can, avg 2µs/call
479 |  |  |  |  |
480 |  |  |  |  | # init_meta can apply a role, which when loaded uses
481 |  |  |  |  | # Moose::Exporter, which in turn sets $CALLER, so we need
482 |  |  |  |  | # to protect against that.
483 | 63 | 26µs |  |  | local $CALLER = $CALLER;
484 | 63 | 100µs | 63 | 121ms | $c->init_meta( # spent 74.3ms making 28 calls to Moose::init_meta, avg 2.65ms/call # spent 46.9ms making 35 calls to Moose::Role::init_meta, avg 1.34ms/call
485 |  |  |  |  | for_class => $CALLER,
486 |  |  |  |  | metaclass => $metaclass,
487 |  |  |  |  | meta_name => $meta_name,
488 |  |  |  |  | );
489 | 63 | 80µs |  |  | $did_init_meta = 1;
490 |  |  |  |  | }
491 |  |  |  |  |
492 |  |  |  |  | {
493 |  |  |  |  | # The metaroles will use Moose::Role, which in turn uses
494 |  |  |  |  | # Moose::Exporter, which in turn sets $CALLER, so we need
495 |  |  |  |  | # to protect against that.
496 | 134 | 66µs |  |  | local $CALLER = $CALLER;
497 | 67 | 144µs | 67 | 2.27ms | _apply_metaroles( # spent 2.27ms making 67 calls to Moose::Exporter::_apply_metaroles, avg 34µs/call
498 |  |  |  |  | $CALLER,
499 |  |  |  |  | [$class, @$exports_from],
500 |  |  |  |  | $meta_lookup
501 |  |  |  |  | );
502 |  |  |  |  | }
503 |  |  |  |  |
504 | 67 | 70µs |  |  | if ( $did_init_meta && @{$traits} ) {
505 |  |  |  |  |
506 |  |  |  |  | # The traits will use Moose::Role, which in turn uses
507 |  |  |  |  | # Moose::Exporter, which in turn sets $CALLER, so we need
508 |  |  |  |  | # to protect against that.
509 |  |  |  |  | local $CALLER = $CALLER;
510 |  |  |  |  | _apply_meta_traits( $CALLER, $traits, $meta_lookup );
511 |  |  |  |  | }
512 |  |  |  |  | elsif ( @{$traits} ) {
513 |  |  |  |  | throw_exception( ClassDoesNotHaveInitMeta => class_name => $class,
514 |  |  |  |  | traits => $traits
515 |  |  |  |  | );
516 |  |  |  |  | }
517 |  |  |  |  |
518 | 67 | 61µs |  |  | my ( undef, @args ) = @_;
519 | 67 | 33µs |  |  | my $extra = shift @args if ref $args[0] eq 'HASH';
520 |  |  |  |  |
521 | 67 | 19µs |  |  | $extra ||= {};
522 | 67 | 55µs |  |  | if ( !$extra->{into} ) {
523 | 67 | 56µs |  |  | $extra->{into_level} ||= 0;
524 | 67 | 31µs |  |  | $extra->{into_level}++;
525 |  |  |  |  | }
526 |  |  |  |  |
527 | 67 | 424µs | 67 | 92.0ms | $class->$exporter( $extra, @args ); # spent 92.0ms making 67 calls to Sub::Exporter::__ANON__[Sub/Exporter.pm:337], avg 1.37ms/call
528 | 3 | 19µs |  |  | };
529 |  |  |  |  | }
530 |  |  |  |  |
531 |  |  |  |  | # spent 978µs (701+277) within Moose::Exporter::_strip_traits which was called 67 times, avg 15µs/call: # 67 times (701µs+277µs) by Moose::Role::import or Moose::Util::TypeConstraints::import or Moose::import at line 450, avg 15µs/call sub _strip_traits {
532 | 134 | 765µs | 67 | 277µs | my $idx = first_index { ( $_ || '' ) eq '-traits' } @_; # spent 277µs making 67 calls to List::MoreUtils::firstidx, avg 4µs/call
533 |  |  |  |  |
534 | 67 | 250µs |  |  | return ( [], @_ ) unless $idx >= 0 && $#_ >= $idx + 1;
535 |  |  |  |  |
536 |  |  |  |  | my $traits = $_[ $idx + 1 ];
537 |  |  |  |  |
538 |  |  |  |  | splice @_, $idx, 2;
539 |  |  |  |  |
540 |  |  |  |  | $traits = [$traits] unless ref $traits;
541 |  |  |  |  |
542 |  |  |  |  | return ( $traits, @_ );
543 |  |  |  |  | }
544 |  |  |  |  |
545 |  |  |  |  | # spent 521µs (422+99) within Moose::Exporter::_strip_metaclass which was called 67 times, avg 8µs/call: # 67 times (422µs+99µs) by Moose::Role::import or Moose::Util::TypeConstraints::import or Moose::import at line 453, avg 8µs/call sub _strip_metaclass {
546 | 134 | 380µs | 67 | 99µs | my $idx = first_index { ( $_ || '' ) eq '-metaclass' } @_; # spent 99µs making 67 calls to List::MoreUtils::firstidx, avg 1µs/call
547 |  |  |  |  |
548 | 67 | 5.42ms |  |  | return ( undef, @_ ) unless $idx >= 0 && $#_ >= $idx + 1;
549 |  |  |  |  |
550 |  |  |  |  | my $metaclass = $_[ $idx + 1 ];
551 |  |  |  |  |
552 |  |  |  |  | splice @_, $idx, 2;
553 |  |  |  |  |
554 |  |  |  |  | return ( $metaclass, @_ );
555 |  |  |  |  | }
556 |  |  |  |  |
557 |  |  |  |  | # spent 505µs (422+83) within Moose::Exporter::_strip_meta_name which was called 67 times, avg 8µs/call: # 67 times (422µs+83µs) by Moose::Role::import or Moose::Util::TypeConstraints::import or Moose::import at line 459, avg 8µs/call sub _strip_meta_name {
558 | 134 | 359µs | 67 | 83µs | my $idx = first_index { ( $_ || '' ) eq '-meta_name' } @_; # spent 83µs making 67 calls to List::MoreUtils::firstidx, avg 1µs/call
559 |  |  |  |  |
560 | 67 | 191µs |  |  | return ( 'meta', @_ ) unless $idx >= 0 && $#_ >= $idx + 1;
561 |  |  |  |  |
562 |  |  |  |  | my $meta_name = $_[ $idx + 1 ];
563 |  |  |  |  |
564 |  |  |  |  | splice @_, $idx, 2;
565 |  |  |  |  |
566 |  |  |  |  | return ( $meta_name, @_ );
567 |  |  |  |  | }
568 |  |  |  |  |
569 |  |  |  |  | # spent 2.27ms (703µs+1.57) within Moose::Exporter::_apply_metaroles which was called 67 times, avg 34µs/call: # 67 times (703µs+1.57ms) by Moose::Role::import or Moose::Util::TypeConstraints::import or Moose::import at line 497, avg 34µs/call sub _apply_metaroles {
570 | 67 | 32µs |  |  | my ($class, $exports_from, $meta_lookup) = @_;
571 |  |  |  |  |
572 | 67 | 109µs | 67 | 1.01ms | my $metaroles = _collect_metaroles($exports_from); # spent 1.01ms making 67 calls to Moose::Exporter::_collect_metaroles, avg 15µs/call
573 | 67 | 36µs |  |  | my $base_class_roles = delete $metaroles->{base_class_roles};
574 |  |  |  |  |
575 | 67 | 113µs | 67 | 470µs | my $meta = $meta_lookup->($class); # spent 470µs making 67 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:39], avg 7µs/call
576 |  |  |  |  | # for instance, Moose.pm uses Moose::Util::TypeConstraints
577 | 67 | 27µs |  |  | return unless $meta;
578 |  |  |  |  |
579 | 65 | 38µs |  |  | Moose::Util::MetaRole::apply_metaroles(
580 |  |  |  |  | for => $meta,
581 |  |  |  |  | %$metaroles,
582 |  |  |  |  | ) if keys %$metaroles;
583 |  |  |  |  |
584 | 65 | 363µs | 65 | 87µs | Moose::Util::MetaRole::apply_base_class_roles( # spent 87µs making 65 calls to UNIVERSAL::isa, avg 1µs/call
585 |  |  |  |  | for => $meta,
586 |  |  |  |  | roles => $base_class_roles,
587 |  |  |  |  | ) if $meta->isa('Class::MOP::Class')
588 |  |  |  |  | && $base_class_roles && @$base_class_roles;
589 |  |  |  |  | }
590 |  |  |  |  |
591 |  |  |  |  | # spent 1.01ms within Moose::Exporter::_collect_metaroles which was called 67 times, avg 15µs/call: # 67 times (1.01ms+0s) by Moose::Exporter::_apply_metaroles at line 572, avg 15µs/call sub _collect_metaroles {
592 | 67 | 16µs |  |  | my ($exports_from) = @_;
593 |  |  |  |  |
594 | 67 | 264µs |  |  | my @old_style_role_types = map { "${_}_roles" } qw(
595 |  |  |  |  | metaclass
596 |  |  |  |  | attribute_metaclass
597 |  |  |  |  | method_metaclass
598 |  |  |  |  | wrapped_method_metaclass
599 |  |  |  |  | instance_metaclass
600 |  |  |  |  | constructor_class
601 |  |  |  |  | destructor_class
602 |  |  |  |  | error_class
603 |  |  |  |  | );
604 |  |  |  |  |
605 | 67 | 17µs |  |  | my %class_metaroles;
606 | 67 | 12µs |  |  | my %role_metaroles;
607 | 67 | 11µs |  |  | my @base_class_roles;
608 | 67 | 12µs |  |  | my %old_style_roles;
609 |  |  |  |  |
610 | 67 | 64µs |  |  | for my $exporter (@$exports_from) {
611 | 67 | 56µs |  |  | my $data = $EXPORT_SPEC{$exporter};
612 |  |  |  |  |
613 | 67 | 42µs |  |  | if (exists $data->{class_metaroles}) {
614 |  |  |  |  | for my $type (keys %{ $data->{class_metaroles} }) {
615 |  |  |  |  | push @{ $class_metaroles{$type} ||= [] },
616 |  |  |  |  | @{ $data->{class_metaroles}{$type} };
617 |  |  |  |  | }
618 |  |  |  |  | }
619 |  |  |  |  |
620 | 67 | 38µs |  |  | if (exists $data->{role_metaroles}) {
621 |  |  |  |  | for my $type (keys %{ $data->{role_metaroles} }) {
622 |  |  |  |  | push @{ $role_metaroles{$type} ||= [] },
623 |  |  |  |  | @{ $data->{role_metaroles}{$type} };
624 |  |  |  |  | }
625 |  |  |  |  | }
626 |  |  |  |  |
627 | 67 | 26µs |  |  | if (exists $data->{base_class_roles}) {
628 |  |  |  |  | push @base_class_roles, @{ $data->{base_class_roles} };
629 |  |  |  |  | }
630 |  |  |  |  |
631 | 67 | 65µs |  |  | for my $type (@old_style_role_types) {
632 | 536 | 187µs |  |  | if (exists $data->{$type}) {
633 |  |  |  |  | push @{ $old_style_roles{$type} ||= [] },
634 |  |  |  |  | @{ $data->{$type} };
635 |  |  |  |  | }
636 |  |  |  |  | }
637 |  |  |  |  | }
638 |  |  |  |  |
639 |  |  |  |  | return {
640 | 67 | 271µs |  |  | (keys(%class_metaroles)
641 |  |  |  |  | ? (class_metaroles => \%class_metaroles)
642 |  |  |  |  | : ()),
643 |  |  |  |  | (keys(%role_metaroles)
644 |  |  |  |  | ? (role_metaroles => \%role_metaroles)
645 |  |  |  |  | : ()),
646 |  |  |  |  | (@base_class_roles
647 |  |  |  |  | ? (base_class_roles => \@base_class_roles)
648 |  |  |  |  | : ()),
649 |  |  |  |  | %old_style_roles,
650 |  |  |  |  | };
651 |  |  |  |  | }
652 |  |  |  |  |
653 |  |  |  |  | sub _apply_meta_traits {
654 |  |  |  |  | my ( $class, $traits, $meta_lookup ) = @_;
655 |  |  |  |  |
656 |  |  |  |  | return unless @{$traits};
657 |  |  |  |  |
658 |  |  |  |  | my $meta = $meta_lookup->($class);
659 |  |  |  |  |
660 |  |  |  |  | my $type = $meta->isa('Moose::Meta::Role') ? 'Role'
661 |  |  |  |  | : $meta->isa('Class::MOP::Class') ? 'Class'
662 |  |  |  |  | : confess('Cannot determine metaclass type for '
663 |  |  |  |  | . 'trait application. Meta isa '
664 |  |  |  |  | . ref $meta);
665 |  |  |  |  |
666 |  |  |  |  | my @resolved_traits = map {
667 |  |  |  |  | ref $_
668 |  |  |  |  | ? $_
669 |  |  |  |  | : Moose::Util::resolve_metatrait_alias( $type => $_ )
670 |  |  |  |  | } @$traits;
671 |  |  |  |  |
672 |  |  |  |  | return unless @resolved_traits;
673 |  |  |  |  |
674 |  |  |  |  | my %args = ( for => $class );
675 |  |  |  |  |
676 |  |  |  |  | if ( $meta->isa('Moose::Meta::Role') ) {
677 |  |  |  |  | $args{role_metaroles} = { role => \@resolved_traits };
678 |  |  |  |  | }
679 |  |  |  |  | else {
680 |  |  |  |  | $args{class_metaroles} = { class => \@resolved_traits };
681 |  |  |  |  | }
682 |  |  |  |  |
683 |  |  |  |  | Moose::Util::MetaRole::apply_metaroles(%args);
684 |  |  |  |  | }
685 |  |  |  |  |
686 |  |  |  |  | # spent 207µs within Moose::Exporter::_get_caller which was called 67 times, avg 3µs/call: # 67 times (207µs+0s) by Moose::Role::import or Moose::Util::TypeConstraints::import or Moose::import at line 466, avg 3µs/call sub _get_caller {
687 |  |  |  |  |
688 |  |  |  |  | # 1 extra level because it's called by import so there's a layer
689 |  |  |  |  | # of indirection
690 | 67 | 26µs |  |  | my $offset = 1;
691 |  |  |  |  |
692 |  |  |  |  | return
693 | 67 | 231µs |  |  | ( ref $_[1] && defined $_[1]->{into} ) ? $_[1]->{into}
694 |  |  |  |  | : ( ref $_[1] && defined $_[1]->{into_level} )
695 |  |  |  |  | ? caller( $offset + $_[1]->{into_level} )
696 |  |  |  |  | : caller($offset);
697 |  |  |  |  | }
698 |  |  |  |  |
699 |  |  |  |  | # spent 14µs within Moose::Exporter::_make_unimport_sub which was called 3 times, avg 5µs/call: # 3 times (14µs+0s) by Moose::Exporter::build_import_methods at line 70, avg 5µs/call sub _make_unimport_sub {
700 | 3 | 600ns |  |  | shift;
701 | 3 | 1µs |  |  | my $exporting_package = shift;
702 | 3 | 700ns |  |  | my $exports = shift;
703 | 3 | 600ns |  |  | my $export_recorder = shift;
704 | 3 | 600ns |  |  | my $is_reexport = shift;
705 | 3 | 500ns |  |  | my $meta_lookup = shift;
706 |  |  |  |  |
707 |  |  |  |  | return sub {
708 | 62 | 54µs |  |  | my $caller = scalar caller();
709 |  |  |  |  | Moose::Exporter->_remove_keywords(
710 |  |  |  |  | $caller,
711 | 62 | 541µs | 62 | 4.27ms | [ keys %{$exports} ], # spent 4.27ms making 62 calls to Moose::Exporter::_remove_keywords, avg 69µs/call
712 |  |  |  |  | $export_recorder,
713 |  |  |  |  | $is_reexport,
714 |  |  |  |  | );
715 | 3 | 12µs |  |  | };
716 |  |  |  |  | }
717 |  |  |  |  |
718 |  |  |  |  | # spent 4.27ms (4.16+111µs) within Moose::Exporter::_remove_keywords which was called 62 times, avg 69µs/call: # 62 times (4.16ms+111µs) by Moose::Role::unimport or Moose::Util::TypeConstraints::unimport or Moose::unimport at line 711, avg 69µs/call sub _remove_keywords {
719 | 62 | 12µs |  |  | shift;
720 | 62 | 18µs |  |  | my $package = shift;
721 | 62 | 19µs |  |  | my $keywords = shift;
722 | 62 | 11µs |  |  | my $recorded_exports = shift;
723 | 62 | 12µs |  |  | my $is_reexport = shift;
724 |  |  |  |  |
725 | 2 | 53µs | 2 | 26µs | # spent 17µs (8+9) within Moose::Exporter::BEGIN@725 which was called: # once (8µs+9µs) by Moose::BEGIN@15 at line 725 no strict 'refs'; # spent 17µs making 1 call to Moose::Exporter::BEGIN@725 # spent 9µs making 1 call to strict::unimport
726 |  |  |  |  |
727 | 62 | 215µs |  |  | foreach my $name ( @{$keywords} ) {
728 | 816 | 906µs |  |  | if ( defined &{ $package . '::' . $name } ) {
729 | 816 | 603µs |  |  | my $sub = \&{ $package . '::' . $name };
730 |  |  |  |  |
731 |  |  |  |  | # make sure it is from us
732 | 816 | 348µs |  |  | next unless $recorded_exports->{$sub};
733 |  |  |  |  |
734 | 816 | 124µs |  |  | if ( $is_reexport->{$name} ) {
735 | 2 | 249µs | 2 | 20µs | # spent 13µs (6+7) within Moose::Exporter::BEGIN@735 which was called: # once (6µs+7µs) by Moose::BEGIN@15 at line 735 no strict 'refs'; # spent 13µs making 1 call to Moose::Exporter::BEGIN@735 # spent 7µs making 1 call to strict::unimport
736 |  |  |  |  | next
737 |  |  |  |  | unless _export_is_flagged(
738 | 122 | 578µs | 122 | 111µs | \*{ join q{::} => $package, $name } ); # spent 111µs making 122 calls to Moose::Exporter::_export_is_flagged, avg 908ns/call
739 |  |  |  |  | }
740 |  |  |  |  |
741 |  |  |  |  | # and if it is from us, then undef the slot
742 | 814 | 1.49ms |  |  | delete ${ $package . '::' }{$name};
743 |  |  |  |  | }
744 |  |  |  |  | }
745 |  |  |  |  | }
746 |  |  |  |  |
747 |  |  |  |  | # maintain this for now for backcompat
748 |  |  |  |  | # make sure to return a sub to install in the same circumstances as previously
749 |  |  |  |  | # but this functionality now happens at the end of ->import
750 |  |  |  |  | # spent 40µs within Moose::Exporter::_make_init_meta which was called 3 times, avg 13µs/call: # 3 times (40µs+0s) by Moose::Exporter::build_import_methods at line 78, avg 13µs/call sub _make_init_meta {
751 | 3 | 300ns |  |  | shift;
752 | 3 | 800ns |  |  | my $class = shift;
753 | 3 | 700ns |  |  | my $args = shift;
754 | 3 | 500ns |  |  | my $meta_lookup = shift;
755 |  |  |  |  |
756 | 3 | 2µs |  |  | my %old_style_roles;
757 | 3 | 13µs |  |  | for my $role (
758 |  |  |  |  | map {"${_}_roles"}
759 |  |  |  |  | qw(
760 |  |  |  |  | metaclass
761 |  |  |  |  | attribute_metaclass
762 |  |  |  |  | method_metaclass
763 |  |  |  |  | wrapped_method_metaclass
764 |  |  |  |  | instance_metaclass
765 |  |  |  |  | constructor_class
766 |  |  |  |  | destructor_class
767 |  |  |  |  | error_class
768 |  |  |  |  | )
769 |  |  |  |  | ) {
770 | 24 | 8µs |  |  | $old_style_roles{$role} = $args->{$role}
771 |  |  |  |  | if exists $args->{$role};
772 |  |  |  |  | }
773 |  |  |  |  |
774 | 3 | 500ns |  |  | my %base_class_roles;
775 | 3 | 2µs |  |  | %base_class_roles = ( roles => $args->{base_class_roles} )
776 |  |  |  |  | if exists $args->{base_class_roles};
777 |  |  |  |  |
778 |  |  |  |  | my %new_style_roles = map { $_ => $args->{$_} }
779 | 3 | 6µs |  |  | grep { exists $args->{$_} } qw( class_metaroles role_metaroles );
780 |  |  |  |  |
781 | 3 | 10µs |  |  | return unless %new_style_roles || %old_style_roles || %base_class_roles;
782 |  |  |  |  |
783 |  |  |  |  | return sub {
784 |  |  |  |  | shift;
785 |  |  |  |  | my %opts = @_;
786 |  |  |  |  | $meta_lookup->($opts{for_class});
787 |  |  |  |  | };
788 |  |  |  |  | }
789 |  |  |  |  |
790 |  |  |  |  | # spent 89µs (37+52) within Moose::Exporter::import which was called 3 times, avg 30µs/call: # once (21µs+28µs) by Moose::BEGIN@15 at line 15 of Moose.pm # once (7µs+14µs) by Moose::Role::BEGIN@16 at line 16 of Moose/Role.pm # once (9µs+10µs) by Moose::Util::TypeConstraints::BEGIN@6 at line 6 of Moose/Util/TypeConstraints.pm sub import {
791 | 3 | 4µs | 3 | 26µs | strict->import; # spent 26µs making 3 calls to strict::import, avg 9µs/call
792 | 3 | 13µs | 3 | 26µs | warnings->import; # spent 26µs making 3 calls to warnings::import, avg 9µs/call
793 |  |  |  |  | }
794 |  |  |  |  |
795 | 1 | 3µs |  |  | 1;
796 |  |  |  |  |
797 |  |  |  |  | # ABSTRACT: make an import() and unimport() just like Moose.pm
798 |  |  |  |  |
799 |  |  |  |  | __END__
|  |  |  |  | # spent 26µs within Moose::Exporter::CORE:match which was called 28 times, avg 936ns/call: # 28 times (26µs+0s) by Moose::Exporter::_make_sub_exporter_params at line 287, avg 936ns/call sub Moose::Exporter::CORE:match; # opcode
|  |  |  |  | # spent 111µs within Moose::Exporter::_export_is_flagged which was called 122 times, avg 908ns/call: # 122 times (111µs+0s) by Moose::Exporter::_remove_keywords at line 738, avg 908ns/call sub Moose::Exporter::_export_is_flagged; # xsub
|  |  |  |  | # spent 111µs within Moose::Exporter::_flag_as_reexport which was called 124 times, avg 895ns/call: # 124 times (111µs+0s) by Moose::Exporter::__ANON__[/usr/local/lib/perl/5.18.2/Moose/Exporter.pm:140] at line 138, avg 895ns/call sub Moose::Exporter::_flag_as_reexport; # xsub