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

Filename/usr/share/perl5/MARC/File.pm
StatementsExecuted 40027 statements in 123ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
50001180.5ms17.9sMARC::File::::nextMARC::File::next
50001143.1ms43.1msMARC::File::::warningsMARC::File::warnings
111206µs211µsMARC::File::::BEGIN@10MARC::File::BEGIN@10
11150µs79µsMARC::File::::inMARC::File::in
11129µs29µsMARC::File::::CORE:openMARC::File::CORE:open (opcode)
11122µs27µsMARC::File::::BEGIN@9MARC::File::BEGIN@9
11115µs54µsMARC::File::::BEGIN@12MARC::File::BEGIN@12
11114µs25µsMARC::File::::BEGIN@57MARC::File::BEGIN@57
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
- -
9339µ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
103227µs2216µs
# spent 211µs (206+5) within MARC::File::BEGIN@10 which was called: # once (206µs+5µs) by base::import at line 10
use integer;
# spent 211µs making 1 call to MARC::File::BEGIN@10 # spent 5µs making 1 call to integer::import
11
12388µs293µs
# spent 54µs (15+39) within MARC::File::BEGIN@12 which was called: # once (15µs+39µs) by base::import at line 12
use vars qw( $ERROR );
# spent 54µs making 1 call to MARC::File::BEGIN@12 # spent 39µs making 1 call to vars::import
13
14=head1 SYNOPSIS
15
- -
51
# spent 79µs (50+29) within MARC::File::in which was called: # once (50µs+29µs) by MARC::Batch::next at line 150 of MARC/Batch.pm
sub in {
52726µs my $class = shift;
53 my $arg = shift;
54 my ( $filename, $fh );
55
56 ## if a valid filehandle was passed in
574705µs236µs
# spent 25µs (14+11) within MARC::File::BEGIN@57 which was called: # once (14µs+11µs) by base::import at line 57
my $ishandle = do { no strict; defined fileno($arg); };
# spent 25µs making 1 call to MARC::File::BEGIN@57 # spent 11µs making 1 call to strict::unimport
5836µ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;
67342µs129µs $fh = eval { local *FH; open( FH, $arg ) or die; *FH{IO}; };
# spent 29µ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 17.9s (80.5ms+17.8) within MARC::File::next which was called 5000 times, avg 3.58ms/call: # 5000 times (80.5ms+17.8s) by MARC::Batch::next at line 111 of MARC/Batch.pm, avg 3.58ms/call
sub next {
1022000075.5ms my $self = shift;
103 $self->{recnum}++;
1045000419ms my $rec = $self->_next() or return;
# spent 419ms making 5000 calls to MARC::File::XML::_next, avg 84µs/call
1051500017.5s return $self->decode($rec, @_);
# spent 17.4s making 5000 calls to MARC::File::XML::decode, avg 3.48ms/call # spent 121ms making 10000 calls to XML::LibXML::Node::DESTROY, avg 12µs/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 43.1ms within MARC::File::warnings which was called 5000 times, avg 9µs/call: # 5000 times (43.1ms+0s) by MARC::Batch::next at line 117 of MARC/Batch.pm, avg 9µs/call
sub warnings {
1332000046.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
20413µs1;
205
206__END__
 
# spent 29µs within MARC::File::CORE:open which was called: # once (29µs+0s) by MARC::File::in at line 67
sub MARC::File::CORE:open; # opcode