| Filename | /usr/share/perl5/MARC/File.pm |
| Statements | Executed 40027 statements in 121ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 5000 | 1 | 1 | 79.5ms | 30.9s | MARC::File::next |
| 5000 | 1 | 1 | 41.5ms | 41.5ms | MARC::File::warnings |
| 1 | 1 | 1 | 193µs | 197µs | MARC::File::BEGIN@10 |
| 1 | 1 | 1 | 48µs | 65µs | MARC::File::in |
| 1 | 1 | 1 | 24µs | 30µs | MARC::File::BEGIN@9 |
| 1 | 1 | 1 | 17µs | 17µs | MARC::File::CORE:open (opcode) |
| 1 | 1 | 1 | 15µs | 27µs | MARC::File::BEGIN@57 |
| 1 | 1 | 1 | 12µs | 54µs | MARC::File::BEGIN@12 |
| 0 | 0 | 0 | 0s | 0s | MARC::File::_gripe |
| 0 | 0 | 0 | 0s | 0s | MARC::File::_unimplemented |
| 0 | 0 | 0 | 0s | 0s | MARC::File::_warn |
| 0 | 0 | 0 | 0s | 0s | MARC::File::close |
| 0 | 0 | 0 | 0s | 0s | MARC::File::decode |
| 0 | 0 | 0 | 0s | 0s | MARC::File::out |
| 0 | 0 | 0 | 0s | 0s | MARC::File::skip |
| 0 | 0 | 0 | 0s | 0s | MARC::File::write |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package MARC::File; | ||||
| 2 | |||||
| 3 | =head1 NAME | ||||
| 4 | |||||
| - - | |||||
| 9 | 3 | 47µs | 2 | 36µs | # spent 30µs (24+6) within MARC::File::BEGIN@9 which was called:
# once (24µs+6µs) by base::import at line 9 # spent 30µs making 1 call to MARC::File::BEGIN@9
# spent 6µs making 1 call to strict::import |
| 10 | 3 | 213µs | 2 | 201µs | # spent 197µs (193+4) within MARC::File::BEGIN@10 which was called:
# once (193µs+4µs) by base::import at line 10 # spent 197µs making 1 call to MARC::File::BEGIN@10
# spent 4µs making 1 call to integer::import |
| 11 | |||||
| 12 | 3 | 85µs | 2 | 96µs | # spent 54µs (12+42) within MARC::File::BEGIN@12 which was called:
# once (12µs+42µs) by base::import at line 12 # spent 54µs making 1 call to MARC::File::BEGIN@12
# spent 42µs making 1 call to vars::import |
| 13 | |||||
| 14 | =head1 SYNOPSIS | ||||
| 15 | |||||
| - - | |||||
| 51 | # spent 65µs (48+17) within MARC::File::in which was called:
# once (48µs+17µs) by MARC::Batch::next at line 150 of MARC/Batch.pm | ||||
| 52 | 1 | 2µs | my $class = shift; | ||
| 53 | 1 | 2µs | my $arg = shift; | ||
| 54 | 1 | 2µs | my ( $filename, $fh ); | ||
| 55 | |||||
| 56 | ## if a valid filehandle was passed in | ||||
| 57 | 5 | 709µs | 2 | 39µs | # spent 27µs (15+12) within MARC::File::BEGIN@57 which was called:
# once (15µs+12µs) by base::import at line 57 # spent 27µs making 1 call to MARC::File::BEGIN@57
# spent 12µs making 1 call to strict::unimport |
| 58 | 1 | 2µ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 | 1 | 1µs | $filename = $arg; | ||
| 67 | 4 | 33µs | 1 | 17µs | $fh = eval { local *FH; open( FH, $arg ) or die; *FH{IO}; }; # spent 17µs making 1 call to MARC::File::CORE:open |
| 68 | 1 | 2µs | if ( $@ ) { | ||
| 69 | $MARC::File::ERROR = "Couldn't open $filename: $@"; | ||||
| 70 | return; | ||||
| 71 | } | ||||
| 72 | } | ||||
| 73 | |||||
| 74 | 1 | 5µs | my $self = { | ||
| 75 | filename => $filename, | ||||
| 76 | fh => $fh, | ||||
| 77 | recnum => 0, | ||||
| 78 | warnings => [], | ||||
| 79 | }; | ||||
| 80 | |||||
| 81 | 1 | 10µs | return( bless $self, $class ); | ||
| 82 | |||||
| 83 | } # new() | ||||
| 84 | |||||
| 85 | sub out { | ||||
| 86 | die "Not yet written"; | ||||
| 87 | } | ||||
| 88 | |||||
| 89 | =head2 next( [\&filter_func] ) | ||||
| 90 | |||||
| - - | |||||
| 101 | # spent 30.9s (79.5ms+30.9) within MARC::File::next which was called 5000 times, avg 6.19ms/call:
# 5000 times (79.5ms+30.9s) by MARC::Batch::next at line 111 of MARC/Batch.pm, avg 6.19ms/call | ||||
| 102 | 5000 | 5.97ms | my $self = shift; | ||
| 103 | 5000 | 6.49ms | $self->{recnum}++; | ||
| 104 | 5000 | 22.4ms | 5000 | 411ms | my $rec = $self->_next() or return; # spent 411ms making 5000 calls to MARC::File::XML::_next, avg 82µs/call |
| 105 | 5000 | 39.1ms | 5000 | 30.5s | return $self->decode($rec, @_); # spent 30.5s making 5000 calls to MARC::File::XML::decode, avg 6.09ms/call |
| 106 | } | ||||
| 107 | |||||
| 108 | =head2 skip() | ||||
| 109 | |||||
| - - | |||||
| 118 | sub skip { | ||||
| 119 | my $self = shift; | ||||
| 120 | my $rec = $self->_next() or return; | ||||
| 121 | return 1; | ||||
| 122 | } | ||||
| 123 | |||||
| 124 | =head2 warnings() | ||||
| 125 | |||||
| - - | |||||
| 132 | # spent 41.5ms within MARC::File::warnings which was called 5000 times, avg 8µs/call:
# 5000 times (41.5ms+0s) by MARC::Batch::next at line 117 of MARC/Batch.pm, avg 8µs/call | ||||
| 133 | 5000 | 5.76ms | my $self = shift; | ||
| 134 | 5000 | 9.04ms | my @warnings = @{ $self->{warnings} }; | ||
| 135 | 5000 | 8.76ms | $self->{warnings} = []; | ||
| 136 | 5000 | 22.5ms | return(@warnings); | ||
| 137 | } | ||||
| 138 | |||||
| 139 | =head2 close() | ||||
| 140 | |||||
| - - | |||||
| 145 | sub close { | ||||
| 146 | my $self = shift; | ||||
| 147 | close( $self->{fh} ); | ||||
| 148 | delete $self->{fh}; | ||||
| 149 | delete $self->{filename}; | ||||
| 150 | return; | ||||
| 151 | } | ||||
| 152 | |||||
| 153 | sub _unimplemented() { | ||||
| 154 | my $self = shift; | ||||
| 155 | my $method = shift; | ||||
| 156 | warn "Method $method must be overridden"; | ||||
| 157 | } | ||||
| 158 | |||||
| 159 | =head2 write() | ||||
| 160 | |||||
| - - | |||||
| 171 | sub write { $_[0]->_unimplemented("write"); } | ||||
| 172 | sub decode { $_[0]->_unimplemented("decode"); } | ||||
| 173 | |||||
| 174 | # NOTE: _warn must be called as an object method | ||||
| 175 | |||||
| 176 | sub _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 | ||||
| 184 | sub _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 | |||||
| 204 | 1 | 4µs | 1; | ||
| 205 | |||||
| 206 | __END__ | ||||
# spent 17µs within MARC::File::CORE:open which was called:
# once (17µs+0s) by MARC::File::in at line 67 |