Filename | /Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Meta/Attribute/Native.pm |
Statements | Executed 38 statements in 230µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 8µs | 8µs | BEGIN@2 | Moose::Meta::Attribute::Native::
1 | 1 | 1 | 6µs | 26µs | BEGIN@9 | Moose::Meta::Attribute::Native::
0 | 0 | 0 | 0s | 0s | __ANON__[:30] | Moose::Meta::Attribute::Native::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Moose::Meta::Attribute::Native; | ||||
2 | # spent 8µs within Moose::Meta::Attribute::Native::BEGIN@2 which was called:
# once (8µs+0s) by Moose::BEGIN@46 at line 4 | ||||
3 | 1 | 4µs | $Moose::Meta::Attribute::Native::AUTHORITY = 'cpan:STEVAN'; | ||
4 | 1 | 28µs | 1 | 8µs | } # spent 8µs making 1 call to Moose::Meta::Attribute::Native::BEGIN@2 |
5 | { | ||||
6 | 2 | 900ns | $Moose::Meta::Attribute::Native::VERSION = '2.1005'; | ||
7 | } | ||||
8 | |||||
9 | 2 | 142µs | 2 | 45µs | # spent 26µs (6+20) within Moose::Meta::Attribute::Native::BEGIN@9 which was called:
# once (6µs+20µs) by Moose::BEGIN@46 at line 9 # spent 26µs making 1 call to Moose::Meta::Attribute::Native::BEGIN@9
# spent 20µs making 1 call to Exporter::import |
10 | |||||
11 | 1 | 1µs | my @trait_names = qw(Bool Counter Number String Array Hash Code); | ||
12 | |||||
13 | 1 | 400ns | for my $trait_name (@trait_names) { | ||
14 | 7 | 3µs | my $trait_class = "Moose::Meta::Attribute::Native::Trait::$trait_name"; | ||
15 | 7 | 8µs | 7 | 355µs | my $meta = Class::MOP::Class->initialize( # spent 355µs making 7 calls to Class::MOP::Class::initialize, avg 51µs/call |
16 | "Moose::Meta::Attribute::Custom::Trait::$trait_name" | ||||
17 | ); | ||||
18 | 7 | 6µs | 7 | 387µs | if ($meta->find_method_by_name('register_implementation')) { # spent 387µs making 7 calls to Class::MOP::Class::find_method_by_name, avg 55µs/call |
19 | my $class = $meta->name->register_implementation; | ||||
20 | Moose->throw_error( | ||||
21 | "An implementation for $trait_name already exists " . | ||||
22 | "(found '$class' when trying to register '$trait_class')" | ||||
23 | ); | ||||
24 | } | ||||
25 | $meta->add_method(register_implementation => sub { | ||||
26 | # resolve_metatrait_alias will load classes anyway, but throws away | ||||
27 | # their error message; we WANT to die if there's a problem | ||||
28 | 1 | 1µs | 1 | 12.5ms | load_class($trait_class); # spent 12.5ms making 1 call to Class::Load::load_class |
29 | 1 | 3µs | return $trait_class; | ||
30 | 7 | 24µs | 7 | 281µs | }); # spent 281µs making 7 calls to Class::MOP::Mixin::HasMethods::add_method, avg 40µs/call |
31 | } | ||||
32 | |||||
33 | 1 | 9µs | 1; | ||
34 | |||||
35 | # ABSTRACT: Delegate to native Perl types | ||||
36 | |||||
37 | __END__ |