← Index
Performance Profile   « block view • line view • sub view »
For t/test-parsing
  Run on Sun Nov 14 09:49:57 2010
Reported on Sun Nov 14 09:50:12 2010

File /usr/local/lib/perl/5.10.0/Class/MOP/Method/Generated.pm
Statements Executed 2118
Total Time 0.0323506 seconds
Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1396325.8ms25.8msClass::MOP::Method::Generated::::_eval_closureClass::MOP::Method::Generated::_eval_closure
2511471µs588µsClass::MOP::Method::Generated::::_add_line_directiveClass::MOP::Method::Generated::_add_line_directive
2533447µs7.29msClass::MOP::Method::Generated::::_compile_codeClass::MOP::Method::Generated::_compile_code
0000s0sClass::MOP::Method::Generated::::BEGINClass::MOP::Method::Generated::BEGIN
0000s0sClass::MOP::Method::Generated::::_dump_sourceClass::MOP::Method::Generated::_dump_source
0000s0sClass::MOP::Method::Generated::::_initialize_bodyClass::MOP::Method::Generated::_initialize_body
0000s0sClass::MOP::Method::Generated::::newClass::MOP::Method::Generated::new
LineStmts.Exclusive
Time
Avg.Code
1
2package Class::MOP::Method::Generated;
3
4337µs12µsuse strict;
# spent 14µs making 1 call to strict::import
5324µs8µsuse warnings;
# spent 16µs making 1 call to warnings::import
6
7361µs20µsuse Carp 'confess';
# spent 45µs making 1 call to Exporter::import
8
91800ns800nsour $VERSION = '1.09';
10122µs22µs$VERSION = eval $VERSION;
111500ns500nsour $AUTHORITY = 'cpan:STEVAN';
12
133686µs229µsuse base 'Class::MOP::Method';
# spent 80µs making 1 call to base::import, max recursion depth 1
14
15## accessors
16
17sub new {
18 confess __PACKAGE__ . " is an abstract base class, you must provide a constructor.";
19}
20
21208313µs2µssub is_inline { $_[0]{is_inline} }
22
232546µs2µssub definition_context { $_[0]{definition_context} }
24
25sub _initialize_body {
26 confess "No body to initialize, " . __PACKAGE__ . " is an abstract base class";
27}
28
29
# spent 25.8ms within Class::MOP::Method::Generated::_eval_closure which was called 139 times, avg 186µs/call: # 52 times (5.36ms+0s) by Class::MOP::Method::Accessor::_generate_reader_method_inline at line 152 of /usr/local/lib/perl/5.10.0/Class/MOP/Method/Accessor.pm, avg 103µs/call # 31 times (11.2ms+0s) by Class::MOP::Method::Constructor::_generate_constructor_method_inline at line 121 of /usr/local/lib/perl/5.10.0/Class/MOP/Method/Constructor.pm, avg 361µs/call # 25 times (6.26ms+0s) by Class::MOP::Method::Generated::_compile_code at line 119, avg 250µs/call # 15 times (1.65ms+0s) by Class::MOP::Method::Accessor::_generate_accessor_method_inline at line 136 of /usr/local/lib/perl/5.10.0/Class/MOP/Method/Accessor.pm, avg 110µs/call # 13 times (1.10ms+0s) by Class::MOP::Method::Accessor::_generate_predicate_method_inline at line 180 of /usr/local/lib/perl/5.10.0/Class/MOP/Method/Accessor.pm, avg 85µs/call # 3 times (275µs+0s) by Class::MOP::Method::Accessor::_generate_writer_method_inline at line 167 of /usr/local/lib/perl/5.10.0/Class/MOP/Method/Accessor.pm, avg 92µs/call
sub _eval_closure {
30139386µs3µs my ($self, $__captures, $sub_body) = @_;
31
3213934µs242ns my $code;
33
34139134µs964ns my $e = do {
3513966µs473ns local $@;
36139692µs5µs local $SIG{__DIE__};
37110237µs2µs my $source = join
38 "\n", (
39 map {
40139550µs4µs /^([\@\%\$])/
41 or die "capture key should start with \@, \% or \$: $_";
42110229µs2µs q[my ]
43 . $_ . q[ = ]
44 . $1
45 . q[{$__captures->{']
46 . $_ . q['}};];
47 } keys %$__captures
48 ),
49 $sub_body;
50
51139151µs1µs $self->_dump_source($source) if $ENV{MOP_PRINT_SOURCE};
52
5313927.0ms194µs $code = eval $source;
# spent 2.93ms making 7 calls to Class::MOP::Class::new_object, avg 419µs/call # spent 91µs making 7 calls to Class::MOP::Class::initialize, avg 13µs/call # spent 52µs making 8 calls to Moose::Meta::TypeConstraint::__ANON__[/usr/local/lib/perl/5.10.0/Moose/Meta/TypeConstraint.pm:32], avg 7µs/call # spent 46µs making 8 calls to Class::MOP::__ANON__[/usr/local/lib/perl/5.10.0/Class/MOP.pm:509], avg 6µs/call
54139350µs3µs $@;
55 };
56
57139311µs2µs return ( $code, $e );
58}
59
60sub _dump_source {
61 my ( $self, $source ) = @_;
62
63 my $output;
64 if ( eval { require Perl::Tidy } ) {
65 require File::Spec;
66
67 my $rc_file = File::Spec->catfile(
68 $INC{'Class/MOP/Method/Generated.pm'},
69 ('..') x 5,
70 'perltidyrc'
71 );
72
73 my %p = (
74 source => \$source,
75 destination => \$output,
76 );
77 $p{perltidyrc} = $rc_file
78 if -f $rc_file;
79
80 Perl::Tidy::perltidy(%p);
81 }
82 else {
83 $output = $source;
84 }
85
86 print STDERR "\n", $self->name, ":\n", $output, "\n";
87}
88
89
# spent 588µs (471+118) within Class::MOP::Method::Generated::_add_line_directive which was called 25 times, avg 24µs/call: # 25 times (471µs+118µs) by Class::MOP::Method::Generated::_compile_code at line 117, avg 24µs/call
sub _add_line_directive {
902582µs3µs my ( $self, %args ) = @_;
91
922514µs560ns my ( $line, $file );
93
9425180µs7µs if ( my $ctx = ( $args{context} || $self->definition_context ) ) {
# spent 118µs making 25 calls to Class::MOP::Method::Generated::definition_context, avg 5µs/call
9597µs800ns $line = $ctx->{line};
96925µs3µs if ( my $desc = $ctx->{description} ) {
97 $file = "$desc defined at $ctx->{file}";
98 } else {
99 $file = $ctx->{file};
100 }
101 } else {
1021617µs1µs ( $line, $file ) = ( 0, "generated method (unknown origin)" );
103 }
104
1052526µs1µs my $code = $args{code};
106
107 # if it's an array of lines, join it up
108 # don't use newlines so that the definition context is more meaningful
1092515µs620ns $code = join(@$code, ' ') if ref $code;
110
11125109µs4µs return qq{#line $line "$file"\n} . $code;
112}
113
114
# spent 7.29ms (447µs+6.84) within Class::MOP::Method::Generated::_compile_code which was called 25 times, avg 292µs/call: # 11 times (192µs+2.80ms) by Moose::Meta::Method::Accessor::_eval_code at line 24 of /usr/local/lib/perl/5.10.0/Moose/Meta/Method/Accessor.pm, avg 272µs/call # 7 times (126µs+3.09ms) by Moose::Meta::Method::Constructor::_initialize_body at line 100 of /usr/local/lib/perl/5.10.0/Moose/Meta/Method/Constructor.pm, avg 460µs/call # 7 times (129µs+948µs) by Moose::Meta::Method::Destructor::_initialize_body at line 111 of /usr/local/lib/perl/5.10.0/Moose/Meta/Method/Destructor.pm, avg 154µs/call
sub _compile_code {
11525114µs5µs my ( $self, %args ) = @_;
116
11725177µs7µs my $code = $self->_add_line_directive(%args);
# spent 588µs making 25 calls to Class::MOP::Method::Generated::_add_line_directive, avg 24µs/call
118
11925228µs9µs return $self->_eval_closure($args{environment}, $code);
# spent 6.26ms making 25 calls to Class::MOP::Method::Generated::_eval_closure, avg 250µs/call
120}
121
12218µs8µs1;
123
124__END__
125
126=pod
127
128=head1 NAME
129
130Class::MOP::Method::Generated - Abstract base class for generated methods
131
132=head1 DESCRIPTION
133
134This is a C<Class::MOP::Method> subclass which is subclassed by
135C<Class::MOP::Method::Accessor> and
136C<Class::MOP::Method::Constructor>.
137
138It is not intended to be used directly.
139
140=head1 AUTHORS
141
142Stevan Little E<lt>stevan@iinteractive.comE<gt>
143
144=head1 COPYRIGHT AND LICENSE
145
146Copyright 2006-2010 by Infinity Interactive, Inc.
147
148L<http://www.iinteractive.com>
149
150This library is free software; you can redistribute it and/or modify
151it under the same terms as Perl itself.
152
153=cut
154