← 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:55 2010

Filename/usr/share/perl5/MARC/Batch.pm
StatementsExecuted 50026 statements in 138ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
500122140ms91.0sMARC::Batch::::nextMARC::Batch::next (recurses: max depth 1, inclusive time 47.8ms)
11163µs64µsMARC::Batch::::newMARC::Batch::new
11126µs35µsMARC::Batch::::BEGIN@26MARC::Batch::BEGIN@26
11118µs24µsMARC::Batch::::BEGIN@27MARC::Batch::BEGIN@27
11114µs70µsMARC::Batch::::BEGIN@28MARC::Batch::BEGIN@28
1111µs1µsMARC::Batch::::CORE:matchMARC::Batch::CORE:match (opcode)
0000s0sMARC::Batch::::filenameMARC::Batch::filename
0000s0sMARC::Batch::::strict_offMARC::Batch::strict_off
0000s0sMARC::Batch::::strict_onMARC::Batch::strict_on
0000s0sMARC::Batch::::warningsMARC::Batch::warnings
0000s0sMARC::Batch::::warnings_offMARC::Batch::warnings_off
0000s0sMARC::Batch::::warnings_onMARC::Batch::warnings_on
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package MARC::Batch;
2
3=head1 NAME
4
- -
26344µs244µs
# spent 35µs (26+9) within MARC::Batch::BEGIN@26 which was called: # once (26µs+9µs) by main::BEGIN@5 at line 26
use strict;
# spent 35µs making 1 call to MARC::Batch::BEGIN@26 # spent 9µs making 1 call to strict::import
27344µs230µs
# spent 24µs (18+6) within MARC::Batch::BEGIN@27 which was called: # once (18µs+6µs) by main::BEGIN@5 at line 27
use integer;
# spent 24µs making 1 call to MARC::Batch::BEGIN@27 # spent 6µs making 1 call to integer::import
283855µs2126µs
# spent 70µs (14+56) within MARC::Batch::BEGIN@28 which was called: # once (14µs+56µs) by main::BEGIN@5 at line 28
use Carp qw( croak );
# spent 70µs making 1 call to MARC::Batch::BEGIN@28 # spent 56µs making 1 call to Exporter::import
29
30=head1 METHODS
31
- -
56
# spent 64µs (63+1) within MARC::Batch::new which was called: # once (63µs+1µs) by main::RUNTIME at line 9 of conv.pl
sub new {
5711µs my $class = shift;
5811µs my $type = shift;
59
60110µs11µs my $marcclass = ($type =~ /^MARC::File/) ? $type : "MARC::File::$type";
# spent 1µs making 1 call to MARC::Batch::CORE:match
61
62126µs eval "require $marcclass";
# spent 5µs executing statements in string eval
6311µs croak $@ if $@;
64
6512µs my @files = @_;
66
6716µs my $self = {
68 filestack => \@files,
69 filename => undef,
70 marcclass => $marcclass,
71 file => undef,
72 warnings => [],
73 'warn' => 1,
74 strict => 1,
75 };
76
7717µs bless $self, $class;
78
7917µs return $self;
80} # new()
81
82
83=head2 next()
84
- -
102
# spent 91.0s (140ms+90.9) within MARC::Batch::next which was called 5001 times, avg 18.2ms/call: # 5000 times (140ms+90.9s) by main::RUNTIME at line 10 of conv.pl, avg 18.2ms/call # once (48µs+-48µs) by MARC::Batch::next at line 153
sub next {
10350018.76ms my ( $self, $filter ) = @_;
10450015.84ms if ( $filter and ref($filter) ne 'CODE' ) {
105 croak( "filter function in next() must be a subroutine reference" );
106 }
107
10850017.73ms if ( $self->{file} ) {
109
110 # get the next record
111500025.8ms500090.8s my $rec = $self->{file}->next( $filter );
# spent 90.8s making 5000 calls to MARC::File::next, avg 18.2ms/call
112
113 # collect warnings from MARC::File::* object
114 # we use the warnings() method here since MARC::Batch
115 # hides access to MARC::File objects, and we don't
116 # need to preserve the warnings buffer.
117500035.5ms500050.1ms my @warnings = $self->{file}->warnings();
# spent 50.1ms making 5000 calls to MARC::File::warnings, avg 10µs/call
11850005.99ms if ( @warnings ) {
119 $self->warnings( @warnings );
120 return if $self->{ strict };
121 }
122
12350006.17ms if ($rec) {
124
125 # collect warnings from the MARC::Record object
126 # IMPORTANT: here we don't use warnings() but dig
127 # into the the object to get at the warnings without
128 # erasing the buffer. This is so a user can call
129 # warnings() on the MARC::Record object and get back
130 # warnings for that specific record.
13150009.12ms my @warnings = @{ $rec->{_warnings} };
132
13350005.10ms if (@warnings) {
134 $self->warnings( @warnings );
135 return if $self->{ strict };
136 }
137
138 # return the MARC::Record object
139500027.0ms return($rec);
140
141 }
142
143 }
144
145 # Get the next file off the stack, if there is one
14612µs $self->{filename} = shift @{$self->{filestack}} or return;
147
148 # Instantiate a filename for it
14911µs my $marcclass = $self->{marcclass};
15018µs168µs $self->{file} = $marcclass->in( $self->{filename} ) or return;
# spent 68µs making 1 call to MARC::File::in
151
152 # call this method again now that we've got a file open
153113µs10s return( $self->next( $filter ) );
# spent 47.8ms making 1 call to MARC::Batch::next, recursion: max depth 1, sum of overlapping time 47.8ms
154
155}
156
157=head2 strict_off()
158
- -
169sub strict_off {
170 my $self = shift;
171 $self->{ strict } = 0;
172 return(1);
173}
174
175=head2 strict_on()
176
- -
185sub strict_on {
186 my $self = shift;
187 $self->{ strict } = 1;
188 return(1);
189}
190
191=head2 warnings()
192
- -
205sub warnings {
206 my ($self,@new) = @_;
207 if ( @new ) {
208 push( @{ $self->{warnings} }, @new );
209 print STDERR join( "\n", @new ) if $self->{'warn'};
210 } else {
211 my @old = @{ $self->{warnings} };
212 $self->{warnings} = [];
213 return(@old);
214 }
215}
216
217
218=head2 warnings_off()
219
- -
228sub warnings_off {
229 my $self = shift;
230 $self->{ 'warn' } = 0;
231
232 return 1;
233}
234
235=head2 warnings_on()
236
- -
245sub warnings_on {
246 my $self = shift;
247 $self->{ 'warn' } = 1;
248}
249
250=head2 filename()
251
- -
257sub filename {
258 my $self = shift;
259
260 return $self->{filename};
261}
262
263
26414µs1;
265
266__END__
 
# spent 1µs within MARC::Batch::CORE:match which was called: # once (1µs+0s) by MARC::Batch::new at line 60
sub MARC::Batch::CORE:match; # opcode