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

Filename/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/Sub/Exporter.pm
StatementsExecuted 25220 statements in 231ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
851154.4ms471msSub::Exporter::::_do_importSub::Exporter::_do_import
853237.2ms222msSub::Exporter::::default_installerSub::Exporter::default_installer
9081136.0ms101msSub::Exporter::::default_generatorSub::Exporter::default_generator
2252135.9ms99.0msSub::Exporter::::_expand_groupsSub::Exporter::_expand_groups (recurses: max depth 2, inclusive time 109ms)
11882116.7ms16.7msSub::Exporter::::_group_nameSub::Exporter::_group_name
1401114.1ms89.5msSub::Exporter::::_expand_groupSub::Exporter::_expand_group (recurses: max depth 1, inclusive time 67.9ms)
85201812.3ms596msSub::Exporter::::__ANON__[:756]Sub::Exporter::__ANON__[:756]
85117.15ms11.0msSub::Exporter::::_collect_collectionsSub::Exporter::_collect_collections
85113.23ms3.23msSub::Exporter::::_mk_collection_builderSub::Exporter::_mk_collection_builder
10111.70ms14.1msSub::Exporter::::_rewrite_build_configSub::Exporter::_rewrite_build_config
1032467µs14.6msSub::Exporter::::build_exporterSub::Exporter::build_exporter
1011444µs444µsSub::Exporter::::_key_intersectionSub::Exporter::_key_intersection
511427µs647µsSub::Exporter::::__ANON__[:544]Sub::Exporter::__ANON__[:544]
1011248µs270µsSub::Exporter::::_assert_collector_names_okSub::Exporter::_assert_collector_names_ok
511184µs184µsSub::Exporter::::_setupSub::Exporter::_setup
222138µs2.86msSub::Exporter::::setup_exporterSub::Exporter::setup_exporter
111131µs131µsEval::Closure::::BEGIN@1Eval::Closure::BEGIN@1
511119µs5.41msSub::Exporter::::__ANON__[:937]Sub::Exporter::__ANON__[:937]
11164µs64µsSub::Exporter::::BEGIN@636Sub::Exporter::BEGIN@636
11150µs67µsEval::Closure::::BEGIN@2.1Eval::Closure::BEGIN@2.1
11138µs85µsSub::Exporter::::BEGIN@9Sub::Exporter::BEGIN@9
11136µs101µsEval::Closure::::BEGIN@3Eval::Closure::BEGIN@3
21122µs22µsSub::Exporter::::CORE:matchSub::Exporter::CORE:match (opcode)
11118µs18µsSub::Exporter::::BEGIN@6Sub::Exporter::BEGIN@6
11118µs18µsSub::Exporter::::BEGIN@7Sub::Exporter::BEGIN@7
11117µs17µsSub::Exporter::::BEGIN@8Sub::Exporter::BEGIN@8
0000s0sSub::Exporter::::__ANON__[:773]Sub::Exporter::__ANON__[:773]
0000s0sSub::Exporter::::default_exporterSub::Exporter::default_exporter
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
13159µs1131µs
# spent 131µs within Eval::Closure::BEGIN@1 which was called: # once (131µs+0s) by Eval::Closure::BEGIN@7 at line 1
use 5.006;
# spent 131µs making 1 call to Eval::Closure::BEGIN@1
2387µs284µs
# spent 67µs (50+17) within Eval::Closure::BEGIN@2.1 which was called: # once (50µs+17µs) by Eval::Closure::BEGIN@7 at line 2
use strict;
# spent 67µs making 1 call to Eval::Closure::BEGIN@2.1 # spent 17µs making 1 call to strict::import
33112µs2167µs
# spent 101µs (36+65) within Eval::Closure::BEGIN@3 which was called: # once (36µs+65µs) by Eval::Closure::BEGIN@7 at line 3
use warnings;
# spent 101µs making 1 call to Eval::Closure::BEGIN@3 # spent 65µs making 1 call to warnings::import
4package Sub::Exporter;
5
6374µs118µs
# spent 18µs within Sub::Exporter::BEGIN@6 which was called: # once (18µs+0s) by Eval::Closure::BEGIN@7 at line 6
use Carp ();
# spent 18µs making 1 call to Sub::Exporter::BEGIN@6
7383µs118µs
# spent 18µs within Sub::Exporter::BEGIN@7 which was called: # once (18µs+0s) by Eval::Closure::BEGIN@7 at line 7
use Data::OptList ();
# spent 18µs making 1 call to Sub::Exporter::BEGIN@7
8380µs117µs
# spent 17µs within Sub::Exporter::BEGIN@8 which was called: # once (17µs+0s) by Eval::Closure::BEGIN@7 at line 8
use Params::Util ();
# spent 17µs making 1 call to Sub::Exporter::BEGIN@8
934.34ms2132µs
# spent 85µs (38+47) within Sub::Exporter::BEGIN@9 which was called: # once (38µs+47µs) by Eval::Closure::BEGIN@7 at line 9
use Sub::Install 0.92 ();
# spent 85µs making 1 call to Sub::Exporter::BEGIN@9 # spent 47µs making 1 call to UNIVERSAL::VERSION
10
11=head1 NAME
12
- -
2115µ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 16.7ms within Sub::Exporter::_group_name which was called 1188 times, avg 14µs/call: # 1048 times (14.7ms+0s) by Sub::Exporter::_expand_groups at line 421, avg 14µs/call # 140 times (2.05ms+0s) by Sub::Exporter::_expand_group at line 461, avg 15µs/call
sub _group_name {
404265620.9ms 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 99.0ms (35.9+63.1) within Sub::Exporter::_expand_groups which was called 225 times, avg 440µs/call: # 140 times (28.3ms+-28.3ms) by Sub::Exporter::_expand_group at line 509, avg 0s/call # 85 times (7.68ms+91.3ms) 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.16ms/call
sub _expand_groups {
415358632.7ms my ($class, $config, $groups, $collection, $seen, $merge) = @_;
416 $seen ||= {};
417 $merge ||= {};
418 my @groups = @$groups;
419
420 for my $i (reverse 0 .. $#groups) {
421104814.7ms if (my $group_name = _group_name($groups[$i][0])) {
# spent 14.7ms making 1048 calls to Sub::Exporter::_group_name, avg 14µs/call
422 my $seen = { %$seen }; # faux-dynamic scoping
423
42414089.5ms splice @groups, $i, 1,
# spent 157ms making 140 calls to Sub::Exporter::_expand_group, avg 1.12ms/call, recursion: max depth 1, sum of overlapping time 67.9ms
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 89.5ms (14.1+75.4) within Sub::Exporter::_expand_group which was called 140 times, avg 639µs/call: # 140 times (14.1ms+75.4ms) by Sub::Exporter::_expand_groups at line 424, avg 639µs/call
sub _expand_group {
457154014.3ms my ($class, $config, $group, $collection, $seen, $merge) = @_;
458 $merge ||= {};
459
460 my ($group_name, $group_arg) = @$group;
4611402.05ms $group_name = _group_name($group_name);
# spent 2.05ms making 140 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
4812801.65ms if (
# spent 981µs making 140 calls to Params::Util::_CODELIKE, avg 7µs/call # spent 666µs making 140 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 {
50514030.6ms $exports
# spent 30.6ms making 140 calls to Data::OptList::mkopt, avg 219µs/call
506 = Data::OptList::mkopt($exports, "$group_name exports");
507
508 return @{
5091400s _expand_groups($class, $config, $exports, $collection, $seen, $merge)
# spent 109ms making 140 calls to Sub::Exporter::_expand_groups, avg 778µs/call, recursion: max depth 2, sum of overlapping time 109ms
510 };
511 }
512}
513
514
# spent 3.23ms within Sub::Exporter::_mk_collection_builder which was called 85 times, avg 38µs/call: # 85 times (3.23ms+0s) by Sub::Exporter::_collect_collections at line 560, avg 38µs/call
sub _mk_collection_builder {
5153403.66ms my ($col, $etc) = @_;
516 my ($config, $import_args, $class, $into) = @$etc;
517
518 my %seen;
519
# spent 647µs (427+220) 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 5 times, avg 129µs/call: # 5 times (427µs+220µs) by Sub::Exporter::_collect_collections at line 562, avg 129µs/call
sub {
52045452µs my ($collection) = @_;
521 my ($name, $value) = @$collection;
522
523 Carp::croak "collection $name provided multiple times in import"
524 if $seen{ $name }++;
525
526 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";
536536µs if (Params::Util::_SCALAR0($hook)) { ## no critic Private
# spent 36µs making 5 calls to Params::Util::_SCALAR0, avg 7µs/call
537 Carp::croak $error_msg unless $class->$$hook($value, $arg);
538 } else {
5395184µs Carp::croak $error_msg unless $hook->($value, $arg);
# spent 184µs making 5 calls to Sub::Exporter::_setup, avg 37µ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 11.0ms (7.15+3.88) within Sub::Exporter::_collect_collections which was called 85 times, avg 130µs/call: # 85 times (7.15ms+3.88ms) 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 130µs/call
sub _collect_collections {
5506007.11ms 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 = {};
560853.23ms my $builder = _mk_collection_builder($col, \@_);
# spent 3.23ms making 85 calls to Sub::Exporter::_mk_collection_builder, avg 38µs/call
561 for my $collection (@collections) {
5625647µs $builder->($collection)
# spent 647µs making 5 calls to Sub::Exporter::__ANON__[Sub/Exporter.pm:544], avg 129µs/call
563 }
564
565 return $col;
566}
567
568=head1 SUBROUTINES
569
- -
593
# spent 2.86ms (138µs+2.73) within Sub::Exporter::setup_exporter which was called 2 times, avg 1.43ms/call: # once (70µs+1.37ms) by Eval::Closure::BEGIN@7 at line 938 # once (68µs+1.36ms) by Moose::Meta::Class::BEGIN@26 at line 36 of Moose/Util.pm
sub setup_exporter {
59412132µ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.25ms my $import = build_exporter($config);
# spent 2.25ms making 2 calls to Sub::Exporter::build_exporter, avg 1.12ms/call
606
6072481µs Sub::Install::reinstall_sub({
# spent 481µs making 2 calls to Sub::Install::__ANON__[Sub/Install.pm:132], avg 240µs/call
608 code => $import,
609 into => $into,
610 as => $as,
611 });
612}
613
614=head2 build_exporter
615
- -
625
# spent 444µs within Sub::Exporter::_key_intersection which was called 10 times, avg 44µs/call: # 10 times (444µs+0s) by Sub::Exporter::_rewrite_build_config at line 681, avg 44µs/call
sub _key_intersection {
62630479µs 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 Eval::Closure::BEGIN@7 at line 641
BEGIN {
637 %valid_config_key =
638168µs map { $_ => 1 }
639 qw(as collectors installer generator exports groups into into_level),
640 qw(exporter), # deprecated
64113.98ms164µs}
# spent 64µs making 1 call to Sub::Exporter::BEGIN@636
642
643
# spent 270µs (248+22) within Sub::Exporter::_assert_collector_names_ok which was called 10 times, avg 27µs/call: # 10 times (248µs+22µs) by Sub::Exporter::_rewrite_build_config at line 679, avg 27µs/call
sub _assert_collector_names_ok {
64422306µs my ($collectors) = @_;
645
646222µs for my $reserved_name (grep { /\A[_A-Z]+\z/ } keys %$collectors) {
# spent 22µs making 2 calls to Sub::Exporter::CORE:match, avg 11µs/call
647 Carp::croak "unknown reserved collector name: $reserved_name"
648 if $reserved_name ne 'INIT';
649 }
650}
651
652
# spent 14.1ms (1.70+12.4) within Sub::Exporter::_rewrite_build_config which was called 10 times, avg 1.41ms/call: # 10 times (1.70ms+12.4ms) by Sub::Exporter::build_exporter at line 709, avg 1.41ms/call
sub _rewrite_build_config {
6531501.58ms 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)) {
672208.27ms $config->{$_} = Data::OptList::mkopt_hash(
# spent 8.27ms making 20 calls to Data::OptList::mkopt_hash, avg 414µs/call
673 $config->{$_},
674 $_,
675 [ 'CODE', 'SCALAR' ],
676 );
677 }
678
67910270µs _assert_collector_names_ok($config->{collectors});
# spent 270µs making 10 calls to Sub::Exporter::_assert_collector_names_ok, avg 27µs/call
680
68110444µs if (my @names = _key_intersection(@$config{qw(exports collectors)})) {
# spent 444µs making 10 calls to Sub::Exporter::_key_intersection, avg 44µs/call
682 Carp::croak "names (@names) used in both collections and exports";
683 }
684
685103.46ms $config->{groups} = Data::OptList::mkopt_hash(
# spent 3.46ms making 10 calls to Data::OptList::mkopt_hash, avg 346µ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 14.6ms (467µs+14.1) within Sub::Exporter::build_exporter which was called 10 times, avg 1.46ms/call: # 5 times (230µs+5.06ms) 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 1.06ms/call # 3 times (140µs+6.93ms) by Moose::Exporter::_make_exporter at line 127 of Moose/Exporter.pm, avg 2.36ms/call # 2 times (97µs+2.15ms) by Sub::Exporter::setup_exporter at line 605, avg 1.12ms/call
sub build_exporter {
70740478µs my ($config) = @_;
708
7091014.1ms _rewrite_build_config($config);
# spent 14.1ms making 10 calls to Sub::Exporter::_rewrite_build_config, avg 1.41ms/call
710
711
# spent 596ms (12.3+584) 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 85 times, avg 7.02ms/call: # 66 times (9.70ms+563ms) by Moose::Exporter::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Exporter.pm:456] at line 455 of Moose/Exporter.pm, avg 8.67ms/call # once (139µs+2.66ms) by B::Hooks::EndOfScope::BEGIN@16 at line 16 of B/Hooks/EndOfScope.pm # once (145µs+2.20ms) by Devel::PartialDump::BEGIN@13 at line 26 of Devel/PartialDump.pm # once (147µs+2.19ms) by Data::UUID::LibUUID::BEGIN@13 at line 13 of Data/UUID/LibUUID.pm # once (133µs+1.74ms) by KiokuDB::Role::UUIDs::LibUUID::BEGIN@6 at line 6 of KiokuDB/Role/UUIDs/LibUUID.pm # once (136µs+1.65ms) by Eval::Closure::BEGIN@7 at line 7 of Eval/Closure.pm # once (127µs+1.57ms) by Devel::GlobalDestruction::BEGIN@26 at line 26 of Devel/GlobalDestruction.pm # once (195µs+1.45ms) by namespace::clean::BEGIN@17 at line 17 of namespace/clean.pm # once (128µs+1.02ms) by Class::MOP::Method::Generated::BEGIN@8 at line 8 of Class/MOP/Method/Generated.pm # once (132µs+895µs) by KiokuDB::LiveObjects::BEGIN@1 at line 1 of (eval 307)[KiokuDB/LiveObjects.pm:10] # once (127µs+765µs) by Moose::Meta::TypeConstraint::DuckType::BEGIN@9 at line 9 of Moose/Meta/TypeConstraint/DuckType.pm # once (159µs+710µs) by Moose::Meta::Role::Application::ToClass::BEGIN@7 at line 7 of Moose/Meta/Role/Application/ToClass.pm # once (126µs+719µs) by Moose::Meta::Role::BEGIN@10 at line 10 of Moose/Meta/Role.pm # once (127µs+694µs) by Moose::Meta::Role::BEGIN@22 at line 22 of Moose/Meta/Role.pm # once (121µs+680µs) by Class::MOP::Class::BEGIN@16 at line 16 of Class/MOP/Class.pm # once (126µs+520µs) by Moose::Exporter::BEGIN@15 at line 15 of Moose/Exporter.pm # once (130µs+511µs) by Moose::Meta::Role::Method::Conflicting::BEGIN@7 at line 7 of Moose/Meta/Role/Method/Conflicting.pm # once (124µs+510µs) by Moose::Role::BEGIN@8 at line 8 of Moose/Role.pm # once (124µs+485µs) by Moose::Util::BEGIN@8 at line 8 of Moose/Util.pm # once (125µs+478µs) by Moose::Meta::Class::BEGIN@26 at line 26 of Moose/Meta/Class.pm
my $import = sub {
712102011.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 ]
735853.24ms my $import_args = Data::OptList::mkopt([ @_ ]);
# spent 3.24ms making 85 calls to Data::OptList::mkopt, avg 38µ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
7408511.0ms my $collection = _collect_collections($config, $import_args, $class, $into);
# spent 11.0ms making 85 calls to Sub::Exporter::_collect_collections, avg 130µs/call
741
7428599.0ms my $to_import = _expand_groups($class, $config, $import_args, $collection);
# spent 99.0ms making 85 calls to Sub::Exporter::_expand_groups, avg 1.16ms/call
743
744 # now, finally $import_arg is really the "to do" list
74585471ms _do_import(
# spent 471ms making 85 calls to Sub::Exporter::_do_import, avg 5.54ms/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 471ms (54.4+417) within Sub::Exporter::_do_import which was called 85 times, avg 5.54ms/call: # 85 times (54.4ms+417ms) 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 5.54ms/call
sub _do_import {
762851252.8ms my ($arg, $to_import) = @_;
763
764 my @todo;
765
766 for my $pair (@$to_import) {
767 my ($name, $import_arg) = @$pair;
768
769 my ($generator, $as);
770
771529µs if ($import_arg and Params::Util::_CODELIKE($import_arg)) { ## no critic
# spent 29µs making 5 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
786908101ms my $code = $arg->{generator}->(
# spent 101ms making 908 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
79985308ms $arg->{installer}->(
# spent 303ms making 66 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:125], avg 4.58ms/call # spent 5.26ms making 19 calls to Sub::Exporter::default_installer, avg 277µ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 101ms (36.0+64.9) within Sub::Exporter::default_generator which was called 908 times, avg 111µs/call: # 908 times (36.0ms+64.9ms) by Sub::Exporter::_do_import at line 786, avg 111µs/call
sub default_generator {
844364339.6ms my ($arg) = @_;
845 my ($class, $name, $generator) = @$arg{qw(class name generator)};
846
847 if (not defined $generator) {
84811118µs my $code = $class->can($name)
# spent 118µs making 11 calls to UNIVERSAL::can, avg 11µ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
856179464.7ms return $generator->($class, $name, $arg->{arg}, $arg->{col})
# spent 51.6ms making 480 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:329], avg 107µs/call # spent 5.41ms making 5 calls to Sub::Exporter::__ANON__[Sub/Exporter.pm:937], avg 1.08ms/call # spent 4.20ms making 897 calls to Params::Util::_CODELIKE, avg 5µs/call # spent 3.53ms making 412 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:259], avg 9µ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 222ms (37.2+185) within Sub::Exporter::default_installer which was called 85 times, avg 2.61ms/call: # 64 times (34.8ms+174ms) by Moose::Exporter::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Exporter.pm:125] at line 117 of Moose/Exporter.pm, avg 3.26ms/call # 19 times (1.08ms+4.18ms) by Sub::Exporter::_do_import at line 799, avg 277µs/call # 2 times (1.29ms+6.55ms) by Sub::Exporter::_do_import at line 98 of Moose/Exporter.pm, avg 3.92ms/call
sub default_installer {
883297335.4ms my ($arg, $to_export) = @_;
884
885 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
891 if (ref $as eq 'SCALAR') {
892 $$as = $code;
893 } elsif (ref $as) {
894 Carp::croak "invalid reference type for $as: " . ref $as;
895 } else {
896906185ms Sub::Install::reinstall_sub({
# spent 185ms making 906 calls to Sub::Install::__ANON__[Sub/Install.pm:132], avg 204µ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),
9375100µs55.29ms
# spent 5.41ms (119µs+5.29) 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 5 times, avg 1.08ms/call: # 5 times (119µs+5.29ms) by Sub::Exporter::default_generator at line 856, avg 1.08ms/call
_import => sub { build_exporter($_[2]) },
# spent 5.29ms making 5 calls to Sub::Exporter::build_exporter, avg 1.06ms/call
938148µs11.44ms ],
# spent 1.44ms 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 184µs within Sub::Exporter::_setup which was called 5 times, avg 37µs/call: # 5 times (184µ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 37µs/call
sub _setup {
94620213µs my ($value, $arg) = @_;
947
948 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
- -
1101125µs"jn8:32"; # <-- magic true value
 
# spent 22µs within Sub::Exporter::CORE:match which was called 2 times, avg 11µs/call: # 2 times (22µs+0s) by Sub::Exporter::_assert_collector_names_ok at line 646, avg 11µs/call
sub Sub::Exporter::CORE:match; # opcode