| Filename | /home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/Sub/Exporter.pm |
| Statements | Executed 25220 statements in 231ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 85 | 1 | 1 | 54.4ms | 471ms | Sub::Exporter::_do_import |
| 85 | 3 | 2 | 37.2ms | 222ms | Sub::Exporter::default_installer |
| 908 | 1 | 1 | 36.0ms | 101ms | Sub::Exporter::default_generator |
| 225 | 2 | 1 | 35.9ms | 99.0ms | Sub::Exporter::_expand_groups (recurses: max depth 2, inclusive time 109ms) |
| 1188 | 2 | 1 | 16.7ms | 16.7ms | Sub::Exporter::_group_name |
| 140 | 1 | 1 | 14.1ms | 89.5ms | Sub::Exporter::_expand_group (recurses: max depth 1, inclusive time 67.9ms) |
| 85 | 20 | 18 | 12.3ms | 596ms | Sub::Exporter::__ANON__[:756] |
| 85 | 1 | 1 | 7.15ms | 11.0ms | Sub::Exporter::_collect_collections |
| 85 | 1 | 1 | 3.23ms | 3.23ms | Sub::Exporter::_mk_collection_builder |
| 10 | 1 | 1 | 1.70ms | 14.1ms | Sub::Exporter::_rewrite_build_config |
| 10 | 3 | 2 | 467µs | 14.6ms | Sub::Exporter::build_exporter |
| 10 | 1 | 1 | 444µs | 444µs | Sub::Exporter::_key_intersection |
| 5 | 1 | 1 | 427µs | 647µs | Sub::Exporter::__ANON__[:544] |
| 10 | 1 | 1 | 248µs | 270µs | Sub::Exporter::_assert_collector_names_ok |
| 5 | 1 | 1 | 184µs | 184µs | Sub::Exporter::_setup |
| 2 | 2 | 2 | 138µs | 2.86ms | Sub::Exporter::setup_exporter |
| 1 | 1 | 1 | 131µs | 131µs | Eval::Closure::BEGIN@1 |
| 5 | 1 | 1 | 119µs | 5.41ms | Sub::Exporter::__ANON__[:937] |
| 1 | 1 | 1 | 64µs | 64µs | Sub::Exporter::BEGIN@636 |
| 1 | 1 | 1 | 50µs | 67µs | Eval::Closure::BEGIN@2.1 |
| 1 | 1 | 1 | 38µs | 85µs | Sub::Exporter::BEGIN@9 |
| 1 | 1 | 1 | 36µs | 101µs | Eval::Closure::BEGIN@3 |
| 2 | 1 | 1 | 22µs | 22µs | Sub::Exporter::CORE:match (opcode) |
| 1 | 1 | 1 | 18µs | 18µs | Sub::Exporter::BEGIN@6 |
| 1 | 1 | 1 | 18µs | 18µs | Sub::Exporter::BEGIN@7 |
| 1 | 1 | 1 | 17µs | 17µs | Sub::Exporter::BEGIN@8 |
| 0 | 0 | 0 | 0s | 0s | Sub::Exporter::__ANON__[:773] |
| 0 | 0 | 0 | 0s | 0s | Sub::Exporter::default_exporter |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | 3 | 159µs | 1 | 131µs | # spent 131µs within Eval::Closure::BEGIN@1 which was called:
# once (131µs+0s) by Eval::Closure::BEGIN@7 at line 1 # spent 131µs making 1 call to Eval::Closure::BEGIN@1 |
| 2 | 3 | 87µs | 2 | 84µ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 # spent 67µs making 1 call to Eval::Closure::BEGIN@2.1
# spent 17µs making 1 call to strict::import |
| 3 | 3 | 112µs | 2 | 167µ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 # spent 101µs making 1 call to Eval::Closure::BEGIN@3
# spent 65µs making 1 call to warnings::import |
| 4 | package Sub::Exporter; | ||||
| 5 | |||||
| 6 | 3 | 74µs | 1 | 18µs | # spent 18µs within Sub::Exporter::BEGIN@6 which was called:
# once (18µs+0s) by Eval::Closure::BEGIN@7 at line 6 # spent 18µs making 1 call to Sub::Exporter::BEGIN@6 |
| 7 | 3 | 83µs | 1 | 18µs | # spent 18µs within Sub::Exporter::BEGIN@7 which was called:
# once (18µs+0s) by Eval::Closure::BEGIN@7 at line 7 # spent 18µs making 1 call to Sub::Exporter::BEGIN@7 |
| 8 | 3 | 80µs | 1 | 17µs | # spent 17µs within Sub::Exporter::BEGIN@8 which was called:
# once (17µs+0s) by Eval::Closure::BEGIN@7 at line 8 # spent 17µs making 1 call to Sub::Exporter::BEGIN@8 |
| 9 | 3 | 4.34ms | 2 | 132µ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 # 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 | |||||
| - - | |||||
| 21 | 1 | 5µs | our $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 | sub _group_name { | ||||
| 404 | 2656 | 20.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 | ||||
| 415 | 3586 | 32.7ms | my ($class, $config, $groups, $collection, $seen, $merge) = @_; | ||
| 416 | $seen ||= {}; | ||||
| 417 | $merge ||= {}; | ||||
| 418 | my @groups = @$groups; | ||||
| 419 | |||||
| 420 | for my $i (reverse 0 .. $#groups) { | ||||
| 421 | 1048 | 14.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 | |||||
| 424 | 140 | 89.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 | ||||
| 457 | 1540 | 14.3ms | my ($class, $config, $group, $collection, $seen, $merge) = @_; | ||
| 458 | $merge ||= {}; | ||||
| 459 | |||||
| 460 | my ($group_name, $group_arg) = @$group; | ||||
| 461 | 140 | 2.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 | |||||
| 481 | 280 | 1.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 { | ||||
| 505 | 140 | 30.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 @{ | ||||
| 509 | 140 | 0s | _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 | ||||
| 515 | 340 | 3.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 | ||||
| 520 | 45 | 452µ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"; | ||||
| 536 | 5 | 36µ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 { | ||||
| 539 | 5 | 184µ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 | ||||
| 550 | 600 | 7.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 = {}; | ||||
| 560 | 85 | 3.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) { | ||||
| 562 | 5 | 647µ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 | ||||
| 594 | 12 | 132µ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 | |||||
| 605 | 2 | 2.25ms | my $import = build_exporter($config); # spent 2.25ms making 2 calls to Sub::Exporter::build_exporter, avg 1.12ms/call | ||
| 606 | |||||
| 607 | 2 | 481µ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 | ||||
| 626 | 30 | 479µ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. | ||||
| 635 | 1 | 2µs | my %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 | ||||
| 637 | %valid_config_key = | ||||
| 638 | 1 | 68µs | map { $_ => 1 } | ||
| 639 | qw(as collectors installer generator exports groups into into_level), | ||||
| 640 | qw(exporter), # deprecated | ||||
| 641 | 1 | 3.98ms | 1 | 64µ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 | ||||
| 644 | 22 | 306µs | my ($collectors) = @_; | ||
| 645 | |||||
| 646 | 2 | 22µ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 | ||||
| 653 | 150 | 1.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)) { | ||||
| 672 | 20 | 8.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 | |||||
| 679 | 10 | 270µ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 | |||||
| 681 | 10 | 444µ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 | |||||
| 685 | 10 | 3.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 | ||||
| 707 | 40 | 478µs | my ($config) = @_; | ||
| 708 | |||||
| 709 | 10 | 14.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 | ||||
| 712 | 1020 | 11.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 ] | ||||
| 735 | 85 | 3.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 | |||||
| 740 | 85 | 11.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 | |||||
| 742 | 85 | 99.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 | ||||
| 745 | 85 | 471ms | _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 | ||||
| 762 | 8512 | 52.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 | |||||
| 771 | 5 | 29µ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 | |||||
| 786 | 908 | 101ms | 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 | |||||
| 799 | 85 | 308ms | $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 | ||||
| 844 | 3643 | 39.6ms | my ($arg) = @_; | ||
| 845 | my ($class, $name, $generator) = @$arg{qw(class name generator)}; | ||||
| 846 | |||||
| 847 | if (not defined $generator) { | ||||
| 848 | 11 | 118µ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 | ||||
| 856 | 1794 | 64.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 | ||||
| 883 | 2973 | 35.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 { | ||||
| 896 | 906 | 185ms | 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 | |||||
| 905 | sub 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 | |||||
| - - | |||||
| 934 | setup_exporter({ | ||||
| 935 | exports => [ | ||||
| 936 | qw(setup_exporter build_exporter), | ||||
| 937 | 5 | 100µs | 5 | 5.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 # spent 5.29ms making 5 calls to Sub::Exporter::build_exporter, avg 1.06ms/call |
| 938 | 1 | 48µs | 1 | 1.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 | ||||
| 946 | 20 | 213µ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 | |||||
| - - | |||||
| 1101 | 1 | 25µ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 |