| File | /usr/lib/perl5/vendor_perl/5.10.1/i386-linux-thread-multi/MooseX/Role/WithOverloading/Meta/Role/Application.pm |
| Statements Executed | 898 |
| Statement Execution Time | 14.4ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 4 | 1 | 1 | 10.6ms | 54.0ms | MooseX::Role::WithOverloading::Meta::Role::Application::apply_overloading |
| 1 | 1 | 1 | 1.05ms | 102ms | MooseX::Role::WithOverloading::Meta::Role::Application::BEGIN@7 |
| 4 | 1 | 1 | 546µs | 546µs | MooseX::Role::WithOverloading::Meta::Role::Application::_build_overload_ops |
| 1 | 1 | 1 | 138µs | 4.32ms | MooseX::Role::WithOverloading::Meta::Role::Application::BEGIN@5 |
| 1 | 1 | 1 | 36µs | 171µs | MooseX::Role::WithOverloading::Meta::Role::Application::BEGIN@8 |
| 1 | 1 | 1 | 20µs | 20µs | MooseX::Role::WithOverloading::Meta::Role::Application::BEGIN@6 |
| 0 | 0 | 0 | 0s | 0s | MooseX::Role::WithOverloading::Meta::Role::Application::__ANON__[:27] |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package MooseX::Role::WithOverloading::Meta::Role::Application; | ||||
| 2 | 1 | 3µs | our $VERSION = '0.05'; | ||
| 3 | # ABSTRACT: Role application role for Roles which support overloading | ||||
| 4 | |||||
| 5 | 3 | 101µs | 2 | 8.50ms | # spent 4.32ms (138µs+4.18) within MooseX::Role::WithOverloading::Meta::Role::Application::BEGIN@5 which was called
# once (138µs+4.18ms) by Class::MOP::__ANON__[/usr/lib/perl5/vendor_perl/5.10.1/i386-linux-thread-multi/Class/MOP.pm:103] at line 5 # spent 4.32ms making 1 call to MooseX::Role::WithOverloading::Meta::Role::Application::BEGIN@5
# spent 4.18ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:389] |
| 6 | 3 | 150µs | 1 | 20µs | # spent 20µs within MooseX::Role::WithOverloading::Meta::Role::Application::BEGIN@6 which was called
# once (20µs+0s) by Class::MOP::__ANON__[/usr/lib/perl5/vendor_perl/5.10.1/i386-linux-thread-multi/Class/MOP.pm:103] at line 6 # spent 20µs making 1 call to MooseX::Role::WithOverloading::Meta::Role::Application::BEGIN@6 |
| 7 | 3 | 761µs | 2 | 119ms | # spent 102ms (1.05+101) within MooseX::Role::WithOverloading::Meta::Role::Application::BEGIN@7 which was called
# once (1.05ms+101ms) by Class::MOP::__ANON__[/usr/lib/perl5/vendor_perl/5.10.1/i386-linux-thread-multi/Class/MOP.pm:103] at line 7 # spent 102ms making 1 call to MooseX::Role::WithOverloading::Meta::Role::Application::BEGIN@7
# spent 17.0ms making 1 call to MooseX::Types::Base::import |
| 8 | 3 | 1.30ms | 2 | 306µs | # spent 171µs (36+135) within MooseX::Role::WithOverloading::Meta::Role::Application::BEGIN@8 which was called
# once (36µs+135µs) by Class::MOP::__ANON__[/usr/lib/perl5/vendor_perl/5.10.1/i386-linux-thread-multi/Class/MOP.pm:103] at line 8 # spent 171µs making 1 call to MooseX::Role::WithOverloading::Meta::Role::Application::BEGIN@8
# spent 135µs making 1 call to namespace::autoclean::import |
| 9 | |||||
| 10 | 1 | 63µs | 1 | 622µs | requires 'apply_methods'; # spent 622µs making 1 call to Moose::Role::requires |
| 11 | |||||
| 12 | |||||
| 13 | 1 | 20µs | 3 | 7.07ms | has overload_ops => ( # spent 5.72ms making 1 call to __TYPE__::ArrayRef
# spent 854µs making 1 call to Moose::Role::has
# spent 490µs making 1 call to __TYPE__::Str |
| 14 | is => 'ro', | ||||
| 15 | isa => ArrayRef[Str], | ||||
| 16 | builder => '_build_overload_ops', | ||||
| 17 | ); | ||||
| 18 | |||||
| 19 | # spent 546µs within MooseX::Role::WithOverloading::Meta::Role::Application::_build_overload_ops which was called 4 times, avg 137µs/call:
# 4 times (546µs+0s) by Moose::Meta::Attribute::_call_builder at line 412 of Moose/Meta/Attribute.pm, avg 137µs/call | ||||
| 20 | 60 | 568µs | return [map { split /\s+/ } values %overload::ops]; | ||
| 21 | } | ||||
| 22 | |||||
| 23 | |||||
| 24 | after apply_methods => sub { | ||||
| 25 | 4 | 14µs | my ($self, $role, $other) = @_; | ||
| 26 | 4 | 81µs | 4 | 54.0ms | $self->apply_overloading($role, $other); # spent 54.0ms making 4 calls to MooseX::Role::WithOverloading::Meta::Role::Application::apply_overloading, avg 13.5ms/call |
| 27 | 1 | 8µs | 1 | 108µs | }; # spent 108µs making 1 call to Moose::Role::after |
| 28 | |||||
| 29 | |||||
| 30 | # spent 54.0ms (10.6+43.4) within MooseX::Role::WithOverloading::Meta::Role::Application::apply_overloading which was called 4 times, avg 13.5ms/call:
# 4 times (10.6ms+43.4ms) by Class::MOP::Class:::after at line 26, avg 13.5ms/call | ||||
| 31 | 4 | 11µs | my ($self, $role, $other) = @_; | ||
| 32 | 4 | 178µs | 8 | 202µs | return unless overload::Overloaded($role->name); # spent 104µs making 4 calls to overload::Overloaded, avg 26µs/call
# spent 98µs making 4 calls to Class::MOP::Package::name, avg 25µs/call |
| 33 | |||||
| 34 | # overloading predicate method | ||||
| 35 | 4 | 104µs | 8 | 650µs | $other->add_package_symbol('&()' => $role->get_package_symbol('&()')); # spent 390µs making 4 calls to Class::MOP::Package::get_package_symbol, avg 98µs/call
# spent 260µs making 4 calls to Class::MOP::Package::add_package_symbol, avg 65µs/call |
| 36 | # fallback value | ||||
| 37 | 4 | 152µs | 12 | 1.03ms | $other->add_package_symbol('$()' => $role->get_package_symbol('$()')) # spent 420µs making 4 calls to Class::MOP::Package::get_package_symbol, avg 105µs/call
# spent 346µs making 4 calls to Class::MOP::Package::has_package_symbol, avg 87µs/call
# spent 267µs making 4 calls to Class::MOP::Package::add_package_symbol, avg 67µs/call |
| 38 | if $role->has_package_symbol('$()'); | ||||
| 39 | # register with magic by touching | ||||
| 40 | 4 | 53µs | 4 | 637µs | $other->get_package_symbol('%OVERLOAD')->{dummy}++; # spent 637µs making 4 calls to Class::MOP::Package::get_package_symbol, avg 159µs/call |
| 41 | |||||
| 42 | 4 | 1.50ms | 4 | 198µs | for my $op (@{ $self->overload_ops }) { # spent 169µs making 1 call to Class::MOP::Class::__ANON__::SERIAL::2::overload_ops
# spent 29µs making 3 calls to Class::MOP::Class::__ANON__::SERIAL::3::overload_ops, avg 10µs/call |
| 43 | 264 | 767µs | my $code_sym = '&(' . $op; | ||
| 44 | |||||
| 45 | 264 | 6.47ms | 528 | 23.6ms | next if overload::Method($other->name, $op); # spent 21.2ms making 264 calls to overload::Method, avg 80µs/call
# spent 2.37ms making 264 calls to Class::MOP::Package::name, avg 9µs/call |
| 46 | 260 | 2.03ms | 260 | 17.1ms | next unless $role->has_package_symbol($code_sym); # spent 17.1ms making 260 calls to Class::MOP::Package::has_package_symbol, avg 66µs/call |
| 47 | |||||
| 48 | my $meth = $role->get_package_symbol($code_sym); | ||||
| 49 | next unless $meth; | ||||
| 50 | |||||
| 51 | # when using "use overload $op => sub { };" this is the actual method | ||||
| 52 | # to be called on overloading. otherwise it's \&overload::nil. see | ||||
| 53 | # below. | ||||
| 54 | $other->add_package_symbol($code_sym => $meth); | ||||
| 55 | |||||
| 56 | # when using "use overload $op => 'method_name';" overload::nil is | ||||
| 57 | # installed into the code slot of the glob and the actual method called | ||||
| 58 | # is determined by the scalar slot of the same glob. | ||||
| 59 | if ($meth == \&overload::nil) { | ||||
| 60 | my $scalar_sym = qq{\$($op}; | ||||
| 61 | $other->add_package_symbol( | ||||
| 62 | $scalar_sym => ${ $role->get_package_symbol($scalar_sym) }, | ||||
| 63 | ); | ||||
| 64 | } | ||||
| 65 | } | ||||
| 66 | } | ||||
| 67 | |||||
| 68 | 1 | 44µs | 1; | ||
| 69 | |||||
| 70 | 1 | 54µs | 1 | 10.7ms | __END__ # spent 10.7ms making 1 call to B::Hooks::EndOfScope::__ANON__[B/Hooks/EndOfScope.pm:47] |
| 71 | |||||
| 72 | =pod | ||||
| 73 | |||||
| 74 | =head1 NAME | ||||
| 75 | |||||
| 76 | MooseX::Role::WithOverloading::Meta::Role::Application - Role application role for Roles which support overloading | ||||
| 77 | |||||
| 78 | =head1 VERSION | ||||
| 79 | |||||
| 80 | version 0.05 | ||||
| 81 | |||||
| 82 | =head1 METHODS | ||||
| 83 | |||||
| 84 | =head2 overload_ops | ||||
| 85 | |||||
| 86 | Returns an arrayref of the names of overloaded operations | ||||
| 87 | |||||
| 88 | |||||
| 89 | |||||
| 90 | =head2 apply_methods ($role, $other) | ||||
| 91 | |||||
| 92 | Wrapped with an after modifier which calls the C<< ->apply_overloading >> | ||||
| 93 | method. | ||||
| 94 | |||||
| 95 | |||||
| 96 | |||||
| 97 | =head2 apply_overloading ($role, $other) | ||||
| 98 | |||||
| 99 | Does the heavy lifting of applying overload operations to | ||||
| 100 | a class or role which the role is applied to. | ||||
| 101 | |||||
| 102 | |||||
| 103 | |||||
| 104 | =head1 AUTHORS | ||||
| 105 | |||||
| 106 | Florian Ragwitz <rafl@debian.org> | ||||
| 107 | Tomas Doran <bobtfish@bobtfish.net> | ||||
| 108 | |||||
| 109 | =head1 COPYRIGHT AND LICENSE | ||||
| 110 | |||||
| 111 | This software is copyright (c) 2010 by Florian Ragwitz. | ||||
| 112 | |||||
| 113 | This is free software; you can redistribute it and/or modify it under | ||||
| 114 | the same terms as the Perl 5 programming language system itself. | ||||
| 115 | |||||
| 116 | =cut | ||||
| 117 | |||||
| 118 |