← Index
NYTProf Performance Profile   « block view • line view • sub view »
For -e
  Run on Wed Nov 17 21:45:08 2010
Reported on Wed Nov 17 22:10:38 2010

Filename/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/Sub/Exporter.pm
StatementsExecuted 59306 statements in 560ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
23311146ms1.16sSub::Exporter::::_do_import Sub::Exporter::_do_import
5982185.9ms233msSub::Exporter::::_expand_groups Sub::Exporter::_expand_groups (recurses: max depth 2, inclusive time 238ms)
2333281.1ms495msSub::Exporter::::default_installer Sub::Exporter::default_installer
20131181.1ms224msSub::Exporter::::default_generator Sub::Exporter::default_generator
27432138.9ms38.9msSub::Exporter::::_group_name Sub::Exporter::_group_name
3651137.5ms204msSub::Exporter::::_expand_group Sub::Exporter::_expand_group (recurses: max depth 1, inclusive time 148ms)
233221933.3ms1.47sSub::Exporter::::__ANON__[:756] Sub::Exporter::__ANON__[:756]
2331120.2ms29.6msSub::Exporter::::_collect_collections Sub::Exporter::_collect_collections
45119.34ms194msSub::Exporter::::_rewrite_build_config Sub::Exporter::_rewrite_build_config
233118.86ms8.86msSub::Exporter::::_mk_collection_builder Sub::Exporter::_mk_collection_builder
45113.91ms3.91msSub::Exporter::::_key_intersection Sub::Exporter::_key_intersection
45432.18ms196msSub::Exporter::::build_exporter Sub::Exporter::build_exporter
4511994µs1.00msSub::Exporter::::_assert_collector_names_ok Sub::Exporter::_assert_collector_names_ok
311366µs488µsSub::Exporter::::__ANON__[:544] Sub::Exporter::__ANON__[:544]
4211311µs311µsDevel::GlobalDestruction::::in_global_destructionDevel::GlobalDestruction::in_global_destruction (xsub)
222130µs2.85msSub::Exporter::::setup_exporter Sub::Exporter::setup_exporter
111113µs113µsDevel::GlobalDestruction::::BEGIN@1Devel::GlobalDestruction::BEGIN@1
311101µs101µsSub::Exporter::::_setup Sub::Exporter::_setup
31168µs2.22msSub::Exporter::::__ANON__[:937] Sub::Exporter::__ANON__[:937]
11164µs64µsSub::Exporter::::BEGIN@636 Sub::Exporter::BEGIN@636
11140µs90µsSub::Exporter::::BEGIN@9 Sub::Exporter::BEGIN@9
11138µs56µsDevel::GlobalDestruction::::BEGIN@2Devel::GlobalDestruction::BEGIN@2
11137µs106µsDevel::GlobalDestruction::::BEGIN@3Devel::GlobalDestruction::BEGIN@3
11119µs19µsSub::Exporter::::BEGIN@6 Sub::Exporter::BEGIN@6
11118µs18µsSub::Exporter::::BEGIN@7 Sub::Exporter::BEGIN@7
11117µs17µsSub::Exporter::::BEGIN@8 Sub::Exporter::BEGIN@8
11110µs10µsSub::Exporter::::CORE:match Sub::Exporter::CORE:match (opcode)
0000s0sSub::Exporter::::__ANON__[:773] Sub::Exporter::__ANON__[:773]
0000s0sSub::Exporter::::default_exporter Sub::Exporter::default_exporter
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
13159µs1113µs
# spent 113µs within Devel::GlobalDestruction::BEGIN@1 which was called: # once (113µs+0s) by Devel::GlobalDestruction::BEGIN@26 at line 1
use 5.006;
# spent 113µs making 1 call to Devel::GlobalDestruction::BEGIN@1
2390µs274µs
# spent 56µs (38+18) within Devel::GlobalDestruction::BEGIN@2 which was called: # once (38µs+18µs) by Devel::GlobalDestruction::BEGIN@26 at line 2
use strict;
# spent 56µs making 1 call to Devel::GlobalDestruction::BEGIN@2 # spent 18µs making 1 call to strict::import
33123µs2175µs
# spent 106µs (37+69) within Devel::GlobalDestruction::BEGIN@3 which was called: # once (37µs+69µs) by Devel::GlobalDestruction::BEGIN@26 at line 3
use warnings;
# spent 106µs making 1 call to Devel::GlobalDestruction::BEGIN@3 # spent 69µs making 1 call to warnings::import
4package Sub::Exporter;
5
6376µs119µs
# spent 19µs within Sub::Exporter::BEGIN@6 which was called: # once (19µs+0s) by Devel::GlobalDestruction::BEGIN@26 at line 6
use Carp ();
# spent 19µs making 1 call to Sub::Exporter::BEGIN@6
7372µs118µs
# spent 18µs within Sub::Exporter::BEGIN@7 which was called: # once (18µs+0s) by Devel::GlobalDestruction::BEGIN@26 at line 7
use Data::OptList ();
# spent 18µs making 1 call to Sub::Exporter::BEGIN@7
8392µs117µs
# spent 17µs within Sub::Exporter::BEGIN@8 which was called: # once (17µs+0s) by Devel::GlobalDestruction::BEGIN@26 at line 8
use Params::Util ();
# spent 17µs making 1 call to Sub::Exporter::BEGIN@8
933.81ms2139µs
# spent 90µs (40+50) within Sub::Exporter::BEGIN@9 which was called: # once (40µs+50µs) by Devel::GlobalDestruction::BEGIN@26 at line 9
use Sub::Install 0.92 ();
# spent 90µs making 1 call to Sub::Exporter::BEGIN@9 # spent 50µs making 1 call to UNIVERSAL::VERSION
10
11=head1 NAME
12
- -
2114µsour $VERSION = '0.982';
22
23=head1 SYNOPSIS
24
- -
401# Given a potential import name, this returns the group name -- if it's got a
402# group prefix.
403
# spent 38.9ms within Sub::Exporter::_group_name which was called 2743 times, avg 14µs/call: # 2378 times (33.6ms+0s) by Sub::Exporter::_expand_groups at line 421, avg 14µs/call # 365 times (5.30ms+0s) by Sub::Exporter::_expand_group at line 461, avg 15µs/call
sub _group_name {
404621648.7ms my ($name) = @_;
405
406 return if (index q{-:}, (substr $name, 0, 1)) == -1;
407 return substr $name, 1;
408}
409
410# \@groups is a canonicalized opt list of exports and groups this returns
411# another canonicalized opt list with groups replaced with relevant exports.
412# \%seen is groups we've already expanded and can ignore.
413# \%merge is merged options from the group we're descending through.
414
# spent 233ms (85.9+147) within Sub::Exporter::_expand_groups which was called 598 times, avg 390µs/call: # 365 times (63.0ms+-63.0ms) by Sub::Exporter::_expand_group at line 509, avg 0s/call # 233 times (22.9ms+210ms) by Sub::Exporter::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/Sub/Exporter.pm:756] at line 742, avg 1.00ms/call
sub _expand_groups {
415358824.3ms my ($class, $config, $groups, $collection, $seen, $merge) = @_;
416 $seen ||= {};
417 $merge ||= {};
418 my @groups = @$groups;
419
420 for my $i (reverse 0 .. $#groups) {
421512154.4ms237833.6ms if (my $group_name = _group_name($groups[$i][0])) {
# spent 33.6ms making 2378 calls to Sub::Exporter::_group_name, avg 14µs/call
422 my $seen = { %$seen }; # faux-dynamic scoping
423
424365204ms splice @groups, $i, 1,
# spent 352ms making 365 calls to Sub::Exporter::_expand_group, avg 965µs/call, recursion: max depth 1, sum of overlapping time 148ms
425 _expand_group($class, $config, $groups[$i], $collection, $seen, $merge);
426 } else {
427 # there's nothing to munge in this export's args
428 next unless my %merge = %$merge;
429
430 # we have things to merge in; do so
431 my $prefix = (delete $merge{-prefix}) || '';
432 my $suffix = (delete $merge{-suffix}) || '';
433
434 if (
435 Params::Util::_CODELIKE($groups[$i][1]) ## no critic Private
436 or
437 Params::Util::_SCALAR0($groups[$i][1]) ## no critic Private
438 ) {
439 # this entry was build by a group generator
440 $groups[$i][0] = $prefix . $groups[$i][0] . $suffix;
441 } else {
442 my $as
443 = ref $groups[$i][1]{-as} ? $groups[$i][1]{-as}
444 : $groups[$i][1]{-as} ? $prefix . $groups[$i][1]{-as} . $suffix
445 : $prefix . $groups[$i][0] . $suffix;
446
447 $groups[$i][1] = { %{ $groups[$i][1] }, %merge, -as => $as };
448 }
449 }
450 }
451
452 return \@groups;
453}
454
455# \@group is a name/value pair from an opt list.
456
# spent 204ms (37.5+167) within Sub::Exporter::_expand_group which was called 365 times, avg 559µs/call: # 365 times (37.5ms+167ms) by Sub::Exporter::_expand_groups at line 424, avg 559µs/call
sub _expand_group {
457328523.8ms my ($class, $config, $group, $collection, $seen, $merge) = @_;
458 $merge ||= {};
459
460 my ($group_name, $group_arg) = @$group;
4613655.30ms $group_name = _group_name($group_name);
# spent 5.30ms making 365 calls to Sub::Exporter::_group_name, avg 15µs/call
462
463 Carp::croak qq(group "$group_name" is not exported by the $class module)
464 unless exists $config->{groups}{$group_name};
465
466 return if $seen->{$group_name}++;
467
468 if (ref $group_arg) {
469 my $prefix = (delete $merge->{-prefix}||'') . ($group_arg->{-prefix}||'');
470 my $suffix = ($group_arg->{-suffix}||'') . (delete $merge->{-suffix}||'');
471 $merge = {
472 %$merge,
473 %$group_arg,
474 ($prefix ? (-prefix => $prefix) : ()),
475 ($suffix ? (-suffix => $suffix) : ()),
476 };
477 }
478
479 my $exports = $config->{groups}{$group_name};
480
48173014.4ms7304.21ms if (
# spent 2.55ms making 365 calls to Params::Util::_CODELIKE, avg 7µs/call # spent 1.65ms making 365 calls to Params::Util::_SCALAR0, avg 5µs/call
482 Params::Util::_CODELIKE($exports) ## no critic Private
483 or
484 Params::Util::_SCALAR0($exports) ## no critic Private
485 ) {
486 # I'm not very happy with this code for hiding -prefix and -suffix, but
487 # it's needed, and I'm not sure, offhand, how to make it better.
488 # -- rjbs, 2006-12-05
489 my $group_arg = $merge ? { %$merge } : {};
490 delete $group_arg->{-prefix};
491 delete $group_arg->{-suffix};
492
493 my $group = Params::Util::_CODELIKE($exports) ## no critic Private
494 ? $exports->($class, $group_name, $group_arg, $collection)
495 : $class->$$exports($group_name, $group_arg, $collection);
496
497 Carp::croak qq(group generator "$group_name" did not return a hashref)
498 if ref $group ne 'HASH';
499
500 my $stuff = [ map { [ $_ => $group->{$_} ] } keys %$group ];
501 return @{
502 _expand_groups($class, $config, $stuff, $collection, $seen, $merge)
503 };
504 } else {
50536566.9ms $exports
# spent 66.9ms making 365 calls to Data::OptList::mkopt, avg 183µs/call
506 = Data::OptList::mkopt($exports, "$group_name exports");
507
508 return @{
5093650s _expand_groups($class, $config, $exports, $collection, $seen, $merge)
# spent 238ms making 365 calls to Sub::Exporter::_expand_groups, avg 653µs/call, recursion: max depth 2, sum of overlapping time 238ms
510 };
511 }
512}
513
514
# spent 8.86ms within Sub::Exporter::_mk_collection_builder which was called 233 times, avg 38µs/call: # 233 times (8.86ms+0s) by Sub::Exporter::_collect_collections at line 560, avg 38µs/call
sub _mk_collection_builder {
5159329.87ms my ($col, $etc) = @_;
516 my ($config, $import_args, $class, $into) = @$etc;
517
518 my %seen;
519
# spent 488µs (366+121) within Sub::Exporter::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/Sub/Exporter.pm:544] which was called 3 times, avg 162µs/call: # 3 times (366µs+121µs) by Sub::Exporter::_collect_collections at line 562, avg 162µs/call
sub {
52015113µs my ($collection) = @_;
521 my ($name, $value) = @$collection;
522
523 Carp::croak "collection $name provided multiple times in import"
524 if $seen{ $name }++;
525
5269238µs if (ref(my $hook = $config->{collectors}{$name})) {
527 my $arg = {
528 name => $name,
529 config => $config,
530 import_args => $import_args,
531 class => $class,
532 into => $into,
533 };
534
535 my $error_msg = "collection $name failed validation";
536334µs320µs if (Params::Util::_SCALAR0($hook)) { ## no critic Private
# spent 20µs making 3 calls to Params::Util::_SCALAR0, avg 7µs/call
537 Carp::croak $error_msg unless $class->$$hook($value, $arg);
538 } else {
5393101µs Carp::croak $error_msg unless $hook->($value, $arg);
# spent 101µs making 3 calls to Sub::Exporter::_setup, avg 34µs/call
540 }
541 }
542
543 $col->{ $name } = $value;
544 }
545}
546
547# Given a config and pre-canonicalized importer args, remove collections from
548# the args and return them.
549
# spent 29.6ms (20.2+9.35) within Sub::Exporter::_collect_collections which was called 233 times, avg 127µs/call: # 233 times (20.2ms+9.35ms) by Sub::Exporter::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/Sub/Exporter.pm:756] at line 740, avg 127µs/call
sub _collect_collections {
550163120.3ms my ($config, $import_args, $class, $into) = @_;
551
552 my @collections
553 = map { splice @$import_args, $_, 1 }
554 grep { exists $config->{collectors}{ $import_args->[$_][0] } }
555 reverse 0 .. $#$import_args;
556
557 unshift @collections, [ INIT => {} ] if $config->{collectors}{INIT};
558
559 my $col = {};
5602338.86ms my $builder = _mk_collection_builder($col, \@_);
# spent 8.86ms making 233 calls to Sub::Exporter::_mk_collection_builder, avg 38µs/call
561 for my $collection (@collections) {
562345µs3488µs $builder->($collection)
# spent 488µs making 3 calls to Sub::Exporter::__ANON__[Sub/Exporter.pm:544], avg 162µs/call
563 }
564
565 return $col;
566}
567
568=head1 SUBROUTINES
569
- -
593
# spent 2.85ms (130µs+2.72) within Sub::Exporter::setup_exporter which was called 2 times, avg 1.42ms/call: # once (68µs+1.41ms) by Devel::GlobalDestruction::BEGIN@26 at line 938 # once (61µs+1.31ms) by Moose::Meta::Class::BEGIN@26 at line 36 of Moose/Util.pm
sub setup_exporter {
59412123µs my ($config) = @_;
595
596 Carp::croak 'into and into_level may not both be supplied to exporter'
597 if exists $config->{into} and exists $config->{into_level};
598
599 my $as = delete $config->{as} || 'import';
600 my $into
601 = exists $config->{into} ? delete $config->{into}
602 : exists $config->{into_level} ? caller(delete $config->{into_level})
603 : caller(0);
604
60522.22ms my $import = build_exporter($config);
# spent 2.22ms making 2 calls to Sub::Exporter::build_exporter, avg 1.11ms/call
606
6072500µs Sub::Install::reinstall_sub({
# spent 500µs making 2 calls to Sub::Install::__ANON__[Sub/Install.pm:132], avg 250µs/call
608 code => $import,
609 into => $into,
610 as => $as,
611 });
612}
613
614=head2 build_exporter
615
- -
625
# spent 3.91ms within Sub::Exporter::_key_intersection which was called 45 times, avg 87µs/call: # 45 times (3.91ms+0s) by Sub::Exporter::_rewrite_build_config at line 681, avg 87µs/call
sub _key_intersection {
6261354.09ms my ($x, $y) = @_;
627 my %seen = map { $_ => 1 } keys %$x;
628 my @names = grep { $seen{$_} } keys %$y;
629}
630
631# Given the config passed to setup_exporter, which contains sugary opt list
632# data, rewrite the opt lists into hashes, catch a few kinds of invalid
633# configurations, and set up defaults. Since the config is a reference, it's
634# rewritten in place.
63512µsmy %valid_config_key;
636
# spent 64µs within Sub::Exporter::BEGIN@636 which was called: # once (64µs+0s) by Devel::GlobalDestruction::BEGIN@26 at line 641
BEGIN {
637 %valid_config_key =
638169µs map { $_ => 1 }
639 qw(as collectors installer generator exports groups into into_level),
640 qw(exporter), # deprecated
64114.05ms164µs}
# spent 64µs making 1 call to Sub::Exporter::BEGIN@636
642
643
# spent 1.00ms (994µs+10µs) within Sub::Exporter::_assert_collector_names_ok which was called 45 times, avg 22µs/call: # 45 times (994µs+10µs) by Sub::Exporter::_rewrite_build_config at line 679, avg 22µs/call
sub _assert_collector_names_ok {
644901.11ms my ($collectors) = @_;
645
646131µs110µs for my $reserved_name (grep { /\A[_A-Z]+\z/ } keys %$collectors) {
# spent 10µs making 1 call to Sub::Exporter::CORE:match
647 Carp::croak "unknown reserved collector name: $reserved_name"
648 if $reserved_name ne 'INIT';
649 }
650}
651
652
# spent 194ms (9.34+185) within Sub::Exporter::_rewrite_build_config which was called 45 times, avg 4.32ms/call: # 45 times (9.34ms+185ms) by Sub::Exporter::build_exporter at line 709, avg 4.32ms/call
sub _rewrite_build_config {
6535855.92ms my ($config) = @_;
654
655 if (my @keys = grep { not exists $valid_config_key{$_} } keys %$config) {
656 Carp::croak "unknown options (@keys) passed to Sub::Exporter";
657 }
658
659 Carp::croak q(into and into_level may not both be supplied to exporter)
660 if exists $config->{into} and exists $config->{into_level};
661
662 # XXX: Remove after deprecation period.
663 if ($config->{exporter}) {
664 Carp::cluck "'exporter' argument to build_exporter is deprecated. Use 'installer' instead; the semantics are identical.";
665 $config->{installer} = delete $config->{exporter};
666 }
667
668 Carp::croak q(into and into_level may not both be supplied to exporter)
669 if exists $config->{into} and exists $config->{into_level};
670
671 for (qw(exports collectors)) {
672902.82ms90176ms $config->{$_} = Data::OptList::mkopt_hash(
# spent 176ms making 90 calls to Data::OptList::mkopt_hash, avg 1.96ms/call
673 $config->{$_},
674 $_,
675 [ 'CODE', 'SCALAR' ],
676 );
677 }
678
679451.00ms _assert_collector_names_ok($config->{collectors});
# spent 1.00ms making 45 calls to Sub::Exporter::_assert_collector_names_ok, avg 22µs/call
680
681453.91ms if (my @names = _key_intersection(@$config{qw(exports collectors)})) {
# spent 3.91ms making 45 calls to Sub::Exporter::_key_intersection, avg 87µs/call
682 Carp::croak "names (@names) used in both collections and exports";
683 }
684
685453.65ms $config->{groups} = Data::OptList::mkopt_hash(
# spent 3.65ms making 45 calls to Data::OptList::mkopt_hash, avg 81µs/call
686 $config->{groups},
687 'groups',
688 [
689 'HASH', # standard opt list
690 'ARRAY', # standard opt list
691 'CODE', # group generator
692 'SCALAR', # name of group generation method
693 ]
694 );
695
696 # by default, export nothing
697 $config->{groups}{default} ||= [];
698
699 # by default, build an all-inclusive 'all' group
700 $config->{groups}{all} ||= [ keys %{ $config->{exports} } ];
701
702 $config->{generator} ||= \&default_generator;
703 $config->{installer} ||= \&default_installer;
704}
705
706
# spent 196ms (2.18+194) within Sub::Exporter::build_exporter which was called 45 times, avg 4.37ms/call: # 33 times (1.59ms+177ms) by MooseX::Types::Base::import at line 91 of MooseX/Types/Base.pm, avg 5.42ms/call # 7 times (350µs+12.8ms) by Moose::Exporter::_make_exporter at line 127 of Moose/Exporter.pm, avg 1.88ms/call # 3 times (153µs+1.99ms) by Sub::Exporter::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/Sub/Exporter.pm:937] at line 937, avg 716µs/call # 2 times (85µs+2.13ms) by Sub::Exporter::setup_exporter at line 605, avg 1.11ms/call
sub build_exporter {
7071802.14ms my ($config) = @_;
708
70945194ms _rewrite_build_config($config);
# spent 194ms making 45 calls to Sub::Exporter::_rewrite_build_config, avg 4.32ms/call
710
711
# spent 1.47s (33.3ms+1.44) within Sub::Exporter::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/Sub/Exporter.pm:756] which was called 233 times, avg 6.31ms/call: # 180 times (26.1ms+1.34s) by Moose::Exporter::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Exporter.pm:456] at line 455 of Moose/Exporter.pm, avg 7.59ms/call # 33 times (4.43ms+79.6ms) by MooseX::Types::Base::import at line 115 of MooseX/Types/Base.pm, avg 2.55ms/call # once (177µs+1.84ms) by MooseX::Params::Validate::BEGIN@12 at line 12 of MooseX/Params/Validate.pm # once (134µs+1.65ms) by Devel::GlobalDestruction::BEGIN@26 at line 26 of Devel/GlobalDestruction.pm # once (128µs+1.54ms) by B::Hooks::EndOfScope::BEGIN@16 at line 16 of B/Hooks/EndOfScope.pm # once (148µs+1.14ms) by Markdent::Role::HTMLStream::BEGIN@15 at line 15 of Markdent/Role/HTMLStream.pm # once (148µs+1.05ms) by Moose::Exporter::BEGIN@15 at line 15 of Moose/Exporter.pm # once (132µs+966µs) by namespace::clean::BEGIN@17 at line 17 of namespace/clean.pm # once (135µs+962µs) by namespace::autoclean::BEGIN@14 at line 14 of namespace/autoclean.pm # once (181µs+842µs) by Markdent::Simple::Document::BEGIN@12 at line 12 of Markdent/Simple/Document.pm # once (129µs+748µs) by Moose::Meta::TypeConstraint::DuckType::BEGIN@9 at line 9 of Moose/Meta/TypeConstraint/DuckType.pm # once (131µs+733µs) by MooseX::Types::Base::BEGIN@13 at line 13 of MooseX/Types/Base.pm # once (127µs+729µs) by Moose::Meta::Role::Application::ToClass::BEGIN@7 at line 7 of Moose/Meta/Role/Application/ToClass.pm # once (122µs+733µs) by Moose::Meta::Role::BEGIN@10 at line 10 of Moose/Meta/Role.pm # once (122µs+732µs) by Class::MOP::Class::BEGIN@16 at line 16 of Class/MOP/Class.pm # once (127µs+720µs) by Markdent::Parser::BEGIN@13 at line 13 of Markdent/Parser.pm # once (129µs+705µs) by Moose::Meta::Role::BEGIN@22 at line 22 of Moose/Meta/Role.pm # once (127µs+705µs) by Markdent::Role::BalancedEvent::BEGIN@11 at line 11 of Markdent/Role/BalancedEvent.pm # once (152µs+638µs) by Moose::Role::BEGIN@8 at line 8 of Moose/Role.pm # once (134µs+518µs) by Moose::Meta::Role::Method::Conflicting::BEGIN@7 at line 7 of Moose/Meta/Role/Method/Conflicting.pm # once (128µs+499µs) by Moose::Util::BEGIN@8 at line 8 of Moose/Util.pm # once (119µs+470µs) by Moose::Meta::Class::BEGIN@26 at line 26 of Moose/Meta/Class.pm
my $import = sub {
712279630.4ms my ($class) = shift;
713
714 # XXX: clean this up -- rjbs, 2006-03-16
715 my $special = (ref $_[0]) ? shift(@_) : {};
716 Carp::croak q(into and into_level may not both be supplied to exporter)
717 if exists $special->{into} and exists $special->{into_level};
718
719 if ($special->{exporter}) {
720 Carp::cluck "'exporter' special import argument is deprecated. Use 'installer' instead; the semantics are identical.";
721 $special->{installer} = delete $special->{exporter};
722 }
723
724 my $into
725 = defined $special->{into} ? delete $special->{into}
726 : defined $special->{into_level} ? caller(delete $special->{into_level})
727 : defined $config->{into} ? $config->{into}
728 : defined $config->{into_level} ? caller($config->{into_level})
729 : caller(0);
730
731 my $generator = delete $special->{generator} || $config->{generator};
732 my $installer = delete $special->{installer} || $config->{installer};
733
734 # this builds a AOA, where the inner arrays are [ name => value_ref ]
73523312.5ms my $import_args = Data::OptList::mkopt([ @_ ]);
# spent 12.5ms making 233 calls to Data::OptList::mkopt, avg 53µs/call
736
737 # is this right? defaults first or collectors first? -- rjbs, 2006-06-24
738 $import_args = [ [ -default => undef ] ] unless @$import_args;
739
74023329.6ms my $collection = _collect_collections($config, $import_args, $class, $into);
# spent 29.6ms making 233 calls to Sub::Exporter::_collect_collections, avg 127µs/call
741
742233233ms my $to_import = _expand_groups($class, $config, $import_args, $collection);
# spent 233ms making 233 calls to Sub::Exporter::_expand_groups, avg 1.00ms/call
743
744 # now, finally $import_arg is really the "to do" list
7452331.16s _do_import(
# spent 1.16s making 233 calls to Sub::Exporter::_do_import, avg 4.99ms/call
746 {
747 class => $class,
748 col => $collection,
749 config => $config,
750 into => $into,
751 generator => $generator,
752 installer => $installer,
753 },
754 $to_import,
755 );
756 };
757
758 return $import;
759}
760
761
# spent 1.16s (146ms+1.02) within Sub::Exporter::_do_import which was called 233 times, avg 4.99ms/call: # 233 times (146ms+1.02s) by Sub::Exporter::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/Sub/Exporter.pm:756] at line 745, avg 4.99ms/call
sub _do_import {
7629329.86ms my ($arg, $to_import) = @_;
763
764 my @todo;
765
766 for my $pair (@$to_import) {
76710065101ms my ($name, $import_arg) = @$pair;
768
769 my ($generator, $as);
770
771805230.6ms319µs if ($import_arg and Params::Util::_CODELIKE($import_arg)) { ## no critic
# spent 19µs making 3 calls to Params::Util::_CODELIKE, avg 6µs/call
772 # This is the case when a group generator has inserted name/code pairs.
773 $generator = sub { $import_arg };
774 $as = $name;
775 } else {
776 $import_arg = { $import_arg ? %$import_arg : () };
777
778 Carp::croak qq("$name" is not exported by the $arg->{class} module)
779 unless exists $arg->{config}{exports}{$name};
780
781 $generator = $arg->{config}{exports}{$name};
782
783 $as = exists $import_arg->{-as} ? (delete $import_arg->{-as}) : $name;
784 }
785
7862013224ms my $code = $arg->{generator}->(
# spent 224ms making 2013 calls to Sub::Exporter::default_generator, avg 111µs/call
787 {
788 class => $arg->{class},
789 name => $name,
790 arg => $import_arg,
791 col => $arg->{col},
792 generator => $generator,
793 }
794 );
795
796 push @todo, $as, $code;
797 }
798
799233768ms $arg->{installer}->(
# spent 725ms making 180 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:125], avg 4.03ms/call # spent 42.8ms making 53 calls to Sub::Exporter::default_installer, avg 807µs/call
800 {
801 class => $arg->{class},
802 into => $arg->{into},
803 col => $arg->{col},
804 },
805 \@todo,
806 );
807}
808
809## Cute idea, possibly for future use: also supply an "unimport" for:
810## no Module::Whatever qw(arg arg arg);
811# sub _unexport {
812# my (undef, undef, undef, undef, undef, $as, $into) = @_;
813#
814# if (ref $as eq 'SCALAR') {
815# undef $$as;
816# } elsif (ref $as) {
817# Carp::croak "invalid reference type for $as: " . ref $as;
818# } else {
819# no strict 'refs';
820# delete &{$into . '::' . $as};
821# }
822# }
823
824=head2 default_generator
825
- -
843
# spent 224ms (81.1+143) within Sub::Exporter::default_generator which was called 2013 times, avg 111µs/call: # 2013 times (81.1ms+143ms) by Sub::Exporter::_do_import at line 786, avg 111µs/call
sub default_generator {
844803988.6ms my ($arg) = @_;
845 my ($class, $name, $generator) = @$arg{qw(class name generator)};
846
84726579µs if (not defined $generator) {
84813154µs my $code = $class->can($name)
# spent 154µs making 13 calls to UNIVERSAL::can, avg 12µs/call
849 or Carp::croak "can't locate exported subroutine $name via $class";
850 return $code;
851 }
852
853 # I considered making this "$class->$generator(" but it seems that
854 # overloading precedence would turn an overloaded-as-code generator object
855 # into a string before code. -- rjbs, 2006-06-11
8564000143ms return $generator->($class, $name, $arg->{arg}, $arg->{col})
# spent 110ms making 1008 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:329], avg 109µs/call # spent 10.1ms making 2000 calls to Params::Util::_CODELIKE, avg 5µs/call # spent 7.09ms making 792 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:259], avg 9µs/call # spent 5.74ms making 69 calls to MooseX::Types::Base::__ANON__[MooseX/Types/Base.pm:73], avg 83µs/call # spent 4.79ms making 50 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:307], avg 96µs/call # spent 3.03ms making 69 calls to MooseX::Types::Base::__ANON__[MooseX/Types/Base.pm:78], avg 44µs/call # spent 2.22ms making 3 calls to Sub::Exporter::__ANON__[Sub/Exporter.pm:937], avg 738µs/call # spent 443µs making 9 calls to MooseX::Types::Base::__ANON__[MooseX/Types/Base.pm:86], avg 49µs/call
857 if Params::Util::_CODELIKE($generator); ## no critic Private
858
859 # This "must" be a scalar reference, to a generator method name.
860 # -- rjbs, 2006-12-05
861 return $class->$$generator($name, $arg->{arg}, $arg->{col});
862}
863
864=head2 default_installer
865
- -
882
# spent 495ms (81.1+414) within Sub::Exporter::default_installer which was called 233 times, avg 2.13ms/call: # 173 times (70.1ms+359ms) by Moose::Exporter::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Exporter.pm:125] at line 117 of Moose/Exporter.pm, avg 2.48ms/call # 53 times (7.37ms+35.4ms) by Sub::Exporter::_do_import at line 799, avg 807µs/call # 7 times (3.64ms+20.0ms) by Sub::Exporter::_do_import at line 98 of Moose/Exporter.pm, avg 3.38ms/call
sub default_installer {
88369922.2ms my ($arg, $to_export) = @_;
884
885402021.4ms for (my $i = 0; $i < @$to_export; $i += 2) {
886 my ($as, $code) = @$to_export[ $i, $i+1 ];
887
888 # Allow as isa ARRAY to push onto an array?
889 # Allow into isa HASH to install name=>code into hash?
890
891201033.9ms if (ref $as eq 'SCALAR') {
892 $$as = $code;
893 } elsif (ref $as) {
894 Carp::croak "invalid reference type for $as: " . ref $as;
895 } else {
8962010414ms Sub::Install::reinstall_sub({
# spent 414ms making 2010 calls to Sub::Install::__ANON__[Sub/Install.pm:132], avg 206µs/call
897 code => $code,
898 into => $arg->{into},
899 as => $as
900 });
901 }
902 }
903}
904
905sub default_exporter {
906 Carp::cluck "default_exporter is deprecated; call default_installer instead; the semantics are identical";
907 goto &default_installer;
908}
909
910=head1 EXPORTS
911
- -
934setup_exporter({
935 exports => [
936 qw(setup_exporter build_exporter),
937356µs32.15ms
# spent 2.22ms (68µs+2.15) within Sub::Exporter::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/Sub/Exporter.pm:937] which was called 3 times, avg 738µs/call: # 3 times (68µs+2.15ms) by Sub::Exporter::default_generator at line 856, avg 738µs/call
_import => sub { build_exporter($_[2]) },
# spent 2.15ms making 3 calls to Sub::Exporter::build_exporter, avg 716µs/call
938146µs11.48ms ],
# spent 1.48ms making 1 call to Sub::Exporter::setup_exporter
939 groups => {
940 all => [ qw(setup_exporter build_export) ],
941 },
942 collectors => { -setup => \&_setup },
943});
944
945
# spent 101µs within Sub::Exporter::_setup which was called 3 times, avg 34µs/call: # 3 times (101µs+0s) by Sub::Exporter::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/Sub/Exporter.pm:544] at line 539, avg 34µs/call
sub _setup {
946621µs my ($value, $arg) = @_;
947
948698µs if (ref $value eq 'HASH') {
949 push @{ $arg->{import_args} }, [ _import => { -as => 'import', %$value } ];
950 return 1;
951 } elsif (ref $value eq 'ARRAY') {
952 push @{ $arg->{import_args} },
953 [ _import => { -as => 'import', exports => $value } ];
954 return 1;
955 }
956 return;
957}
958
959=head1 COMPARISONS
960
- -
1065=over
1066
- -
1101127µs"jn8:32"; # <-- magic true value
 
# spent 311µs within Devel::GlobalDestruction::in_global_destruction which was called 42 times, avg 7µs/call: # 42 times (311µs+0s) by Class::MOP::Class::DESTROY at line 465 of Class/MOP/Class.pm, avg 7µs/call
sub Devel::GlobalDestruction::in_global_destruction; # xsub
# spent 10µs within Sub::Exporter::CORE:match which was called: # once (10µs+0s) by Sub::Exporter::_assert_collector_names_ok at line 646
sub Sub::Exporter::CORE:match; # opcode