Filename | /Users/ap13/perl5/lib/perl5/darwin-2level/Moose/Meta/Attribute/Native.pm |
Statements | Executed 38 statements in 305µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 14µs | 26µs | BEGIN@1 | Moose::
1 | 1 | 1 | 10µs | 27µs | BEGIN@6 | Moose::Meta::Attribute::Native::
1 | 1 | 1 | 7µs | 11µs | BEGIN@2 | Moose::
0 | 0 | 0 | 0s | 0s | __ANON__[:26] | Moose::Meta::Attribute::Native::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | 2 | 22µs | 2 | 38µs | # spent 26µs (14+12) within Moose::BEGIN@1 which was called:
# once (14µs+12µs) by Moose::BEGIN@43 at line 1 # spent 26µs making 1 call to Moose::BEGIN@1
# spent 12µs making 1 call to strict::import |
2 | 2 | 47µs | 2 | 15µs | # spent 11µs (7+4) within Moose::BEGIN@2 which was called:
# once (7µs+4µs) by Moose::BEGIN@43 at line 2 # spent 11µs making 1 call to Moose::BEGIN@2
# spent 4µs making 1 call to warnings::import |
3 | package Moose::Meta::Attribute::Native; | ||||
4 | 1 | 600ns | our $VERSION = '2.1403'; | ||
5 | |||||
6 | 2 | 150µs | 2 | 44µs | # spent 27µs (10+17) within Moose::Meta::Attribute::Native::BEGIN@6 which was called:
# once (10µs+17µs) by Moose::BEGIN@43 at line 6 # spent 27µs making 1 call to Moose::Meta::Attribute::Native::BEGIN@6
# spent 17µs making 1 call to Module::Runtime::import |
7 | |||||
8 | 1 | 2µs | my @trait_names = qw(Bool Counter Number String Array Hash Code); | ||
9 | |||||
10 | 1 | 500ns | for my $trait_name (@trait_names) { | ||
11 | 7 | 5µs | my $trait_class = "Moose::Meta::Attribute::Native::Trait::$trait_name"; | ||
12 | 7 | 20µs | 7 | 569µs | my $meta = Class::MOP::Class->initialize( # spent 569µs making 7 calls to Class::MOP::Class::initialize, avg 81µs/call |
13 | "Moose::Meta::Attribute::Custom::Trait::$trait_name" | ||||
14 | ); | ||||
15 | |||||
16 | 7 | 9µs | 7 | 587µs | if ($meta->find_method_by_name('register_implementation')) { # spent 587µs making 7 calls to Class::MOP::Class::find_method_by_name, avg 84µs/call |
17 | my $class = $meta->name->register_implementation; | ||||
18 | die "An implementation for $trait_name already exists " . | ||||
19 | "(found '$class' when trying to register '$trait_class')" | ||||
20 | } | ||||
21 | $meta->add_method(register_implementation => sub { | ||||
22 | # resolve_metatrait_alias will load classes anyway, but throws away | ||||
23 | # their error message; we WANT to die if there's a problem | ||||
24 | require_module($trait_class); | ||||
25 | return $trait_class; | ||||
26 | 7 | 26µs | 7 | 383µs | }); # spent 383µs making 7 calls to Class::MOP::Mixin::HasMethods::add_method, avg 55µs/call |
27 | } | ||||
28 | |||||
29 | 1 | 23µs | 1; | ||
30 | |||||
31 | # ABSTRACT: Delegate to native Perl types | ||||
32 | |||||
33 | __END__ |