← Index
NYTProf Performance Profile   « block view • line view • sub view »
For conv.pl
  Run on Sun Nov 14 21:14:18 2010
Reported on Sun Nov 14 21:17:51 2010

Filename/usr/share/perl5/MARC/File.pm
StatementsExecuted 40027 statements in 139ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
50001190.9ms90.8sMARC::File::::nextMARC::File::next
50001150.1ms50.1msMARC::File::::warningsMARC::File::warnings
111191µs195µsMARC::File::::BEGIN@10MARC::File::BEGIN@10
11150µs68µsMARC::File::::inMARC::File::in
11122µs27µsMARC::File::::BEGIN@9MARC::File::BEGIN@9
11118µs18µsMARC::File::::CORE:openMARC::File::CORE:open (opcode)
11116µs28µsMARC::File::::BEGIN@57MARC::File::BEGIN@57
11112µs49µsMARC::File::::BEGIN@12MARC::File::BEGIN@12
0000s0sMARC::File::::_gripeMARC::File::_gripe
0000s0sMARC::File::::_unimplementedMARC::File::_unimplemented
0000s0sMARC::File::::_warnMARC::File::_warn
0000s0sMARC::File::::closeMARC::File::close
0000s0sMARC::File::::decodeMARC::File::decode
0000s0sMARC::File::::outMARC::File::out
0000s0sMARC::File::::skipMARC::File::skip
0000s0sMARC::File::::writeMARC::File::write
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package MARC::File;
2
3=head1 NAME
4
- -
9345µs232µs
# spent 27µs (22+5) within MARC::File::BEGIN@9 which was called: # once (22µs+5µs) by base::import at line 9
use strict;
# spent 27µs making 1 call to MARC::File::BEGIN@9 # spent 5µs making 1 call to strict::import
103213µs2199µs
# spent 195µs (191+4) within MARC::File::BEGIN@10 which was called: # once (191µs+4µs) by base::import at line 10
use integer;
# spent 195µs making 1 call to MARC::File::BEGIN@10 # spent 4µs making 1 call to integer::import
11
12395µs286µs
# spent 49µs (12+37) within MARC::File::BEGIN@12 which was called: # once (12µs+37µs) by base::import at line 12
use vars qw( $ERROR );
# spent 49µs making 1 call to MARC::File::BEGIN@12 # spent 37µs making 1 call to vars::import
13
14=head1 SYNOPSIS
15
- -
51
# spent 68µs (50+18) within MARC::File::in which was called: # once (50µs+18µs) by MARC::Batch::next at line 150 of MARC/Batch.pm
sub in {
52722µs my $class = shift;
53 my $arg = shift;
54 my ( $filename, $fh );
55
56 ## if a valid filehandle was passed in
574695µs240µs
# spent 28µs (16+12) within MARC::File::BEGIN@57 which was called: # once (16µs+12µs) by base::import at line 57
my $ishandle = do { no strict; defined fileno($arg); };
# spent 28µs making 1 call to MARC::File::BEGIN@57 # spent 12µs making 1 call to strict::unimport
5837µs if ( $ishandle ) {
59 $filename = scalar( $arg );
60 $fh = $arg;
61 }
62
63 ## otherwise check if it's a filename, and
64 ## return undef if we weren't able to open it
65 else {
66 $filename = $arg;
67333µs118µs $fh = eval { local *FH; open( FH, $arg ) or die; *FH{IO}; };
# spent 18µs making 1 call to MARC::File::CORE:open
68 if ( $@ ) {
69 $MARC::File::ERROR = "Couldn't open $filename: $@";
70 return;
71 }
72 }
73
74 my $self = {
75 filename => $filename,
76 fh => $fh,
77 recnum => 0,
78 warnings => [],
79 };
80
81 return( bless $self, $class );
82
83} # new()
84
85sub out {
86 die "Not yet written";
87}
88
89=head2 next( [\&filter_func] )
90
- -
101
# spent 90.8s (90.9ms+90.8) within MARC::File::next which was called 5000 times, avg 18.2ms/call: # 5000 times (90.9ms+90.8s) by MARC::Batch::next at line 111 of MARC/Batch.pm, avg 18.2ms/call
sub next {
1022000086.5ms my $self = shift;
103 $self->{recnum}++;
1045000482ms my $rec = $self->_next() or return;
# spent 482ms making 5000 calls to MARC::File::XML::_next, avg 96µs/call
105500090.3s return $self->decode($rec, @_);
# spent 90.3s making 5000 calls to MARC::File::XML::decode, avg 18.1ms/call
106}
107
108=head2 skip()
109
- -
118sub skip {
119 my $self = shift;
120 my $rec = $self->_next() or return;
121 return 1;
122}
123
124=head2 warnings()
125
- -
132
# spent 50.1ms within MARC::File::warnings which was called 5000 times, avg 10µs/call: # 5000 times (50.1ms+0s) by MARC::Batch::next at line 117 of MARC/Batch.pm, avg 10µs/call
sub warnings {
1332000051.8ms my $self = shift;
134 my @warnings = @{ $self->{warnings} };
135 $self->{warnings} = [];
136 return(@warnings);
137}
138
139=head2 close()
140
- -
145sub close {
146 my $self = shift;
147 close( $self->{fh} );
148 delete $self->{fh};
149 delete $self->{filename};
150 return;
151}
152
153sub _unimplemented() {
154 my $self = shift;
155 my $method = shift;
156 warn "Method $method must be overridden";
157}
158
159=head2 write()
160
- -
171sub write { $_[0]->_unimplemented("write"); }
172sub decode { $_[0]->_unimplemented("decode"); }
173
174# NOTE: _warn must be called as an object method
175
176sub _warn {
177 my ($self,$warning) = @_;
178 push( @{ $self->{warnings} }, "$warning in record ".$self->{recnum} );
179 return( $self );
180}
181
182# NOTE: _gripe can be called as an object method, or not. Your choice.
183# NOTE: it's use is now depracated use _warn instead
184sub _gripe(@) {
185 my @parms = @_;
186 if ( @parms ) {
187 my $self = shift @parms;
188
189 if ( ref($self) =~ /^MARC::File/ ) {
190 push( @parms, " at byte ", tell($self->{fh}) )
191 if $self->{fh};
192 push( @parms, " in file ", $self->{filename} ) if $self->{filename};
193 } else {
194 unshift( @parms, $self );
195 }
196
197 $ERROR = join( "", @parms );
198 warn $ERROR;
199 }
200
201 return;
202}
203
20414µs1;
205
206__END__
 
# spent 18µs within MARC::File::CORE:open which was called: # once (18µs+0s) by MARC::File::in at line 67
sub MARC::File::CORE:open; # opcode