← Index
NYTProf Performance Profile   « block view • line view • sub view »
For /usr/share/koha/opac/cgi-bin/opac/opac-search.pl
  Run on Tue Oct 15 11:58:52 2013
Reported on Tue Oct 15 12:01:28 2013

Filename/usr/share/perl5/MARC/File.pm
StatementsExecuted 13 statements in 868µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11124µs30µsMARC::File::::BEGIN@10MARC::File::BEGIN@10
11124µs30µsMARC::File::::BEGIN@9MARC::File::BEGIN@9
11119µs27µsMARC::File::::BEGIN@61MARC::File::BEGIN@61
11118µs73µ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::::inMARC::File::in
0000s0sMARC::File::::nextMARC::File::next
0000s0sMARC::File::::outMARC::File::out
0000s0sMARC::File::::skipMARC::File::skip
0000s0sMARC::File::::warningsMARC::File::warnings
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
- -
9357µs235µs
# spent 30µs (24+6) within MARC::File::BEGIN@9 which was called: # once (24µs+6µs) by MARC::File::USMARC::BEGIN@15 at line 9
use strict;
# spent 30µs making 1 call to MARC::File::BEGIN@9 # spent 6µs making 1 call to strict::import
10362µs236µs
# spent 30µs (24+6) within MARC::File::BEGIN@10 which was called: # once (24µs+6µs) by MARC::File::USMARC::BEGIN@15 at line 10
use integer;
# spent 30µs making 1 call to MARC::File::BEGIN@10 # spent 6µs making 1 call to integer::import
11
123102µs2129µs
# spent 73µs (18+55) within MARC::File::BEGIN@12 which was called: # once (18µs+55µs) by MARC::File::USMARC::BEGIN@15 at line 12
use vars qw( $ERROR );
# spent 73µs making 1 call to MARC::File::BEGIN@12 # spent 56µs making 1 call to vars::import
13
14=head1 SYNOPSIS
15
- -
55sub in {
56 my $class = shift;
57 my $arg = shift;
58 my ( $filename, $fh );
59
60 ## if a valid filehandle was passed in
613643µs235µs
# spent 27µs (19+8) within MARC::File::BEGIN@61 which was called: # once (19µs+8µs) by MARC::File::USMARC::BEGIN@15 at line 61
my $ishandle = do { no strict; defined fileno($arg); };
# spent 27µs making 1 call to MARC::File::BEGIN@61 # spent 8µs making 1 call to strict::unimport
62 if ( $ishandle ) {
63 $filename = scalar( $arg );
64 $fh = $arg;
65 }
66
67 ## otherwise check if it's a filename, and
68 ## return undef if we weren't able to open it
69 else {
70 $filename = $arg;
71 $fh = eval { local *FH; open( FH, $arg ) or die; *FH{IO}; };
72 if ( $@ ) {
73 $MARC::File::ERROR = "Couldn't open $filename: $@";
74 return;
75 }
76 }
77
78 my $self = {
79 filename => $filename,
80 fh => $fh,
81 recnum => 0,
82 warnings => [],
83 };
84
85 return( bless $self, $class );
86
87} # new()
88
89sub out {
90 die "Not yet written";
91}
92
93=head2 next( [\&filter_func] )
94
- -
105sub next {
106 my $self = shift;
107 $self->{recnum}++;
108 my $rec = $self->_next() or return;
109 return $self->decode($rec, @_);
110}
111
112=head2 skip()
113
- -
122sub skip {
123 my $self = shift;
124 my $rec = $self->_next() or return;
125 return 1;
126}
127
128=head2 warnings()
129
- -
136sub warnings {
137 my $self = shift;
138 my @warnings = @{ $self->{warnings} };
139 $self->{warnings} = [];
140 return(@warnings);
141}
142
143=head2 close()
144
- -
149sub close {
150 my $self = shift;
151 close( $self->{fh} );
152 delete $self->{fh};
153 delete $self->{filename};
154 return;
155}
156
157sub _unimplemented() {
158 my $self = shift;
159 my $method = shift;
160 warn "Method $method must be overridden";
161}
162
163=head2 write()
164
- -
175sub write { $_[0]->_unimplemented("write"); }
176sub decode { $_[0]->_unimplemented("decode"); }
177
178# NOTE: _warn must be called as an object method
179
180sub _warn {
181 my ($self,$warning) = @_;
182 push( @{ $self->{warnings} }, "$warning in record ".$self->{recnum} );
183 return( $self );
184}
185
186# NOTE: _gripe can be called as an object method, or not. Your choice.
187# NOTE: it's use is now depracated use _warn instead
188sub _gripe(@) {
189 my @parms = @_;
190 if ( @parms ) {
191 my $self = shift @parms;
192
193 if ( ref($self) =~ /^MARC::File/ ) {
194 push( @parms, " at byte ", tell($self->{fh}) )
195 if $self->{fh};
196 push( @parms, " in file ", $self->{filename} ) if $self->{filename};
197 } else {
198 unshift( @parms, $self );
199 }
200
201 $ERROR = join( "", @parms );
202 warn $ERROR;
203 }
204
205 return;
206}
207
20814µs1;
209
210__END__