← Index
NYTProf Performance Profile   « line view »
For /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/bin/perlcritic
  Run on Sat Mar 19 22:12:22 2016
Reported on Sat Mar 19 22:14:12 2016

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/PPI/Document/File.pm
StatementsExecuted 1312 statements in 9.08ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
144116.51ms13.3sPPI::Document::File::::newPPI::Document::File::new
29133739µs739µsPPI::Document::File::::filenamePPI::Document::File::filename
11113µs26µsPPI::Document::File::::BEGIN@20PPI::Document::File::BEGIN@20
1118µs8µsPPI::Document::File::::BEGIN@26PPI::Document::File::BEGIN@26
1117µs33µsPPI::Document::File::::BEGIN@22PPI::Document::File::BEGIN@22
1117µs36µsPPI::Document::File::::BEGIN@25PPI::Document::File::BEGIN@25
1113µs3µsPPI::Document::File::::BEGIN@23PPI::Document::File::BEGIN@23
1113µs3µsPPI::Document::File::::BEGIN@21PPI::Document::File::BEGIN@21
0000s0sPPI::Document::File::::savePPI::Document::File::save
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package PPI::Document::File;
2
3=pod
4
5=head1 NAME
6
7PPI::Document::File - A Perl Document located in a specific file
8
9=head1 DESCRIPTION
10
11B<WARNING: This class is experimental, and may change without notice>
12
13B<PPI::Document::File> provides a L<PPI::Document> subclass that represents
14a Perl document stored in a specific named file.
15
16=head1 METHODS
17
18=cut
19
20220µs238µs
# spent 26µs (13+13) within PPI::Document::File::BEGIN@20 which was called: # once (13µs+13µs) by PPI::BEGIN@24 at line 20
use strict;
# spent 26µs making 1 call to PPI::Document::File::BEGIN@20 # spent 13µs making 1 call to strict::import
21219µs13µs
# spent 3µs within PPI::Document::File::BEGIN@21 which was called: # once (3µs+0s) by PPI::BEGIN@24 at line 21
use Carp ();
# spent 3µs making 1 call to PPI::Document::File::BEGIN@21
22223µs258µs
# spent 33µs (7+25) within PPI::Document::File::BEGIN@22 which was called: # once (7µs+25µs) by PPI::BEGIN@24 at line 22
use Params::Util qw{_STRING _INSTANCE};
# spent 33µs making 1 call to PPI::Document::File::BEGIN@22 # spent 25µs making 1 call to Exporter::import
23220µs13µs
# spent 3µs within PPI::Document::File::BEGIN@23 which was called: # once (3µs+0s) by PPI::BEGIN@24 at line 23
use PPI::Document ();
# spent 3µs making 1 call to PPI::Document::File::BEGIN@23
24
25228µs264µs
# spent 36µs (7+29) within PPI::Document::File::BEGIN@25 which was called: # once (7µs+29µs) by PPI::BEGIN@24 at line 25
use vars qw{$VERSION @ISA};
# spent 36µs making 1 call to PPI::Document::File::BEGIN@25 # spent 29µs making 1 call to vars::import
26
# spent 8µs within PPI::Document::File::BEGIN@26 which was called: # once (8µs+0s) by PPI::BEGIN@24 at line 29
BEGIN {
271400ns $VERSION = '1.215';
2819µs @ISA = 'PPI::Document';
291149µs18µs}
# spent 8µs making 1 call to PPI::Document::File::BEGIN@26
30
- -
35#####################################################################
36# Constructor and Accessors
37
38=pod
39
40=head2 new
41
42 my $file = PPI::Document::File->new( 'Module.pm' );
43
44The C<new> constructor works the same as for the regular one, except
45that the only params allowed is a file name. You cannot create an
46"anonymous" PPI::Document::File object, not can you create an empty one.
47
48Returns a new PPI::Document::File object, or C<undef> on error.
49
50=cut
51
52
# spent 13.3s (6.51ms+13.2) within PPI::Document::File::new which was called 144 times, avg 92.0ms/call: # 144 times (6.51ms+13.2s) by Perl::Critic::Document::_init_from_external_source at line 106 of Perl/Critic/Document.pm, avg 92.0ms/call
sub new {
5314475µs my $class = shift;
54144603µs144218µs my $filename = _STRING(shift);
# spent 218µs making 144 calls to Params::Util::_STRING, avg 2µs/call
5514453µs unless ( defined $filename ) {
56 # Perl::Critic got a complaint about not handling a file
57 # named "0".
58 return $class->_error("Did not provide a file name to load");
59 }
60
61 # Load the Document
621444.48ms28813.2s my $self = $class->SUPER::new( $filename, @_ ) or return undef;
# spent 13.2s making 144 calls to PPI::Document::new, avg 92.0ms/call # spent 99µs making 144 calls to PPI::Util::TRUE, avg 686ns/call
63
64 # Unlike a normal inheritance situation, due to our need to stay
65 # compatible with caching magic, this actually returns a regular
66 # anonymous document. We need to rebless if
671441.76ms4321.16ms if ( _INSTANCE($self, 'PPI::Document') ) {
# spent 919µs making 144 calls to Params::Util::_INSTANCE, avg 6µs/call # spent 148µs making 144 calls to UNIVERSAL::isa, avg 1µs/call # spent 94µs making 144 calls to PPI::Util::TRUE, avg 653ns/call
68 bless $self, 'PPI::Document::File';
69 } else {
70 die "PPI::Document::File SUPER call returned an object of the wrong type";
71 }
72
73 # Save the filename
74144320µs $self->{filename} = $filename;
75
76144530µs $self;
77}
78
79=head2 filename
80
81The C<filename> accessor returns the name of the file in which the document
82is stored.
83
84=cut
85
86
# spent 739µs within PPI::Document::File::filename which was called 291 times, avg 3µs/call: # 144 times (414µs+0s) by PPI::Document::index_locations at line 611 of PPI/Document.pm, avg 3µs/call # 144 times (318µs+0s) by Perl::Critic::Document::filename at line 342 of Perl/Critic/Document.pm, avg 2µs/call # 3 times (6µs+0s) by Perl::Critic::Violation::new at line 86 of Perl/Critic/Violation.pm, avg 2µs/call
sub filename {
87291991µs $_[0]->{filename};
88}
89
90=pod
91
92=head2 save
93
94 # Save to the file we were loaded from
95 $file->save;
96
97 # Save a copy to somewhere else
98 $file->save( 'Module2.pm' );
99
100The C<save> method works similarly to the one in the parent L<PPI::Document>
101class, saving a copy of the document to a file.
102
103The difference with this subclass is that if C<save> is not passed any
104filename, it will save it back to the file it was loaded from.
105
106Note: When saving to a different file, it is considered to be saving a
107B<copy> and so the value returned by the C<filename> accessor will stay
108the same, and not change to the new filename.
109
110=cut
111
112sub save {
113 my $self = shift;
114
115 # Save to where?
116 my $filename = shift;
117 unless ( defined $filename ) {
118 $filename = $self->filename;
119 }
120
121 # Hand off to main save method
122 $self->SUPER::save( $filename, @_ );
123}
124
12512µs1;
126
127=pod
128
129=head1 TO DO
130
131- May need to overload some methods to forcefully prevent Document
132objects becoming children of another Node.
133
134=head1 SUPPORT
135
136See the L<support section|PPI/SUPPORT> in the main module.
137
138=head1 AUTHOR
139
140Adam Kennedy E<lt>adamk@cpan.orgE<gt>
141
142=head1 COPYRIGHT
143
144Copyright 2001 - 2011 Adam Kennedy.
145
146This program is free software; you can redistribute
147it and/or modify it under the same terms as Perl itself.
148
149The full text of the license can be found in the
150LICENSE file included with this module.
151
152=cut