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

Filename/usr/share/perl5/MARC/Batch.pm
StatementsExecuted 50026 statements in 122ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
500122126ms18.1sMARC::Batch::::nextMARC::Batch::next (recurses: max depth 1, inclusive time 17.4ms)
11163µs64µsMARC::Batch::::newMARC::Batch::new
11122µs29µsMARC::Batch::::BEGIN@26MARC::Batch::BEGIN@26
11118µs23µsMARC::Batch::::BEGIN@27MARC::Batch::BEGIN@27
11117µs72µ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
- -
263150µs236µs
# spent 29µs (22+7) within MARC::Batch::BEGIN@26 which was called: # once (22µs+7µs) by main::BEGIN@5 at line 26
use strict;
# spent 29µs making 1 call to MARC::Batch::BEGIN@26 # spent 7µs making 1 call to strict::import
27346µs228µs
# spent 23µs (18+5) within MARC::Batch::BEGIN@27 which was called: # once (18µs+5µs) by main::BEGIN@5 at line 27
use integer;
# spent 23µs making 1 call to MARC::Batch::BEGIN@27 # spent 5µs making 1 call to integer::import
283748µs2127µs
# spent 72µs (17+55) within MARC::Batch::BEGIN@28 which was called: # once (17µs+55µs) by main::BEGIN@5 at line 28
use Carp qw( croak );
# spent 72µs making 1 call to MARC::Batch::BEGIN@28 # spent 55µ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 {
5712µs my $class = shift;
5811µs my $type = shift;
59
6019µ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
6715µ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
7918µs return $self;
80} # new()
81
82
83=head2 next()
84
- -
102
# spent 18.1s (126ms+18.0) within MARC::Batch::next which was called 5001 times, avg 3.62ms/call: # 5000 times (126ms+18.0s) by main::RUNTIME at line 10 of conv.pl, avg 3.62ms/call # once (38µs+-38µs) by MARC::Batch::next at line 153
sub next {
10350018.04ms my ( $self, $filter ) = @_;
10450015.56ms if ( $filter and ref($filter) ne 'CODE' ) {
105 croak( "filter function in next() must be a subroutine reference" );
106 }
107
10850017.64ms if ( $self->{file} ) {
109
110 # get the next record
111500023.7ms500017.9s my $rec = $self->{file}->next( $filter );
# spent 17.9s making 5000 calls to MARC::File::next, avg 3.58ms/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.
117500027.2ms500043.1ms my @warnings = $self->{file}->warnings();
# spent 43.1ms making 5000 calls to MARC::File::warnings, avg 9µs/call
11850005.99ms if ( @warnings ) {
119 $self->warnings( @warnings );
120 return if $self->{ strict };
121 }
122
12350005.87ms 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.
13150008.06ms my @warnings = @{ $rec->{_warnings} };
132
13350005.01ms if (@warnings) {
134 $self->warnings( @warnings );
135 return if $self->{ strict };
136 }
137
138 # return the MARC::Record object
139500023.9ms 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
14912µs my $marcclass = $self->{marcclass};
15019µs179µs $self->{file} = $marcclass->in( $self->{filename} ) or return;
# spent 79µ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 17.4ms making 1 call to MARC::Batch::next, recursion: max depth 1, sum of overlapping time 17.4ms
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
26413µ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