← Index
NYTProf Performance Profile   « line view »
For ../prof.pl
  Run on Wed Dec 14 15:33:55 2022
Reported on Wed Dec 14 15:40:03 2022

Filename/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/MooX/TypeTiny/Role/GenerateAccessor.pm
StatementsExecuted 897 statements in 3.14ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
73111.97ms31.7msMooX::TypeTiny::Role::GenerateAccessor::::__ANON__[:33]MooX::TypeTiny::Role::GenerateAccessor::__ANON__[:33]
1711285µs1.65msMooX::TypeTiny::Role::GenerateAccessor::::__ANON__[:63]MooX::TypeTiny::Role::GenerateAccessor::__ANON__[:63]
7311204µs204µsMooX::TypeTiny::Role::GenerateAccessor::::CORE:substMooX::TypeTiny::Role::GenerateAccessor::CORE:subst (opcode)
21421121µs121µsMooX::TypeTiny::Role::GenerateAccessor::::CORE:matchMooX::TypeTiny::Role::GenerateAccessor::CORE:match (opcode)
11137µs465µsMooX::TypeTiny::Role::GenerateAccessor::::BEGIN@2MooX::TypeTiny::Role::GenerateAccessor::BEGIN@2
1117µs42µsMooX::TypeTiny::Role::GenerateAccessor::::BEGIN@3MooX::TypeTiny::Role::GenerateAccessor::BEGIN@3
1115µs18µsMooX::TypeTiny::Role::GenerateAccessor::::BEGIN@4MooX::TypeTiny::Role::GenerateAccessor::BEGIN@4
0000s0sMooX::TypeTiny::Role::GenerateAccessor::::_is_simple_valueMooX::TypeTiny::Role::GenerateAccessor::_is_simple_value
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package MooX::TypeTiny::Role::GenerateAccessor;
2236µs2489µs
# spent 465µs (37+428) within MooX::TypeTiny::Role::GenerateAccessor::BEGIN@2 which was called: # once (37µs+428µs) by Moo::_Utils::_require at line 2
use Moo::Role;
# spent 465µs making 1 call to MooX::TypeTiny::Role::GenerateAccessor::BEGIN@2 # spent 24µs making 1 call to Moo::Role::import
3226µs277µs
# spent 42µs (7+35) within MooX::TypeTiny::Role::GenerateAccessor::BEGIN@3 which was called: # once (7µs+35µs) by Moo::_Utils::_require at line 3
use Sub::Quote qw(quotify sanitize_identifier);
# spent 42µs making 1 call to MooX::TypeTiny::Role::GenerateAccessor::BEGIN@3 # spent 35µs making 1 call to Exporter::import
42718µs231µs
# spent 18µs (5+13) within MooX::TypeTiny::Role::GenerateAccessor::BEGIN@4 which was called: # once (5µs+13µs) by Moo::_Utils::_require at line 4
use Scalar::Util qw(blessed);
# spent 18µs making 1 call to MooX::TypeTiny::Role::GenerateAccessor::BEGIN@4 # spent 13µs making 1 call to Exporter::import
5
6
# spent 31.7ms (1.97+29.7) within MooX::TypeTiny::Role::GenerateAccessor::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/MooX/TypeTiny/Role/GenerateAccessor.pm:33] which was called 73 times, avg 434µs/call: # 73 times (1.97ms+29.7ms) by Method::Generate::Accessor__WITH__MooX::TypeTiny::Role::GenerateAccessor::__ANON__[(eval 200)[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Class/Method/Modifiers.pm:89]:1] at line 1 of (eval 200)[Class/Method/Modifiers.pm:89], avg 434µs/call
around _generate_isa_check => sub {
7 $Error::TypeTiny::CarpInternal{$_} = 1
873420µs14673µs for grep /\A(?:MooX?|Method::Generate)::/, keys %Carp::CarpInternal;
# spent 73µs making 146 calls to MooX::TypeTiny::Role::GenerateAccessor::CORE:match, avg 500ns/call
9
107340µs my $orig = shift;
117337µs my $self = shift;
127343µs my ($name, $value, $check, $init_arg) = @_;
1373399µs146634µs return $self->$orig(@_)
# spent 537µs making 73 calls to Type::Tiny::isa, avg 7µs/call # spent 97µs making 73 calls to Scalar::Util::blessed, avg 1µs/call
14 unless blessed $check && $check->isa('Type::Tiny');
15
1673130µs73572µs my $var = '$isa_check_for_'.sanitize_identifier($name);
# spent 572µs making 73 calls to Sub::Quote::sanitize_identifier, avg 8µs/call
177397µs $self->{captures}->{$var} = \$check;
18
1973148µs73335µs my $varname = defined $init_arg
# spent 335µs making 73 calls to Sub::Quote::quotify, avg 5µs/call
20 ? sprintf('$args->{%s}', quotify($init_arg))
21 : sprintf('$self->{%s}', quotify($name));
22
2373160µs7327.9ms my $assertion = $check->inline_assert(
# spent 27.9ms making 73 calls to Type::Tiny::inline_assert, avg 382µs/call
24 $value,
25 $var,
26 mgaca => 0,
27 attribute_name => $name,
28 attribute_step => 'isa check',
29 varname => $varname,
30 );
3173314µs73204µs $assertion =~ s/;\z//;
# spent 204µs making 73 calls to MooX::TypeTiny::Role::GenerateAccessor::CORE:subst, avg 3µs/call
3273214µs return $assertion;
3315µs117µs};
# spent 17µs making 1 call to Moo::Role::around
34
35
# spent 1.65ms (285µs+1.37) within MooX::TypeTiny::Role::GenerateAccessor::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/MooX/TypeTiny/Role/GenerateAccessor.pm:63] which was called 17 times, avg 97µs/call: # 17 times (285µs+1.37ms) by Method::Generate::Accessor__WITH__MooX::TypeTiny::Role::GenerateAccessor::__ANON__[(eval 204)[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Class/Method/Modifiers.pm:89]:1] at line 1 of (eval 200)[Class/Method/Modifiers.pm:89], avg 97µs/call
around _generate_coerce => sub {
36 $Error::TypeTiny::CarpInternal{$_} = 1
3717201µs6848µs for grep /\A(?:MooX?|Method::Generate)::/, keys %Carp::Internal;
# spent 48µs making 68 calls to MooX::TypeTiny::Role::GenerateAccessor::CORE:match, avg 706ns/call
38
391714µs my $orig = shift;
40173µs my $self = shift;
411719µs my ($name, $value, $coerce, $init_arg) = @_;
4217108µs341.32ms return $self->$orig(@_)
# spent 1.31ms making 17 calls to Method::Generate::Accessor::_generate_coerce, avg 77µs/call # spent 12µs making 17 calls to Scalar::Util::blessed, avg 706ns/call
43 unless blessed $coerce && $coerce->isa('Type::Coercion');
44
45 my $var = '$coercion_for_'.sanitize_identifier($name);
46 $self->{captures}->{$var} = \$coerce;
47
48 my $need_temp = !$self->_is_simple_value($value);
49 my $inline_value = $value;
50 if ($need_temp) {
51 $inline_value = $value;
52 $value = '$tmp';
53 }
54
55 my $code = $coerce->can_be_inlined ? $coerce->inline_coercion($value) : "${var}->coerce(${value})";
56
57 if ($need_temp) {
58 return "do { my \$tmp = $inline_value; $code }";
59 }
60 else {
61 return $code;
62 }
6312µs16µs};
# spent 6µs making 1 call to Moo::Role::around
64
65# this doesn't need to be perfect. false negatives are fine.
66sub _is_simple_value {
67 my ($self, $value) = @_;
68 return $value =~ /\A(?:
69 \$\w+(?:(?:->)?(?:\[[0-9]+\]|\{\w+\}))?
70 |
71 [-0-9_.ex]+
72 |
73 "[^\$\@"]*"
74 |
75 '[^']*'
76 |
77 undef\(\)
78 |
79 \(!1\)
80 )\z/x;
81}
82
8315µs1;
 
# spent 121µs within MooX::TypeTiny::Role::GenerateAccessor::CORE:match which was called 214 times, avg 565ns/call: # 146 times (73µs+0s) by MooX::TypeTiny::Role::GenerateAccessor::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/MooX/TypeTiny/Role/GenerateAccessor.pm:33] at line 8, avg 500ns/call # 68 times (48µs+0s) by MooX::TypeTiny::Role::GenerateAccessor::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/MooX/TypeTiny/Role/GenerateAccessor.pm:63] at line 37, avg 706ns/call
sub MooX::TypeTiny::Role::GenerateAccessor::CORE:match; # opcode
# spent 204µs within MooX::TypeTiny::Role::GenerateAccessor::CORE:subst which was called 73 times, avg 3µs/call: # 73 times (204µs+0s) by MooX::TypeTiny::Role::GenerateAccessor::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/MooX/TypeTiny/Role/GenerateAccessor.pm:33] at line 31, avg 3µs/call
sub MooX::TypeTiny::Role::GenerateAccessor::CORE:subst; # opcode