| File | /usr/local/lib/perl/5.10.0/Class/MOP/Method/Generated.pm |
| Statements Executed | 2119 |
| Total Time | 0.0323506000000001 seconds |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 139 | 6 | 3 | 25.8ms | 25.8ms | Class::MOP::Method::Generated::_eval_closure |
| 25 | 1 | 1 | 471µs | 588µs | Class::MOP::Method::Generated::_add_line_directive |
| 25 | 3 | 3 | 447µs | 7.29ms | Class::MOP::Method::Generated::_compile_code |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Method::Generated::BEGIN |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Method::Generated::_dump_source |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Method::Generated::_initialize_body |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Method::Generated::new |
| Line | Stmts. | Exclusive Time | Avg. | Code |
|---|---|---|---|---|
| 1 | ||||
| 2 | package Class::MOP::Method::Generated; | |||
| 3 | ||||
| 4 | 3 | 37µs | 12µs | use strict; # spent 14µs making 1 call to strict::import |
| 5 | 3 | 24µs | 8µs | use warnings; # spent 16µs making 1 call to warnings::import |
| 6 | ||||
| 7 | 3 | 61µs | 20µs | use Carp 'confess'; # spent 45µs making 1 call to Exporter::import |
| 8 | ||||
| 9 | 1 | 800ns | 800ns | our $VERSION = '1.09'; |
| 10 | 1 | 22µs | 22µs | $VERSION = eval $VERSION; |
| 11 | 1 | 500ns | 500ns | our $AUTHORITY = 'cpan:STEVAN'; |
| 12 | ||||
| 13 | 3 | 686µs | 229µs | use base 'Class::MOP::Method'; # spent 80µs making 1 call to base::import, max recursion depth 1 |
| 14 | ||||
| 15 | ## accessors | |||
| 16 | ||||
| 17 | sub new { | |||
| 18 | confess __PACKAGE__ . " is an abstract base class, you must provide a constructor."; | |||
| 19 | } | |||
| 20 | ||||
| 21 | 208 | 313µs | 2µs | sub is_inline { $_[0]{is_inline} } |
| 22 | ||||
| 23 | 25 | 46µs | 2µs | sub definition_context { $_[0]{definition_context} } |
| 24 | ||||
| 25 | sub _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 | |||
| 30 | 556 | 865µs | 2µs | my ($self, $__captures, $sub_body) = @_; |
| 31 | ||||
| 32 | my $code; | |||
| 33 | ||||
| 34 | 834 | 22.4ms | 27µs | my $e = do { |
| 35 | local $@; | |||
| 36 | local $SIG{__DIE__}; | |||
| 37 | my $source = join | |||
| 38 | "\n", ( | |||
| 39 | map { | |||
| 40 | 220 | 466µs | 2µs | /^([\@\%\$])/ |
| 41 | or die "capture key should start with \@, \% or \$: $_"; | |||
| 42 | q[my ] | |||
| 43 | . $_ . q[ = ] | |||
| 44 | . $1 | |||
| 45 | . q[{$__captures->{'] | |||
| 46 | . $_ . q['}};]; | |||
| 47 | } keys %$__captures | |||
| 48 | ), | |||
| 49 | $sub_body; | |||
| 50 | ||||
| 51 | $self->_dump_source($source) if $ENV{MOP_PRINT_SOURCE}; | |||
| 52 | ||||
| 53 | 1 | 6.45ms | 6.45ms | $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 |
| 54 | $@; | |||
| 55 | }; | |||
| 56 | ||||
| 57 | return ( $code, $e ); | |||
| 58 | } | |||
| 59 | ||||
| 60 | sub _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 | |||
| 90 | 150 | 427µs | 3µs | my ( $self, %args ) = @_; |
| 91 | ||||
| 92 | my ( $line, $file ); | |||
| 93 | ||||
| 94 | 34 | 49µs | 1µ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 |
| 95 | $line = $ctx->{line}; | |||
| 96 | if ( my $desc = $ctx->{description} ) { | |||
| 97 | $file = "$desc defined at $ctx->{file}"; | |||
| 98 | } else { | |||
| 99 | $file = $ctx->{file}; | |||
| 100 | } | |||
| 101 | } else { | |||
| 102 | ( $line, $file ) = ( 0, "generated method (unknown origin)" ); | |||
| 103 | } | |||
| 104 | ||||
| 105 | 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 | |||
| 109 | $code = join(@$code, ' ') if ref $code; | |||
| 110 | ||||
| 111 | 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 | |||
| 115 | 75 | 519µs | 7µs | my ( $self, %args ) = @_; |
| 116 | ||||
| 117 | 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 | ||||
| 119 | 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 | ||||
| 122 | 1 | 8µs | 8µs | 1; |
| 123 | ||||
| 124 | __END__ | |||
| 125 | ||||
| 126 | =pod | |||
| 127 | ||||
| 128 | =head1 NAME | |||
| 129 | ||||
| 130 | Class::MOP::Method::Generated - Abstract base class for generated methods | |||
| 131 | ||||
| 132 | =head1 DESCRIPTION | |||
| 133 | ||||
| 134 | This is a C<Class::MOP::Method> subclass which is subclassed by | |||
| 135 | C<Class::MOP::Method::Accessor> and | |||
| 136 | C<Class::MOP::Method::Constructor>. | |||
| 137 | ||||
| 138 | It is not intended to be used directly. | |||
| 139 | ||||
| 140 | =head1 AUTHORS | |||
| 141 | ||||
| 142 | Stevan Little E<lt>stevan@iinteractive.comE<gt> | |||
| 143 | ||||
| 144 | =head1 COPYRIGHT AND LICENSE | |||
| 145 | ||||
| 146 | Copyright 2006-2010 by Infinity Interactive, Inc. | |||
| 147 | ||||
| 148 | L<http://www.iinteractive.com> | |||
| 149 | ||||
| 150 | This library is free software; you can redistribute it and/or modify | |||
| 151 | it under the same terms as Perl itself. | |||
| 152 | ||||
| 153 | =cut | |||
| 154 |