| Filename | /home/doy/coding/src/Moose/blib/lib//Moose/Exporter.pm |
| Statements | Executed 15830 statements in 163ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 66 | 1 | 1 | 37.8ms | 303ms | Moose::Exporter::__ANON__[:125] |
| 480 | 1 | 1 | 26.8ms | 51.6ms | Moose::Exporter::__ANON__[:329] |
| 1 | 1 | 1 | 23.6ms | 421ms | Moose::Exporter::BEGIN@11 |
| 480 | 1 | 1 | 18.2ms | 18.2ms | Moose::Exporter::_late_curry_wrapper |
| 66 | 66 | 62 | 16.1ms | 1.10s | Moose::Exporter::__ANON__[:456] |
| 15 | 1 | 1 | 10.0ms | 10.2ms | Moose::Exporter::_remove_keywords |
| 175 | 1 | 1 | 3.99ms | 10.5ms | Moose::Exporter::__ANON__[:321] |
| 1 | 1 | 1 | 3.62ms | 4.67ms | Moose::Exporter::BEGIN@13 |
| 412 | 1 | 1 | 3.53ms | 3.53ms | Moose::Exporter::__ANON__[:259] |
| 66 | 1 | 1 | 2.87ms | 4.06ms | Moose::Exporter::_strip_traits |
| 66 | 1 | 1 | 2.41ms | 3.16ms | Moose::Exporter::_strip_metaclass |
| 66 | 1 | 1 | 2.11ms | 2.85ms | Moose::Exporter::_strip_meta_name |
| 3 | 1 | 1 | 2.01ms | 3.61ms | Moose::Exporter::_make_sub_exporter_params |
| 39 | 2 | 1 | 1.09ms | 1.09ms | Moose::Exporter::_sub_from_package |
| 66 | 1 | 1 | 1.04ms | 1.04ms | Moose::Exporter::_get_caller |
| 3 | 1 | 1 | 921µs | 14.1ms | Moose::Exporter::build_import_methods |
| 118 | 1 | 1 | 846µs | 846µs | Moose::Exporter::_flag_as_reexport (xsub) |
| 15 | 15 | 14 | 771µs | 11.0ms | Moose::Exporter::__ANON__[:557] |
| 16 | 1 | 1 | 401µs | 401µs | Moose::Exporter::_make_wrapped_sub_with_meta |
| 3 | 1 | 1 | 277µs | 277µs | Moose::Exporter::_make_init_meta |
| 28 | 1 | 1 | 188µs | 188µs | Moose::Exporter::_export_is_flagged (xsub) |
| 3 | 1 | 1 | 188µs | 301µs | Moose::Exporter::_follow_also |
| 3 | 3 | 3 | 171µs | 14.3ms | Moose::Exporter::setup_import_methods |
| 3 | 1 | 1 | 159µs | 7.23ms | Moose::Exporter::_make_exporter |
| 3 | 1 | 1 | 156µs | 156µs | Moose::Exporter::_make_import_sub |
| 3 | 3 | 3 | 154µs | 453µs | Moose::Exporter::import |
| 3 | 1 | 1 | 88µs | 88µs | Moose::Exporter::_make_unimport_sub |
| 3 | 1 | 1 | 78µs | 78µs | Moose::Exporter::_parse_trait_aliases |
| 1 | 1 | 1 | 68µs | 772µs | Moose::Exporter::BEGIN@15 |
| 1 | 1 | 1 | 63µs | 138µs | Moose::Exporter::BEGIN@120 |
| 1 | 1 | 1 | 62µs | 79µs | Moose::Exporter::BEGIN@3 |
| 3 | 1 | 1 | 62µs | 62µs | Moose::Exporter::_follow_also_real |
| 1 | 1 | 1 | 47µs | 123µs | Moose::Exporter::BEGIN@567 |
| 1 | 1 | 1 | 45µs | 120µs | Moose::Exporter::BEGIN@272 |
| 1 | 1 | 1 | 44µs | 220µs | Moose::Exporter::BEGIN@14 |
| 1 | 1 | 1 | 44µs | 241µs | Moose::Exporter::BEGIN@12 |
| 1 | 1 | 1 | 41µs | 198µs | Moose::Exporter::BEGIN@16 |
| 1 | 1 | 1 | 39µs | 106µs | Moose::Exporter::BEGIN@4 |
| 1 | 1 | 1 | 39µs | 104µs | Moose::Exporter::BEGIN@121 |
| 1 | 1 | 1 | 36µs | 90µs | Moose::Exporter::BEGIN@577 |
| 1 | 1 | 1 | 23µs | 23µs | Moose::Exporter::BEGIN@18 |
| 0 | 0 | 0 | 0s | 0s | Moose::Exporter::__ANON__[:189] |
| 0 | 0 | 0 | 0s | 0s | Moose::Exporter::__ANON__[:307] |
| 0 | 0 | 0 | 0s | 0s | Moose::Exporter::__ANON__[:338] |
| 0 | 0 | 0 | 0s | 0s | Moose::Exporter::__ANON__[:360] |
| 0 | 0 | 0 | 0s | 0s | Moose::Exporter::__ANON__[:460] |
| 0 | 0 | 0 | 0s | 0s | Moose::Exporter::__ANON__[:474] |
| 0 | 0 | 0 | 0s | 0s | Moose::Exporter::__ANON__[:486] |
| 0 | 0 | 0 | 0s | 0s | Moose::Exporter::__ANON__[:643] |
| 0 | 0 | 0 | 0s | 0s | Moose::Exporter::_apply_meta_traits |
| 0 | 0 | 0 | 0s | 0s | Moose::Exporter::_curry_wrapper |
| 0 | 0 | 0 | 0s | 0s | Moose::Exporter::_make_wrapped_sub |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Moose::Exporter; | ||||
| 2 | |||||
| 3 | 3 | 97µs | 2 | 96µs | # spent 79µs (62+17) within Moose::Exporter::BEGIN@3 which was called:
# once (62µs+17µs) by Moose::BEGIN@15 at line 3 # spent 79µs making 1 call to Moose::Exporter::BEGIN@3
# spent 17µs making 1 call to strict::import |
| 4 | 3 | 252µs | 2 | 173µs | # spent 106µs (39+67) within Moose::Exporter::BEGIN@4 which was called:
# once (39µs+67µs) by Moose::BEGIN@15 at line 4 # spent 106µs making 1 call to Moose::Exporter::BEGIN@4
# spent 67µs making 1 call to warnings::import |
| 5 | |||||
| 6 | 1 | 5µs | our $VERSION = '1.19'; | ||
| 7 | 1 | 3µs | our $XS_VERSION = $VERSION; | ||
| 8 | 1 | 70µs | $VERSION = eval $VERSION; # spent 44µs executing statements in string eval | ||
| 9 | 1 | 3µs | our $AUTHORITY = 'cpan:STEVAN'; | ||
| 10 | |||||
| 11 | 3 | 492µs | 1 | 421ms | # spent 421ms (23.6+398) within Moose::Exporter::BEGIN@11 which was called:
# once (23.6ms+398ms) by Moose::BEGIN@15 at line 11 # spent 421ms making 1 call to Moose::Exporter::BEGIN@11 |
| 12 | 3 | 106µs | 2 | 438µs | # spent 241µs (44+197) within Moose::Exporter::BEGIN@12 which was called:
# once (44µs+197µs) by Moose::BEGIN@15 at line 12 # spent 241µs making 1 call to Moose::Exporter::BEGIN@12
# spent 197µs making 1 call to Exporter::import |
| 13 | 3 | 762µs | 1 | 4.67ms | # spent 4.67ms (3.62+1.05) within Moose::Exporter::BEGIN@13 which was called:
# once (3.62ms+1.05ms) by Moose::BEGIN@15 at line 13 # spent 4.67ms making 1 call to Moose::Exporter::BEGIN@13 |
| 14 | 3 | 110µs | 2 | 396µs | # spent 220µs (44+176) within Moose::Exporter::BEGIN@14 which was called:
# once (44µs+176µs) by Moose::BEGIN@15 at line 14 # spent 220µs making 1 call to Moose::Exporter::BEGIN@14
# spent 176µs making 1 call to Exporter::import |
| 15 | 3 | 229µs | 3 | 1.48ms | # spent 772µs (68+704) within Moose::Exporter::BEGIN@15 which was called:
# once (68µs+704µs) by Moose::BEGIN@15 at line 15 # spent 772µs making 1 call to Moose::Exporter::BEGIN@15
# spent 646µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756]
# spent 58µs making 1 call to UNIVERSAL::VERSION |
| 16 | 3 | 101µs | 2 | 354µs | # spent 198µs (41+156) within Moose::Exporter::BEGIN@16 which was called:
# once (41µs+156µs) by Moose::BEGIN@15 at line 16 # spent 198µs making 1 call to Moose::Exporter::BEGIN@16
# spent 156µs making 1 call to Exporter::import |
| 17 | |||||
| 18 | 3 | 1.45ms | 1 | 23µs | # spent 23µs within Moose::Exporter::BEGIN@18 which was called:
# once (23µs+0s) by Moose::BEGIN@15 at line 18 # spent 23µs making 1 call to Moose::Exporter::BEGIN@18 |
| 19 | |||||
| 20 | 1 | 234µs | 1 | 204µs | XSLoader::load( 'Moose', $XS_VERSION ); # spent 204µs making 1 call to XSLoader::load |
| 21 | |||||
| 22 | 1 | 2µs | my %EXPORT_SPEC; | ||
| 23 | |||||
| 24 | # spent 14.3ms (171µs+14.1) within Moose::Exporter::setup_import_methods which was called 3 times, avg 4.76ms/call:
# once (61µs+5.28ms) by Moose::Meta::Attribute::BEGIN@20 at line 42 of Moose/Util/TypeConstraints.pm
# once (53µs+4.62ms) by KiokuDB::Backend::BEGIN@4 at line 88 of Moose/Role.pm
# once (57µs+4.21ms) by KiokuDB::BEGIN@4 at line 122 of Moose.pm | ||||
| 25 | 3 | 33µs | my ( $class, %args ) = @_; | ||
| 26 | |||||
| 27 | 3 | 26µs | my $exporting_package = $args{exporting_package} ||= caller(); | ||
| 28 | |||||
| 29 | 3 | 116µs | 3 | 14.1ms | $class->build_import_methods( # spent 14.1ms making 3 calls to Moose::Exporter::build_import_methods, avg 4.70ms/call |
| 30 | %args, | ||||
| 31 | install => [qw(import unimport init_meta)] | ||||
| 32 | ); | ||||
| 33 | } | ||||
| 34 | |||||
| 35 | # spent 14.1ms (921µs+13.2) within Moose::Exporter::build_import_methods which was called 3 times, avg 4.70ms/call:
# 3 times (921µs+13.2ms) by Moose::Exporter::setup_import_methods at line 29, avg 4.70ms/call | ||||
| 36 | 3 | 28µs | my ( $class, %args ) = @_; | ||
| 37 | |||||
| 38 | 3 | 11µs | my $exporting_package = $args{exporting_package} ||= caller(); | ||
| 39 | |||||
| 40 | 3 | 16µs | $EXPORT_SPEC{$exporting_package} = \%args; | ||
| 41 | |||||
| 42 | 3 | 41µs | 3 | 301µs | my @exports_from = $class->_follow_also($exporting_package); # spent 301µs making 3 calls to Moose::Exporter::_follow_also, avg 100µs/call |
| 43 | |||||
| 44 | 3 | 12µs | my $export_recorder = {}; | ||
| 45 | 3 | 8µs | my $is_reexport = {}; | ||
| 46 | |||||
| 47 | 3 | 52µs | 3 | 3.61ms | my $exports = $class->_make_sub_exporter_params( # spent 3.61ms making 3 calls to Moose::Exporter::_make_sub_exporter_params, avg 1.20ms/call |
| 48 | [ @exports_from, $exporting_package ], | ||||
| 49 | $export_recorder, | ||||
| 50 | $is_reexport, | ||||
| 51 | ); | ||||
| 52 | |||||
| 53 | 3 | 48µs | 3 | 7.23ms | my $exporter = $class->_make_exporter($exports, $is_reexport); # spent 7.23ms making 3 calls to Moose::Exporter::_make_exporter, avg 2.41ms/call |
| 54 | |||||
| 55 | 3 | 6µs | my %methods; | ||
| 56 | 3 | 60µs | 3 | 156µs | $methods{import} = $class->_make_import_sub( # spent 156µs making 3 calls to Moose::Exporter::_make_import_sub, avg 52µs/call |
| 57 | $exporting_package, | ||||
| 58 | $exporter, | ||||
| 59 | \@exports_from, | ||||
| 60 | $is_reexport | ||||
| 61 | ); | ||||
| 62 | |||||
| 63 | 3 | 49µs | 3 | 88µs | $methods{unimport} = $class->_make_unimport_sub( # spent 88µs making 3 calls to Moose::Exporter::_make_unimport_sub, avg 29µs/call |
| 64 | $exporting_package, | ||||
| 65 | $exports, | ||||
| 66 | $export_recorder, | ||||
| 67 | $is_reexport | ||||
| 68 | ); | ||||
| 69 | |||||
| 70 | 3 | 45µs | 3 | 277µs | $methods{init_meta} = $class->_make_init_meta( # spent 277µs making 3 calls to Moose::Exporter::_make_init_meta, avg 92µs/call |
| 71 | $exporting_package, | ||||
| 72 | \%args | ||||
| 73 | ); | ||||
| 74 | |||||
| 75 | 3 | 50µs | 3 | 509µs | my $package = Class::MOP::Package->initialize($exporting_package); # spent 509µs making 3 calls to Class::MOP::Package::initialize, avg 170µs/call |
| 76 | 3 | 36µs | for my $to_install ( @{ $args{install} || [] } ) { | ||
| 77 | 9 | 34µs | my $symbol = '&' . $to_install; | ||
| 78 | next | ||||
| 79 | 9 | 94µs | 6 | 535µs | unless $methods{$to_install} # spent 535µs making 6 calls to Class::MOP::Package::has_package_symbol, avg 89µs/call |
| 80 | && !$package->has_package_symbol($symbol); | ||||
| 81 | 6 | 90µs | 6 | 485µs | $package->add_package_symbol( $symbol, $methods{$to_install} ); # spent 485µs making 6 calls to Class::MOP::Package::add_package_symbol, avg 81µs/call |
| 82 | } | ||||
| 83 | |||||
| 84 | 3 | 77µs | return ( $methods{import}, $methods{unimport}, $methods{init_meta} ); | ||
| 85 | } | ||||
| 86 | |||||
| 87 | # spent 7.23ms (159µs+7.07) within Moose::Exporter::_make_exporter which was called 3 times, avg 2.41ms/call:
# 3 times (159µs+7.07ms) by Moose::Exporter::build_import_methods at line 53, avg 2.41ms/call | ||||
| 88 | 3 | 14µs | my ($class, $exports, $is_reexport) = @_; | ||
| 89 | |||||
| 90 | return Sub::Exporter::build_exporter( | ||||
| 91 | { | ||||
| 92 | exports => $exports, | ||||
| 93 | groups => { default => [':all'] }, | ||||
| 94 | # spent 303ms (37.8+265) within Moose::Exporter::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Exporter.pm:125] which was called 66 times, avg 4.58ms/call:
# 66 times (37.8ms+265ms) by Sub::Exporter::_do_import at line 799 of Sub/Exporter.pm, avg 4.58ms/call | ||||
| 95 | 66 | 268µs | my ($arg, $to_export) = @_; | ||
| 96 | 66 | 882µs | 66 | 2.56ms | my $meta = Class::MOP::class_of($arg->{into}); # spent 2.56ms making 66 calls to Class::MOP::class_of, avg 39µs/call |
| 97 | |||||
| 98 | 66 | 194µs | 2 | 7.84ms | goto &Sub::Exporter::default_installer unless $meta; # spent 7.84ms making 2 calls to Sub::Exporter::default_installer, avg 3.92ms/call |
| 99 | |||||
| 100 | # don't overwrite existing symbols with our magically flagged | ||||
| 101 | # version of it if we would install the same sub that's already | ||||
| 102 | # in the importer | ||||
| 103 | |||||
| 104 | 64 | 132µs | my @filtered_to_export; | ||
| 105 | 64 | 120µs | my %installed; | ||
| 106 | 64 | 4.76ms | for (my $i = 0; $i < @{ $to_export }; $i += 2) { | ||
| 107 | 858 | 4.14ms | my ($as, $cv) = @{ $to_export }[$i, $i + 1]; | ||
| 108 | |||||
| 109 | 858 | 11.3ms | 860 | 52.6ms | next if !ref($as) # spent 52.5ms making 858 calls to Class::MOP::Package::has_package_symbol, avg 61µs/call
# spent 118µs making 2 calls to Class::MOP::Package::get_package_symbol, avg 59µs/call |
| 110 | && $meta->has_package_symbol('&' . $as) | ||||
| 111 | && $meta->get_package_symbol('&' . $as) == $cv; | ||||
| 112 | |||||
| 113 | 856 | 3.37ms | push @filtered_to_export, $as, $cv; | ||
| 114 | 856 | 4.88ms | $installed{$as} = 1 unless ref $as; | ||
| 115 | 64 | 166µs | } | ||
| 116 | |||||
| 117 | 64 | 825µs | 64 | 209ms | Sub::Exporter::default_installer($arg, \@filtered_to_export); # spent 209ms making 64 calls to Sub::Exporter::default_installer, avg 3.26ms/call |
| 118 | |||||
| 119 | 64 | 1.98ms | for my $name ( keys %{$is_reexport} ) { | ||
| 120 | 3 | 113µs | 2 | 213µs | # spent 138µs (63+75) within Moose::Exporter::BEGIN@120 which was called:
# once (63µs+75µs) by Moose::BEGIN@15 at line 120 # spent 138µs making 1 call to Moose::Exporter::BEGIN@120
# spent 75µs making 1 call to strict::unimport |
| 121 | 3 | 2.50ms | 2 | 169µs | # spent 104µs (39+65) within Moose::Exporter::BEGIN@121 which was called:
# once (39µs+65µs) by Moose::BEGIN@15 at line 121 # spent 104µs making 1 call to Moose::Exporter::BEGIN@121
# spent 65µs making 1 call to warnings::unimport |
| 122 | 120 | 413µs | next unless exists $installed{$name}; | ||
| 123 | 118 | 3.74ms | 118 | 846µs | _flag_as_reexport( \*{ join q{::}, $arg->{into}, $name } ); # spent 846µs making 118 calls to Moose::Exporter::_flag_as_reexport, avg 7µs/call |
| 124 | } | ||||
| 125 | }, | ||||
| 126 | } | ||||
| 127 | 3 | 146µs | 3 | 7.07ms | ); # spent 7.07ms making 3 calls to Sub::Exporter::build_exporter, avg 2.36ms/call |
| 128 | } | ||||
| 129 | |||||
| 130 | { | ||||
| 131 | 2 | 9µs | my $seen = {}; | ||
| 132 | |||||
| 133 | # spent 301µs (188+113) within Moose::Exporter::_follow_also which was called 3 times, avg 100µs/call:
# 3 times (188µs+113µs) by Moose::Exporter::build_import_methods at line 42, avg 100µs/call | ||||
| 134 | 3 | 13µs | my $class = shift; | ||
| 135 | 3 | 9µs | my $exporting_package = shift; | ||
| 136 | |||||
| 137 | 3 | 25µs | local %$seen = ( $exporting_package => 1 ); | ||
| 138 | |||||
| 139 | 3 | 154µs | 6 | 113µs | return uniq( _follow_also_real($exporting_package) ); # spent 62µs making 3 calls to Moose::Exporter::_follow_also_real, avg 21µs/call
# spent 51µs making 3 calls to List::MoreUtils::uniq, avg 17µs/call |
| 140 | } | ||||
| 141 | |||||
| 142 | # spent 62µs within Moose::Exporter::_follow_also_real which was called 3 times, avg 21µs/call:
# 3 times (62µs+0s) by Moose::Exporter::_follow_also at line 139, avg 21µs/call | ||||
| 143 | 3 | 10µs | my $exporting_package = shift; | ||
| 144 | |||||
| 145 | 3 | 12µs | if ( !exists $EXPORT_SPEC{$exporting_package} ) { | ||
| 146 | my $loaded = Class::MOP::is_class_loaded($exporting_package); | ||||
| 147 | |||||
| 148 | die "Package in also ($exporting_package) does not seem to " | ||||
| 149 | . "use Moose::Exporter" | ||||
| 150 | . ( $loaded ? "" : " (is it loaded?)" ); | ||||
| 151 | } | ||||
| 152 | |||||
| 153 | 3 | 12µs | my $also = $EXPORT_SPEC{$exporting_package}{also}; | ||
| 154 | |||||
| 155 | 3 | 76µs | return unless defined $also; | ||
| 156 | |||||
| 157 | my @also = ref $also ? @{$also} : $also; | ||||
| 158 | |||||
| 159 | for my $package (@also) { | ||||
| 160 | die | ||||
| 161 | "Circular reference in 'also' parameter to Moose::Exporter between $exporting_package and $package" | ||||
| 162 | if $seen->{$package}; | ||||
| 163 | |||||
| 164 | $seen->{$package} = 1; | ||||
| 165 | } | ||||
| 166 | |||||
| 167 | return @also, map { _follow_also_real($_) } @also; | ||||
| 168 | } | ||||
| 169 | } | ||||
| 170 | |||||
| 171 | # spent 78µs within Moose::Exporter::_parse_trait_aliases which was called 3 times, avg 26µs/call:
# 3 times (78µs+0s) by Moose::Exporter::_make_sub_exporter_params at line 233, avg 26µs/call | ||||
| 172 | 3 | 11µs | my $class = shift; | ||
| 173 | 3 | 18µs | my ($package, $aliases) = @_; | ||
| 174 | |||||
| 175 | 3 | 5µs | my @ret; | ||
| 176 | 3 | 18µs | for my $alias (@$aliases) { | ||
| 177 | my $name; | ||||
| 178 | if (ref($alias)) { | ||||
| 179 | reftype($alias) eq 'ARRAY' | ||||
| 180 | or Moose->throw_error(reftype($alias) . " references are not " | ||||
| 181 | . "valid arguments to the 'trait_aliases' " | ||||
| 182 | . "option"); | ||||
| 183 | |||||
| 184 | ($alias, $name) = @$alias; | ||||
| 185 | } | ||||
| 186 | else { | ||||
| 187 | ($name = $alias) =~ s/.*:://; | ||||
| 188 | } | ||||
| 189 | push @ret, subname "${package}::${name}" => sub () { $alias }; | ||||
| 190 | } | ||||
| 191 | |||||
| 192 | 3 | 44µs | return @ret; | ||
| 193 | } | ||||
| 194 | |||||
| 195 | # spent 3.61ms (2.01+1.60) within Moose::Exporter::_make_sub_exporter_params which was called 3 times, avg 1.20ms/call:
# 3 times (2.01ms+1.60ms) by Moose::Exporter::build_import_methods at line 47, avg 1.20ms/call | ||||
| 196 | 3 | 10µs | my $class = shift; | ||
| 197 | 3 | 8µs | my $packages = shift; | ||
| 198 | 3 | 6µs | my $export_recorder = shift; | ||
| 199 | 3 | 7µs | my $is_reexport = shift; | ||
| 200 | |||||
| 201 | 3 | 6µs | my %exports; | ||
| 202 | |||||
| 203 | 3 | 21µs | for my $package ( @{$packages} ) { | ||
| 204 | 3 | 10µs | my $args = $EXPORT_SPEC{$package} | ||
| 205 | or die "The $package package does not use Moose::Exporter\n"; | ||||
| 206 | |||||
| 207 | 3 | 21µs | for my $name ( @{ $args->{with_meta} } ) { | ||
| 208 | 16 | 173µs | 16 | 430µs | my $sub = $class->_sub_from_package( $package, $name ) # spent 430µs making 16 calls to Moose::Exporter::_sub_from_package, avg 27µs/call |
| 209 | or next; | ||||
| 210 | |||||
| 211 | 16 | 56µs | my $fq_name = $package . '::' . $name; | ||
| 212 | |||||
| 213 | 16 | 254µs | 16 | 401µs | $exports{$name} = $class->_make_wrapped_sub_with_meta( # spent 401µs making 16 calls to Moose::Exporter::_make_wrapped_sub_with_meta, avg 25µs/call |
| 214 | $fq_name, | ||||
| 215 | $sub, | ||||
| 216 | $export_recorder, | ||||
| 217 | ); | ||||
| 218 | } | ||||
| 219 | |||||
| 220 | 3 | 24µs | for my $name ( @{ $args->{with_caller} } ) { | ||
| 221 | my $sub = $class->_sub_from_package( $package, $name ) | ||||
| 222 | or next; | ||||
| 223 | |||||
| 224 | my $fq_name = $package . '::' . $name; | ||||
| 225 | |||||
| 226 | $exports{$name} = $class->_make_wrapped_sub( | ||||
| 227 | $fq_name, | ||||
| 228 | $sub, | ||||
| 229 | $export_recorder, | ||||
| 230 | ); | ||||
| 231 | } | ||||
| 232 | |||||
| 233 | 3 | 53µs | 3 | 78µs | my @extra_exports = $class->_parse_trait_aliases( # spent 78µs making 3 calls to Moose::Exporter::_parse_trait_aliases, avg 26µs/call |
| 234 | $package, $args->{trait_aliases}, | ||||
| 235 | ); | ||||
| 236 | 3 | 34µs | for my $name ( @{ $args->{as_is} }, @extra_exports ) { | ||
| 237 | 27 | 53µs | my ( $sub, $coderef_name ); | ||
| 238 | |||||
| 239 | 27 | 102µs | if ( ref $name ) { | ||
| 240 | 4 | 8µs | $sub = $name; | ||
| 241 | |||||
| 242 | 4 | 7µs | my $coderef_pkg; | ||
| 243 | 4 | 106µs | 4 | 36µs | ( $coderef_pkg, $coderef_name ) # spent 36µs making 4 calls to Class::MOP::get_code_info, avg 9µs/call |
| 244 | = Class::MOP::get_code_info($name); | ||||
| 245 | |||||
| 246 | 4 | 24µs | if ( $coderef_pkg ne $package ) { | ||
| 247 | $is_reexport->{$coderef_name} = 1; | ||||
| 248 | } | ||||
| 249 | } | ||||
| 250 | else { | ||||
| 251 | 23 | 267µs | 23 | 656µs | $sub = $class->_sub_from_package( $package, $name ) # spent 656µs making 23 calls to Moose::Exporter::_sub_from_package, avg 29µs/call |
| 252 | or next; | ||||
| 253 | |||||
| 254 | 23 | 66µs | $coderef_name = $name; | ||
| 255 | } | ||||
| 256 | |||||
| 257 | 27 | 149µs | $export_recorder->{$sub} = 1; | ||
| 258 | |||||
| 259 | 439 | 4.99ms | # spent 3.53ms within Moose::Exporter::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Exporter.pm:259] which was called 412 times, avg 9µs/call:
# 412 times (3.53ms+0s) by Sub::Exporter::default_generator at line 856 of Sub/Exporter.pm, avg 9µs/call | ||
| 260 | } | ||||
| 261 | } | ||||
| 262 | |||||
| 263 | 3 | 54µs | return \%exports; | ||
| 264 | } | ||||
| 265 | |||||
| 266 | sub _sub_from_package { | ||||
| 267 | 39 | 107µs | my $sclass = shift; | ||
| 268 | 39 | 85µs | my $package = shift; | ||
| 269 | 39 | 85µs | my $name = shift; | ||
| 270 | |||||
| 271 | 39 | 162µs | my $sub = do { | ||
| 272 | 3 | 5.23ms | 2 | 195µs | # spent 120µs (45+75) within Moose::Exporter::BEGIN@272 which was called:
# once (45µs+75µs) by Moose::BEGIN@15 at line 272 # spent 120µs making 1 call to Moose::Exporter::BEGIN@272
# spent 75µs making 1 call to strict::unimport |
| 273 | 39 | 299µs | \&{ $package . '::' . $name }; | ||
| 274 | }; | ||||
| 275 | |||||
| 276 | 39 | 476µs | return $sub if defined &$sub; | ||
| 277 | |||||
| 278 | Carp::cluck "Trying to export undefined sub ${package}::${name}"; | ||||
| 279 | |||||
| 280 | return; | ||||
| 281 | } | ||||
| 282 | |||||
| 283 | 1 | 2µs | our $CALLER; | ||
| 284 | |||||
| 285 | sub _make_wrapped_sub { | ||||
| 286 | my $self = shift; | ||||
| 287 | my $fq_name = shift; | ||||
| 288 | my $sub = shift; | ||||
| 289 | my $export_recorder = shift; | ||||
| 290 | |||||
| 291 | # We need to set the package at import time, so that when | ||||
| 292 | # package Foo imports has(), we capture "Foo" as the | ||||
| 293 | # package. This lets other packages call Foo::has() and get | ||||
| 294 | # the right package. This is done for backwards compatibility | ||||
| 295 | # with existing production code, not because this is a good | ||||
| 296 | # idea ;) | ||||
| 297 | return sub { | ||||
| 298 | my $caller = $CALLER; | ||||
| 299 | |||||
| 300 | my $wrapper = $self->_curry_wrapper( $sub, $fq_name, $caller ); | ||||
| 301 | |||||
| 302 | my $sub = subname( $fq_name => $wrapper ); | ||||
| 303 | |||||
| 304 | $export_recorder->{$sub} = 1; | ||||
| 305 | |||||
| 306 | return $sub; | ||||
| 307 | }; | ||||
| 308 | } | ||||
| 309 | |||||
| 310 | # spent 401µs within Moose::Exporter::_make_wrapped_sub_with_meta which was called 16 times, avg 25µs/call:
# 16 times (401µs+0s) by Moose::Exporter::_make_sub_exporter_params at line 213, avg 25µs/call | ||||
| 311 | 16 | 53µs | my $self = shift; | ||
| 312 | 16 | 48µs | my $fq_name = shift; | ||
| 313 | 16 | 35µs | my $sub = shift; | ||
| 314 | 16 | 31µs | my $export_recorder = shift; | ||
| 315 | |||||
| 316 | # spent 51.6ms (26.8+24.8) within Moose::Exporter::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Exporter.pm:329] which was called 480 times, avg 107µs/call:
# 480 times (26.8ms+24.8ms) by Sub::Exporter::default_generator at line 856 of Sub/Exporter.pm, avg 107µs/call | ||||
| 317 | 480 | 1.48ms | my $caller = $CALLER; | ||
| 318 | |||||
| 319 | my $wrapper = $self->_late_curry_wrapper( | ||||
| 320 | $sub, $fq_name, | ||||
| 321 | 655 | 13.0ms | 655 | 24.8ms | # spent 10.5ms (3.99+6.55) within Moose::Exporter::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Exporter.pm:321] which was called 175 times, avg 60µs/call:
# 175 times (3.99ms+6.55ms) by Moose::Role::after or 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::before or Moose::extends or Moose::has or Moose::with at line 358, avg 60µs/call # spent 18.2ms making 480 calls to Moose::Exporter::_late_curry_wrapper, avg 38µs/call
# spent 6.55ms making 175 calls to Class::MOP::class_of, avg 37µs/call |
| 322 | ); | ||||
| 323 | |||||
| 324 | 480 | 12.1ms | 480 | 6.52ms | my $sub = subname( $fq_name => $wrapper ); # spent 6.52ms making 480 calls to Sub::Name::subname, avg 14µs/call |
| 325 | |||||
| 326 | 480 | 3.40ms | $export_recorder->{$sub} = 1; | ||
| 327 | |||||
| 328 | 480 | 5.83ms | return $sub; | ||
| 329 | 16 | 288µs | }; | ||
| 330 | } | ||||
| 331 | |||||
| 332 | sub _curry_wrapper { | ||||
| 333 | my $class = shift; | ||||
| 334 | my $sub = shift; | ||||
| 335 | my $fq_name = shift; | ||||
| 336 | my @extra = @_; | ||||
| 337 | |||||
| 338 | my $wrapper = sub { $sub->( @extra, @_ ) }; | ||||
| 339 | if ( my $proto = prototype $sub ) { | ||||
| 340 | |||||
| 341 | # XXX - Perl's prototype sucks. Use & to make set_prototype | ||||
| 342 | # ignore the fact that we're passing "private variables" | ||||
| 343 | &Scalar::Util::set_prototype( $wrapper, $proto ); | ||||
| 344 | } | ||||
| 345 | return $wrapper; | ||||
| 346 | } | ||||
| 347 | |||||
| 348 | # spent 18.2ms within Moose::Exporter::_late_curry_wrapper which was called 480 times, avg 38µs/call:
# 480 times (18.2ms+0s) by Moose::Exporter::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Exporter.pm:329] at line 321, avg 38µs/call | ||||
| 349 | 480 | 1.45ms | my $class = shift; | ||
| 350 | 480 | 1.17ms | my $sub = shift; | ||
| 351 | 480 | 1.12ms | my $fq_name = shift; | ||
| 352 | 480 | 988µs | my $extra = shift; | ||
| 353 | 480 | 2.42ms | my @ex_args = @_; | ||
| 354 | |||||
| 355 | my $wrapper = sub { | ||||
| 356 | |||||
| 357 | # resolve curried arguments at runtime via this closure | ||||
| 358 | 175 | 2.55ms | 175 | 10.5ms | my @curry = ( $extra->(@ex_args) ); # spent 10.5ms making 175 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:321], avg 60µs/call |
| 359 | 175 | 5.04ms | 175 | 3.87s | return $sub->( @curry, @_ ); # spent 2.33s making 108 calls to Moose::has, avg 21.6ms/call
# spent 950ms making 13 calls to Moose::with, avg 73.1ms/call, recursion: max depth 1, sum of overlapping time 26.4ms
# spent 788ms making 18 calls to Moose::Role::with, avg 43.8ms/call, recursion: max depth 2, sum of overlapping time 194ms
# spent 11.2ms making 15 calls to Moose::Role::requires, avg 747µs/call
# spent 5.53ms making 1 call to Moose::extends
# spent 4.23ms making 7 calls to Moose::Role::has, avg 604µs/call
# spent 1.56ms making 1 call to Moose::before
# spent 1.32ms making 6 calls to Moose::Role::around, avg 221µs/call
# spent 760µs making 3 calls to Moose::Role::override, avg 253µs/call
# spent 448µs making 2 calls to Moose::Role::before, avg 224µs/call
# spent 224µs making 1 call to Moose::Role::after |
| 360 | 480 | 5.45ms | }; | ||
| 361 | |||||
| 362 | 480 | 1.33ms | if ( my $proto = prototype $sub ) { | ||
| 363 | |||||
| 364 | # XXX - Perl's prototype sucks. Use & to make set_prototype | ||||
| 365 | # ignore the fact that we're passing "private variables" | ||||
| 366 | &Scalar::Util::set_prototype( $wrapper, $proto ); | ||||
| 367 | } | ||||
| 368 | 480 | 6.66ms | return $wrapper; | ||
| 369 | } | ||||
| 370 | |||||
| 371 | # spent 156µs within Moose::Exporter::_make_import_sub which was called 3 times, avg 52µs/call:
# 3 times (156µs+0s) by Moose::Exporter::build_import_methods at line 56, avg 52µs/call | ||||
| 372 | 3 | 9µs | shift; | ||
| 373 | 3 | 13µs | my $exporting_package = shift; | ||
| 374 | 3 | 8µs | my $exporter = shift; | ||
| 375 | 3 | 7µs | my $exports_from = shift; | ||
| 376 | 3 | 7µs | my $is_reexport = shift; | ||
| 377 | |||||
| 378 | # spent 1.10s (16.1ms+1.09) within Moose::Exporter::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Exporter.pm:456] which was called 66 times, avg 16.7ms/call:
# once (397µs+27.4ms) by KiokuDB::TypeMap::BEGIN@4 at line 4 of KiokuDB/TypeMap.pm
# once (546µs+24.7ms) by KiokuDB::Reference::BEGIN@4 at line 4 of KiokuDB/Reference.pm
# once (244µs+24.7ms) by KiokuDB::BEGIN@4 at line 4 of KiokuDB.pm
# once (253µs+23.5ms) by KiokuDB::Error::MissingObjects::BEGIN@2 at line 2 of KiokuDB/Error/MissingObjects.pm
# once (236µs+22.1ms) by KiokuDB::Entry::Skip::BEGIN@4 at line 4 of KiokuDB/Entry/Skip.pm
# once (229µs+21.9ms) by KiokuDB::Stream::Objects::BEGIN@4 at line 4 of KiokuDB/Stream/Objects.pm
# once (262µs+21.6ms) by KiokuDB::LiveObjects::BEGIN@4 at line 4 of KiokuDB/LiveObjects.pm
# once (230µs+21.6ms) by KiokuDB::TypeMap::Shadow::BEGIN@4 at line 4 of KiokuDB/TypeMap/Shadow.pm
# once (241µs+21.5ms) by Data::Visitor::BEGIN@4 at line 4 of Data/Visitor.pm
# once (229µs+21.4ms) by KiokuDB::TypeMap::Entry::Alias::BEGIN@4 at line 4 of KiokuDB/TypeMap/Entry/Alias.pm
# once (229µs+21.3ms) by KiokuDB::LiveObjects::Scope::BEGIN@4 at line 4 of KiokuDB/LiveObjects/Scope.pm
# once (228µs+21.3ms) by KiokuDB::Error::UnknownObjects::BEGIN@2 at line 2 of KiokuDB/Error/UnknownObjects.pm
# once (240µs+21.3ms) by KiokuDB::Thunk::BEGIN@4 at line 4 of KiokuDB/Thunk.pm
# once (254µs+21.2ms) by KiokuDB::Linker::BEGIN@4 at line 4 of KiokuDB/Linker.pm
# once (247µs+21.2ms) by Devel::PartialDump::BEGIN@4 at line 4 of Devel/PartialDump.pm
# once (230µs+21.2ms) by KiokuDB::TypeMap::Entry::Compiled::BEGIN@2 at line 2 of KiokuDB/TypeMap/Entry/Compiled.pm
# once (229µs+21.2ms) by KiokuDB::TypeMap::Resolver::BEGIN@4 at line 4 of KiokuDB/TypeMap/Resolver.pm
# once (230µs+21.1ms) by KiokuDB::LiveObjects::TXNScope::BEGIN@4 at line 4 of KiokuDB/LiveObjects/TXNScope.pm
# once (231µs+21.1ms) by KiokuDB::Collapser::Buffer::BEGIN@2 at line 2 of KiokuDB/Collapser/Buffer.pm
# once (246µs+21.0ms) by Data::Stream::Bulk::Cat::BEGIN@10 at line 10 of Data/Stream/Bulk/Cat.pm
# once (229µs+21.0ms) by KiokuDB::TypeMap::Entry::MOP::BEGIN@4 at line 4 of KiokuDB/TypeMap/Entry/MOP.pm
# once (228µs+21.0ms) by Data::Stream::Bulk::Filter::BEGIN@10 at line 10 of Data/Stream/Bulk/Filter.pm
# once (228µs+20.9ms) by Data::Stream::Bulk::Nil::BEGIN@10 at line 10 of Data/Stream/Bulk/Nil.pm
# once (226µs+20.7ms) by KiokuDB::Entry::BEGIN@4 at line 4 of KiokuDB/Entry.pm
# once (227µs+20.6ms) by KiokuDB::Collapser::BEGIN@4 at line 4 of KiokuDB/Collapser.pm
# once (234µs+18.6ms) by Moose::Meta::Method::Accessor::Native::Hash::values::BEGIN@12 at line 12 of Moose/Meta/Method/Accessor/Native/Hash/values.pm
# once (346µs+18.0ms) by Moose::Meta::Method::Accessor::Native::Writer::BEGIN@12 at line 12 of Moose/Meta/Method/Accessor/Native/Writer.pm
# once (311µs+14.6ms) by KiokuDB::TypeMap::Entry::BEGIN@4 at line 4 of KiokuDB/TypeMap/Entry.pm
# once (235µs+14.4ms) by Moose::Meta::Attribute::Native::Trait::Hash::BEGIN@3 at line 3 of Moose/Meta/Attribute/Native/Trait/Hash.pm
# once (233µs+14.3ms) by MooseX::Clone::Meta::Attribute::Trait::Clone::BEGIN@4 at line 4 of MooseX/Clone/Meta/Attribute/Trait/Clone.pm
# once (246µs+14.2ms) by KiokuDB::Backend::BEGIN@4 at line 4 of KiokuDB/Backend.pm
# once (251µs+14.1ms) by KiokuDB::Error::BEGIN@2 at line 2 of KiokuDB/Error.pm
# once (229µs+13.9ms) by Moose::Meta::Attribute::Native::Trait::Array::BEGIN@3 at line 3 of Moose/Meta/Attribute/Native/Trait/Array.pm
# once (332µs+13.7ms) by Data::Stream::Bulk::BEGIN@10 at line 10 of Data/Stream/Bulk.pm
# once (227µs+13.7ms) by MooseX::Clone::Meta::Attribute::Trait::Clone::Base::BEGIN@4 at line 4 of MooseX/Clone/Meta/Attribute/Trait/Clone/Base.pm
# once (301µs+13.6ms) by Moose::Meta::Method::Accessor::Native::Array::BEGIN@6 at line 6 of Moose/Meta/Method/Accessor/Native/Array.pm
# once (236µs+13.7ms) by KiokuDB::TypeMap::Entry::Std::Compile::BEGIN@2 at line 2 of KiokuDB/TypeMap/Entry/Std/Compile.pm
# once (231µs+13.7ms) by KiokuDB::TypeMap::Entry::Std::Intrinsic::BEGIN@2 at line 2 of KiokuDB/TypeMap/Entry/Std/Intrinsic.pm
# once (271µs+13.6ms) by KiokuDB::TypeMap::Entry::Std::Expand::BEGIN@2 at line 2 of KiokuDB/TypeMap/Entry/Std/Expand.pm
# once (226µs+13.6ms) by Moose::Meta::Method::Accessor::Native::Array::push::BEGIN@10 at line 10 of Moose/Meta/Method/Accessor/Native/Array/push.pm
# once (234µs+13.6ms) by KiokuDB::Role::UUIDs::BEGIN@4 at line 4 of KiokuDB/Role/UUIDs.pm
# once (237µs+13.5ms) by KiokuDB::TypeMap::Entry::Std::BEGIN@4 at line 4 of KiokuDB/TypeMap/Entry/Std.pm
# once (223µs+13.6ms) by Moose::Meta::Method::Accessor::Native::Array::Writer::BEGIN@10 at line 10 of Moose/Meta/Method/Accessor/Native/Array/Writer.pm
# once (224µs+13.5ms) by Moose::Meta::Method::Accessor::Native::Array::clear::BEGIN@10 at line 10 of Moose/Meta/Method/Accessor/Native/Array/clear.pm
# once (236µs+13.5ms) by KiokuDB::Role::API::BEGIN@2 at line 2 of KiokuDB/Role/API.pm
# once (228µs+13.5ms) by KiokuDB::TypeMap::Entry::Std::ID::BEGIN@2 at line 2 of KiokuDB/TypeMap/Entry/Std/ID.pm
# once (231µs+13.5ms) by KiokuDB::Role::TypeMap::BEGIN@4 at line 4 of KiokuDB/Role/TypeMap.pm
# once (226µs+13.5ms) by Moose::Meta::Method::Accessor::Native::Array::elements::BEGIN@10 at line 10 of Moose/Meta/Method/Accessor/Native/Array/elements.pm
# once (225µs+13.4ms) by Moose::Meta::Method::Accessor::Native::Collection::BEGIN@10 at line 10 of Moose/Meta/Method/Accessor/Native/Collection.pm
# once (230µs+13.4ms) by MooseX::Clone::Meta::Attribute::Trait::NoClone::BEGIN@4 at line 4 of MooseX/Clone/Meta/Attribute/Trait/NoClone.pm
# once (224µs+13.4ms) by Moose::Meta::Method::Accessor::Native::Reader::BEGIN@10 at line 10 of Moose/Meta/Method/Accessor/Native/Reader.pm
# once (227µs+13.4ms) by MooseX::Clone::Meta::Attribute::Trait::Copy::BEGIN@4 at line 4 of MooseX/Clone/Meta/Attribute/Trait/Copy.pm
# once (227µs+13.4ms) by Throwable::BEGIN@5 at line 5 of Throwable.pm
# once (230µs+13.4ms) by MooseX::Clone::Meta::Attribute::Trait::StrableClone::BEGIN@4 at line 4 of MooseX/Clone/Meta/Attribute/Trait/StorableClone.pm
# once (227µs+13.4ms) by KiokuDB::Role::UUIDs::LibUUID::BEGIN@4 at line 4 of KiokuDB/Role/UUIDs/LibUUID.pm
# once (237µs+13.4ms) by MooseX::Clone::Meta::Attribute::Trait::Clone::Std::BEGIN@2 at line 2 of MooseX/Clone/Meta/Attribute/Trait/Clone/Std.pm
# once (241µs+13.3ms) by Moose::Meta::Method::Accessor::Native::Hash::keys::BEGIN@12 at line 12 of Moose/Meta/Method/Accessor/Native/Hash/keys.pm
# once (233µs+13.3ms) by MooseX::Clone::BEGIN@4 at line 4 of MooseX/Clone.pm
# once (227µs+13.3ms) by Moose::Meta::Attribute::Native::Trait::BEGIN@3 at line 3 of Moose/Meta/Attribute/Native/Trait.pm
# once (224µs+13.0ms) by Moose::Meta::Method::Accessor::Native::BEGIN@13 at line 13 of Moose/Meta/Method/Accessor/Native.pm
# once (199µs+9.67ms) by KiokuDB::LiveObjects::BEGIN@16 at line 16 of KiokuDB/LiveObjects.pm
# once (205µs+9.63ms) by KiokuDB::Entry::BEGIN@6 at line 6 of KiokuDB/Entry.pm
# once (206µs+9.60ms) by Moose::Meta::Attribute::Native::Trait::BEGIN@6 at line 6 of Moose/Meta/Attribute/Native/Trait.pm
# once (216µs+9.47ms) by KiokuDB::Backend::BEGIN@6 at line 6 of KiokuDB/Backend.pm
# once (256µs+8.01ms) by Moose::BEGIN@35 at line 35 of Moose.pm
# once (193µs+7.90ms) by Moose::Role::BEGIN@19 at line 19 of Moose/Role.pm | ||||
| 379 | |||||
| 380 | # I think we could use Sub::Exporter's collector feature | ||||
| 381 | # to do this, but that would be rather gross, since that | ||||
| 382 | # feature isn't really designed to return a value to the | ||||
| 383 | # caller of the exporter sub. | ||||
| 384 | # | ||||
| 385 | # Also, this makes sure we preserve backwards compat for | ||||
| 386 | # _get_caller, so it always sees the arguments in the | ||||
| 387 | # expected order. | ||||
| 388 | 66 | 145µs | my $traits; | ||
| 389 | 66 | 1.13ms | 66 | 4.06ms | ( $traits, @_ ) = _strip_traits(@_); # spent 4.06ms making 66 calls to Moose::Exporter::_strip_traits, avg 62µs/call |
| 390 | |||||
| 391 | 66 | 141µs | my $metaclass; | ||
| 392 | 66 | 1.01ms | 66 | 3.16ms | ( $metaclass, @_ ) = _strip_metaclass(@_); # spent 3.16ms making 66 calls to Moose::Exporter::_strip_metaclass, avg 48µs/call |
| 393 | 66 | 164µs | $metaclass | ||
| 394 | = Moose::Util::resolve_metaclass_alias( 'Class' => $metaclass ) | ||||
| 395 | if defined $metaclass && length $metaclass; | ||||
| 396 | |||||
| 397 | 66 | 123µs | my $meta_name; | ||
| 398 | 66 | 1.05ms | 66 | 2.85ms | ( $meta_name, @_ ) = _strip_meta_name(@_); # spent 2.85ms making 66 calls to Moose::Exporter::_strip_meta_name, avg 43µs/call |
| 399 | |||||
| 400 | # Normally we could look at $_[0], but in some weird cases | ||||
| 401 | # (involving goto &Moose::import), $_[0] ends as something | ||||
| 402 | # else (like Squirrel). | ||||
| 403 | 66 | 232µs | my $class = $exporting_package; | ||
| 404 | |||||
| 405 | 66 | 819µs | 66 | 1.04ms | $CALLER = _get_caller(@_); # spent 1.04ms making 66 calls to Moose::Exporter::_get_caller, avg 16µs/call |
| 406 | |||||
| 407 | # this works because both pragmas set $^H (see perldoc | ||||
| 408 | # perlvar) which affects the current compilation - | ||||
| 409 | # i.e. the file who use'd us - which is why we don't need | ||||
| 410 | # to do anything special to make it affect that file | ||||
| 411 | # rather than this one (which is already compiled) | ||||
| 412 | |||||
| 413 | 66 | 872µs | 66 | 1.01ms | strict->import; # spent 1.01ms making 66 calls to strict::import, avg 15µs/call |
| 414 | 66 | 879µs | 66 | 4.29ms | warnings->import; # spent 4.29ms making 66 calls to warnings::import, avg 65µs/call |
| 415 | |||||
| 416 | 66 | 144µs | my $did_init_meta; | ||
| 417 | 132 | 2.83ms | 66 | 844µs | for my $c ( grep { $_->can('init_meta') } $class, @{$exports_from} ) { # spent 844µs making 66 calls to UNIVERSAL::can, avg 13µs/call |
| 418 | |||||
| 419 | # init_meta can apply a role, which when loaded uses | ||||
| 420 | # Moose::Exporter, which in turn sets $CALLER, so we need | ||||
| 421 | # to protect against that. | ||||
| 422 | 60 | 264µs | local $CALLER = $CALLER; | ||
| 423 | 60 | 754µs | 60 | 497ms | $c->init_meta( # spent 339ms making 25 calls to Moose::init_meta, avg 13.5ms/call
# spent 159ms making 35 calls to Moose::Role::init_meta, avg 4.53ms/call |
| 424 | for_class => $CALLER, | ||||
| 425 | metaclass => $metaclass, | ||||
| 426 | meta_name => $meta_name, | ||||
| 427 | ); | ||||
| 428 | 60 | 568µs | $did_init_meta = 1; | ||
| 429 | } | ||||
| 430 | |||||
| 431 | 66 | 258µs | if ( $did_init_meta && @{$traits} ) { | ||
| 432 | |||||
| 433 | # The traits will use Moose::Role, which in turn uses | ||||
| 434 | # Moose::Exporter, which in turn sets $CALLER, so we need | ||||
| 435 | # to protect against that. | ||||
| 436 | local $CALLER = $CALLER; | ||||
| 437 | _apply_meta_traits( $CALLER, $traits ); | ||||
| 438 | } | ||||
| 439 | elsif ( @{$traits} ) { | ||||
| 440 | require Moose; | ||||
| 441 | Moose->throw_error( | ||||
| 442 | "Cannot provide traits when $class does not have an init_meta() method" | ||||
| 443 | ); | ||||
| 444 | } | ||||
| 445 | |||||
| 446 | 66 | 310µs | my ( undef, @args ) = @_; | ||
| 447 | 66 | 224µs | my $extra = shift @args if ref $args[0] eq 'HASH'; | ||
| 448 | |||||
| 449 | 66 | 144µs | $extra ||= {}; | ||
| 450 | 66 | 432µs | if ( !$extra->{into} ) { | ||
| 451 | 66 | 272µs | $extra->{into_level} ||= 0; | ||
| 452 | 66 | 212µs | $extra->{into_level}++; | ||
| 453 | } | ||||
| 454 | |||||
| 455 | 66 | 2.31ms | 66 | 572ms | $class->$exporter( $extra, @args ); # spent 572ms making 66 calls to Sub::Exporter::__ANON__[Sub/Exporter.pm:756], avg 8.67ms/call |
| 456 | 3 | 124µs | }; | ||
| 457 | } | ||||
| 458 | |||||
| 459 | # spent 4.06ms (2.87+1.19) within Moose::Exporter::_strip_traits which was called 66 times, avg 62µs/call:
# 66 times (2.87ms+1.19ms) by Moose::Exporter::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Exporter.pm:456] at line 389, avg 62µs/call | ||||
| 460 | 132 | 3.08ms | 66 | 1.19ms | my $idx = first_index { ( $_ || '' ) eq '-traits' } @_; # spent 1.19ms making 66 calls to List::MoreUtils::firstidx, avg 18µs/call |
| 461 | |||||
| 462 | 66 | 1.23ms | return ( [], @_ ) unless $idx >= 0 && $#_ >= $idx + 1; | ||
| 463 | |||||
| 464 | my $traits = $_[ $idx + 1 ]; | ||||
| 465 | |||||
| 466 | splice @_, $idx, 2; | ||||
| 467 | |||||
| 468 | $traits = [$traits] unless ref $traits; | ||||
| 469 | |||||
| 470 | return ( $traits, @_ ); | ||||
| 471 | } | ||||
| 472 | |||||
| 473 | # spent 3.16ms (2.41+746µs) within Moose::Exporter::_strip_metaclass which was called 66 times, avg 48µs/call:
# 66 times (2.41ms+746µs) by Moose::Exporter::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Exporter.pm:456] at line 392, avg 48µs/call | ||||
| 474 | 132 | 2.33ms | 66 | 746µs | my $idx = first_index { ( $_ || '' ) eq '-metaclass' } @_; # spent 746µs making 66 calls to List::MoreUtils::firstidx, avg 11µs/call |
| 475 | |||||
| 476 | 66 | 1.01ms | return ( undef, @_ ) unless $idx >= 0 && $#_ >= $idx + 1; | ||
| 477 | |||||
| 478 | my $metaclass = $_[ $idx + 1 ]; | ||||
| 479 | |||||
| 480 | splice @_, $idx, 2; | ||||
| 481 | |||||
| 482 | return ( $metaclass, @_ ); | ||||
| 483 | } | ||||
| 484 | |||||
| 485 | # spent 2.85ms (2.11+743µs) within Moose::Exporter::_strip_meta_name which was called 66 times, avg 43µs/call:
# 66 times (2.11ms+743µs) by Moose::Exporter::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Exporter.pm:456] at line 398, avg 43µs/call | ||||
| 486 | 132 | 2.01ms | 66 | 743µs | my $idx = first_index { ( $_ || '' ) eq '-meta_name' } @_; # spent 743µs making 66 calls to List::MoreUtils::firstidx, avg 11µs/call |
| 487 | |||||
| 488 | 66 | 1.05ms | return ( 'meta', @_ ) unless $idx >= 0 && $#_ >= $idx + 1; | ||
| 489 | |||||
| 490 | my $meta_name = $_[ $idx + 1 ]; | ||||
| 491 | |||||
| 492 | splice @_, $idx, 2; | ||||
| 493 | |||||
| 494 | return ( $meta_name, @_ ); | ||||
| 495 | } | ||||
| 496 | |||||
| 497 | sub _apply_meta_traits { | ||||
| 498 | my ( $class, $traits ) = @_; | ||||
| 499 | |||||
| 500 | return unless @{$traits}; | ||||
| 501 | |||||
| 502 | my $meta = Class::MOP::class_of($class); | ||||
| 503 | |||||
| 504 | my $type = ( split /::/, ref $meta )[-1] | ||||
| 505 | or Moose->throw_error( | ||||
| 506 | 'Cannot determine metaclass type for trait application . Meta isa ' | ||||
| 507 | . ref $meta ); | ||||
| 508 | |||||
| 509 | my @resolved_traits = map { | ||||
| 510 | ref $_ | ||||
| 511 | ? $_ | ||||
| 512 | : Moose::Util::resolve_metatrait_alias( $type => $_ ) | ||||
| 513 | } @$traits; | ||||
| 514 | |||||
| 515 | return unless @resolved_traits; | ||||
| 516 | |||||
| 517 | my %args = ( for => $class ); | ||||
| 518 | |||||
| 519 | if ( $meta->isa('Moose::Meta::Role') ) { | ||||
| 520 | $args{role_metaroles} = { role => \@resolved_traits }; | ||||
| 521 | } | ||||
| 522 | else { | ||||
| 523 | $args{class_metaroles} = { class => \@resolved_traits }; | ||||
| 524 | } | ||||
| 525 | |||||
| 526 | Moose::Util::MetaRole::apply_metaroles(%args); | ||||
| 527 | } | ||||
| 528 | |||||
| 529 | # spent 1.04ms within Moose::Exporter::_get_caller which was called 66 times, avg 16µs/call:
# 66 times (1.04ms+0s) by Moose::Exporter::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Exporter.pm:456] at line 405, avg 16µs/call | ||||
| 530 | |||||
| 531 | # 1 extra level because it's called by import so there's a layer | ||||
| 532 | # of indirection | ||||
| 533 | 66 | 151µs | my $offset = 1; | ||
| 534 | |||||
| 535 | return | ||||
| 536 | 66 | 1.38ms | ( ref $_[1] && defined $_[1]->{into} ) ? $_[1]->{into} | ||
| 537 | : ( ref $_[1] && defined $_[1]->{into_level} ) | ||||
| 538 | ? caller( $offset + $_[1]->{into_level} ) | ||||
| 539 | : caller($offset); | ||||
| 540 | } | ||||
| 541 | |||||
| 542 | # spent 88µs within Moose::Exporter::_make_unimport_sub which was called 3 times, avg 29µs/call:
# 3 times (88µs+0s) by Moose::Exporter::build_import_methods at line 63, avg 29µs/call | ||||
| 543 | 3 | 7µs | shift; | ||
| 544 | 3 | 9µs | my $exporting_package = shift; | ||
| 545 | 3 | 7µs | my $exports = shift; | ||
| 546 | 3 | 6µs | my $export_recorder = shift; | ||
| 547 | 3 | 6µs | my $is_reexport = shift; | ||
| 548 | |||||
| 549 | # spent 11.0ms (771µs+10.2) within Moose::Exporter::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Exporter.pm:557] which was called 15 times, avg 733µs/call:
# once (98µs+1.01ms) by Moose::Meta::Method::Accessor::Native::Hash::values::BEGIN@26 at line 26 of Moose/Meta/Method/Accessor/Native/Hash/values.pm
# once (62µs+835µs) by Moose::Meta::Method::Accessor::Native::Writer::BEGIN@177 at line 177 of Moose/Meta/Method/Accessor/Native/Writer.pm
# once (46µs+711µs) by Moose::Meta::Method::Accessor::Native::Array::elements::BEGIN@24 at line 24 of Moose/Meta/Method/Accessor/Native/Array/elements.pm
# once (43µs+707µs) by Moose::Meta::Method::Accessor::Native::Array::clear::BEGIN@37 at line 37 of Moose/Meta/Method/Accessor/Native/Array/clear.pm
# once (44µs+700µs) by Moose::Meta::Method::Accessor::Native::Hash::keys::BEGIN@26 at line 26 of Moose/Meta/Method/Accessor/Native/Hash/keys.pm
# once (53µs+672µs) by Moose::Meta::Method::Accessor::Native::Array::BEGIN@28 at line 28 of Moose/Meta/Method/Accessor/Native/Array.pm
# once (43µs+681µs) by Moose::Meta::Method::Accessor::Native::Array::push::BEGIN@44 at line 44 of Moose/Meta/Method/Accessor/Native/Array/push.pm
# once (50µs+656µs) by Moose::Meta::Attribute::Native::Trait::Hash::BEGIN@13 at line 13 of Moose/Meta/Attribute/Native/Trait/Hash.pm
# once (45µs+657µs) by Moose::Meta::Method::Accessor::Native::Collection::BEGIN@149 at line 149 of Moose/Meta/Method/Accessor/Native/Collection.pm
# once (43µs+649µs) by Moose::Meta::Attribute::Native::Trait::Array::BEGIN@13 at line 13 of Moose/Meta/Attribute/Native/Trait/Array.pm
# once (43µs+641µs) by Moose::Meta::Method::Accessor::Native::Reader::BEGIN@48 at line 48 of Moose/Meta/Method/Accessor/Native/Reader.pm
# once (53µs+615µs) by Moose::Meta::Attribute::Native::Trait::BEGIN@198 at line 198 of Moose/Meta/Attribute/Native/Trait.pm
# once (44µs+604µs) by Moose::Meta::Method::Accessor::Native::BEGIN@153 at line 153 of Moose/Meta/Method/Accessor/Native.pm
# once (43µs+581µs) by Moose::Meta::Attribute::Native::Trait::BEGIN@199 at line 199 of Moose/Meta/Attribute/Native/Trait.pm
# once (59µs+502µs) by Throwable::BEGIN@31 at line 31 of Throwable.pm | ||||
| 550 | 15 | 89µs | my $caller = scalar caller(); | ||
| 551 | Moose::Exporter->_remove_keywords( | ||||
| 552 | $caller, | ||||
| 553 | 15 | 669µs | 15 | 10.2ms | [ keys %{$exports} ], # spent 10.2ms making 15 calls to Moose::Exporter::_remove_keywords, avg 681µs/call |
| 554 | $export_recorder, | ||||
| 555 | $is_reexport, | ||||
| 556 | ); | ||||
| 557 | 3 | 63µs | }; | ||
| 558 | } | ||||
| 559 | |||||
| 560 | # spent 10.2ms (10.0+189µs) within Moose::Exporter::_remove_keywords which was called 15 times, avg 681µs/call:
# 15 times (10.0ms+189µs) by Moose::Exporter::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Exporter.pm:557] at line 553, avg 681µs/call | ||||
| 561 | 15 | 45µs | shift; | ||
| 562 | 15 | 51µs | my $package = shift; | ||
| 563 | 15 | 41µs | my $keywords = shift; | ||
| 564 | 15 | 40µs | my $recorded_exports = shift; | ||
| 565 | 15 | 40µs | my $is_reexport = shift; | ||
| 566 | |||||
| 567 | 3 | 243µs | 2 | 200µs | # spent 123µs (47+77) within Moose::Exporter::BEGIN@567 which was called:
# once (47µs+77µs) by Moose::BEGIN@15 at line 567 # spent 123µs making 1 call to Moose::Exporter::BEGIN@567
# spent 77µs making 1 call to strict::unimport |
| 568 | |||||
| 569 | 15 | 331µs | foreach my $name ( @{$keywords} ) { | ||
| 570 | 213 | 2.68ms | if ( defined &{ $package . '::' . $name } ) { | ||
| 571 | 213 | 1.77ms | my $sub = \&{ $package . '::' . $name }; | ||
| 572 | |||||
| 573 | # make sure it is from us | ||||
| 574 | 213 | 882µs | next unless $recorded_exports->{$sub}; | ||
| 575 | |||||
| 576 | 213 | 556µs | if ( $is_reexport->{$name} ) { | ||
| 577 | 3 | 1.13ms | 2 | 145µs | # spent 90µs (36+55) within Moose::Exporter::BEGIN@577 which was called:
# once (36µs+55µs) by Moose::BEGIN@15 at line 577 # spent 90µs making 1 call to Moose::Exporter::BEGIN@577
# spent 54µs making 1 call to strict::unimport |
| 578 | next | ||||
| 579 | unless _export_is_flagged( | ||||
| 580 | 28 | 865µs | 28 | 188µs | \*{ join q{::} => $package, $name } ); # spent 188µs making 28 calls to Moose::Exporter::_export_is_flagged, avg 7µs/call |
| 581 | } | ||||
| 582 | |||||
| 583 | # and if it is from us, then undef the slot | ||||
| 584 | 211 | 3.04ms | delete ${ $package . '::' }{$name}; | ||
| 585 | } | ||||
| 586 | } | ||||
| 587 | } | ||||
| 588 | |||||
| 589 | # spent 277µs within Moose::Exporter::_make_init_meta which was called 3 times, avg 92µs/call:
# 3 times (277µs+0s) by Moose::Exporter::build_import_methods at line 70, avg 92µs/call | ||||
| 590 | 3 | 7µs | shift; | ||
| 591 | 3 | 9µs | my $class = shift; | ||
| 592 | 3 | 7µs | my $args = shift; | ||
| 593 | |||||
| 594 | 3 | 6µs | my %old_style_roles; | ||
| 595 | 3 | 81µs | for my $role ( | ||
| 596 | map {"${_}_roles"} | ||||
| 597 | qw( | ||||
| 598 | metaclass | ||||
| 599 | attribute_metaclass | ||||
| 600 | method_metaclass | ||||
| 601 | wrapped_method_metaclass | ||||
| 602 | instance_metaclass | ||||
| 603 | constructor_class | ||||
| 604 | destructor_class | ||||
| 605 | error_class | ||||
| 606 | ) | ||||
| 607 | ) { | ||||
| 608 | 24 | 102µs | $old_style_roles{$role} = $args->{$role} | ||
| 609 | if exists $args->{$role}; | ||||
| 610 | } | ||||
| 611 | |||||
| 612 | 3 | 6µs | my %base_class_roles; | ||
| 613 | 3 | 8µs | %base_class_roles = ( roles => $args->{base_class_roles} ) | ||
| 614 | if exists $args->{base_class_roles}; | ||||
| 615 | |||||
| 616 | my %new_style_roles = map { $_ => $args->{$_} } | ||||
| 617 | 3 | 18µs | grep { exists $args->{$_} } qw( class_metaroles role_metaroles ); | ||
| 618 | |||||
| 619 | 3 | 46µs | return unless %new_style_roles || %old_style_roles || %base_class_roles; | ||
| 620 | |||||
| 621 | return sub { | ||||
| 622 | shift; | ||||
| 623 | my %options = @_; | ||||
| 624 | |||||
| 625 | return unless Class::MOP::class_of( $options{for_class} ); | ||||
| 626 | |||||
| 627 | if ( %new_style_roles || %old_style_roles ) { | ||||
| 628 | Moose::Util::MetaRole::apply_metaroles( | ||||
| 629 | for => $options{for_class}, | ||||
| 630 | %new_style_roles, | ||||
| 631 | %old_style_roles, | ||||
| 632 | ); | ||||
| 633 | } | ||||
| 634 | |||||
| 635 | Moose::Util::MetaRole::apply_base_class_roles( | ||||
| 636 | for_class => $options{for_class}, | ||||
| 637 | %base_class_roles, | ||||
| 638 | ) | ||||
| 639 | if Class::MOP::class_of( $options{for_class} ) | ||||
| 640 | ->isa('Moose::Meta::Class'); | ||||
| 641 | |||||
| 642 | return Class::MOP::class_of( $options{for_class} ); | ||||
| 643 | }; | ||||
| 644 | } | ||||
| 645 | |||||
| 646 | # spent 453µs (154+299) within Moose::Exporter::import which was called 3 times, avg 151µs/call:
# once (61µs+113µs) by Moose::Util::TypeConstraints::BEGIN@7 at line 7 of Moose/Util/TypeConstraints.pm
# once (49µs+91µs) by Moose::BEGIN@15 at line 15 of Moose.pm
# once (45µs+94µs) by Moose::Role::BEGIN@17 at line 17 of Moose/Role.pm | ||||
| 647 | 3 | 43µs | 3 | 53µs | strict->import; # spent 53µs making 3 calls to strict::import, avg 18µs/call |
| 648 | 3 | 88µs | 3 | 246µs | warnings->import; # spent 246µs making 3 calls to warnings::import, avg 82µs/call |
| 649 | } | ||||
| 650 | |||||
| 651 | 1 | 28µs | 1; | ||
| 652 | |||||
| 653 | __END__ | ||||
# spent 188µs within Moose::Exporter::_export_is_flagged which was called 28 times, avg 7µs/call:
# 28 times (188µs+0s) by Moose::Exporter::_remove_keywords at line 580, avg 7µs/call | |||||
# spent 846µs within Moose::Exporter::_flag_as_reexport which was called 118 times, avg 7µs/call:
# 118 times (846µs+0s) by Moose::Exporter::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Exporter.pm:125] at line 123, avg 7µs/call |