| Filename | /usr/share/perl5/MARC/File/SAX.pm |
| Statements | Executed 2972668 statements in 9.14s |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 185299 | 2 | 1 | 3.73s | 9.26s | MARC::File::SAX::end_element |
| 365598 | 2 | 1 | 2.19s | 2.19s | MARC::File::SAX::characters |
| 185299 | 2 | 1 | 2.01s | 2.07s | MARC::File::SAX::start_element |
| 5000 | 1 | 1 | 48.7ms | 48.7ms | MARC::File::SAX::new |
| 5000 | 1 | 1 | 28.6ms | 28.6ms | MARC::File::SAX::record |
| 1 | 1 | 1 | 6.18ms | 7.17ms | MARC::File::SAX::BEGIN@12 |
| 1 | 1 | 1 | 2.33ms | 70.4ms | MARC::File::SAX::BEGIN@14 |
| 1 | 1 | 1 | 2.10ms | 14.7ms | MARC::File::SAX::BEGIN@10 |
| 1 | 1 | 1 | 51µs | 25.1ms | MARC::File::SAX::BEGIN@11 |
| 1 | 1 | 1 | 22µs | 30µs | MARC::File::SAX::BEGIN@9 |
| 1 | 1 | 1 | 18µs | 57µs | MARC::File::SAX::BEGIN@13 |
| 0 | 0 | 0 | 0s | 0s | MARC::File::SAX::records |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package MARC::File::SAX; | ||||
| 2 | |||||
| 3 | =head1 NAME | ||||
| 4 | |||||
| - - | |||||
| 9 | 3 | 46µs | 2 | 38µs | # spent 30µs (22+8) within MARC::File::SAX::BEGIN@9 which was called:
# once (22µs+8µs) by MARC::File::XML::BEGIN@9 at line 9 # spent 30µs making 1 call to MARC::File::SAX::BEGIN@9
# spent 8µs making 1 call to strict::import |
| 10 | 3 | 172µs | 2 | 14.7ms | # spent 14.7ms (2.10+12.6) within MARC::File::SAX::BEGIN@10 which was called:
# once (2.10ms+12.6ms) by MARC::File::XML::BEGIN@9 at line 10 # spent 14.7ms making 1 call to MARC::File::SAX::BEGIN@10
# spent 55µs making 1 call to Exporter::import |
| 11 | 3 | 90µs | 2 | 50.1ms | # spent 25.1ms (51µs+25.0) within MARC::File::SAX::BEGIN@11 which was called:
# once (51µs+25.0ms) by MARC::File::XML::BEGIN@9 at line 11 # spent 25.1ms making 1 call to MARC::File::SAX::BEGIN@11
# spent 25.0ms making 1 call to base::import |
| 12 | 3 | 263µs | 2 | 7.26ms | # spent 7.17ms (6.18+982µs) within MARC::File::SAX::BEGIN@12 which was called:
# once (6.18ms+982µs) by MARC::File::XML::BEGIN@9 at line 12 # spent 7.17ms making 1 call to MARC::File::SAX::BEGIN@12
# spent 89µs making 1 call to Exporter::import |
| 13 | 3 | 46µs | 2 | 96µs | # spent 57µs (18+39) within MARC::File::SAX::BEGIN@13 which was called:
# once (18µs+39µs) by MARC::File::XML::BEGIN@9 at line 13 # spent 57µs making 1 call to MARC::File::SAX::BEGIN@13
# spent 39µs making 1 call to Exporter::import |
| 14 | 3 | 879µs | 2 | 70.5ms | # spent 70.4ms (2.33+68.1) within MARC::File::SAX::BEGIN@14 which was called:
# once (2.33ms+68.1ms) by MARC::File::XML::BEGIN@9 at line 14 # spent 70.4ms making 1 call to MARC::File::SAX::BEGIN@14
# spent 89µs making 1 call to Exporter::import |
| 15 | |||||
| 16 | =head2 new() | ||||
| 17 | |||||
| - - | |||||
| 22 | # spent 48.7ms within MARC::File::SAX::new which was called 5000 times, avg 10µs/call:
# 5000 times (48.7ms+0s) by MARC::File::XML::decode at line 438 of MARC/File/XML.pm, avg 10µs/call | ||||
| 23 | 10000 | 53.9ms | my $class = shift; | ||
| 24 | return bless {records => []}, ref($class) || $class; | ||||
| 25 | } | ||||
| 26 | |||||
| 27 | =head2 records() | ||||
| 28 | |||||
| - - | |||||
| 33 | sub records { | ||||
| 34 | return shift->{records}; | ||||
| 35 | } | ||||
| 36 | |||||
| 37 | =head2 record() | ||||
| 38 | |||||
| - - | |||||
| 44 | # spent 28.6ms within MARC::File::SAX::record which was called 5000 times, avg 6µs/call:
# 5000 times (28.6ms+0s) by MARC::File::XML::decode at line 447 of MARC/File/XML.pm, avg 6µs/call | ||||
| 45 | 5000 | 31.1ms | return shift->{records}[0]; | ||
| 46 | } | ||||
| 47 | |||||
| 48 | # spent 2.07s (2.01+58.6ms) within MARC::File::SAX::start_element which was called 185299 times, avg 11µs/call:
# 180299 times (1.94s+0s) by XML::SAX::Base::__ANON__[/usr/share/perl5/XML/SAX/Base.pm:292] at line 292 of XML/SAX/Base.pm, avg 11µs/call
# 5000 times (68.0ms+58.6ms) by XML::SAX::Base::start_element at line 293 of XML/SAX/Base.pm, avg 25µs/call | ||||
| 49 | 734520 | 2.33s | my ( $self, $element ) = @_; | ||
| 50 | my $name = $element->{ LocalName }; | ||||
| 51 | 5000 | 58.6ms | if ( $name eq 'record' ) { # spent 58.6ms making 5000 calls to MARC::Record::new, avg 12µs/call | ||
| 52 | $self->{ record } = MARC::Record->new(); | ||||
| 53 | } elsif ( $name eq 'leader' ) { | ||||
| 54 | $self->{ tag } = 'LDR'; | ||||
| 55 | } elsif ( $name eq 'controlfield' ) { | ||||
| 56 | $self->{ tag } = $element->{ Attributes }{ '{}tag' }{ Value }; | ||||
| 57 | } elsif ( $name eq 'datafield' ) { | ||||
| 58 | $self->{ tag } = $element->{ Attributes }{ '{}tag' }{ Value }; | ||||
| 59 | $self->{ i1 } = $element->{ Attributes }{ '{}ind1' }{ Value }; | ||||
| 60 | $self->{ i2 } = $element->{ Attributes }{ '{}ind2' }{ Value }; | ||||
| 61 | } elsif ( $name eq 'subfield' ) { | ||||
| 62 | $self->{ subcode } = $element->{ Attributes }{ '{}code' }{ Value }; | ||||
| 63 | } | ||||
| 64 | } | ||||
| 65 | |||||
| 66 | # spent 9.26s (3.73+5.53) within MARC::File::SAX::end_element which was called 185299 times, avg 50µs/call:
# 180299 times (3.61s+5.47s) by XML::SAX::Base::__ANON__[/usr/share/perl5/XML/SAX/Base.pm:2201] at line 2201 of XML/SAX/Base.pm, avg 50µs/call
# 5000 times (118ms+60.5ms) by XML::SAX::Base::end_element at line 2202 of XML/SAX/Base.pm, avg 36µs/call | ||||
| 67 | 1491933 | 3.92s | my ( $self, $element ) = @_; | ||
| 68 | my $name = $element->{ LocalName }; | ||||
| 69 | if ( $name eq 'subfield' ) { | ||||
| 70 | push @{ $self->{ subfields } }, $self->{ subcode }; | ||||
| 71 | |||||
| 72 | if ($self->{ transcode }) { | ||||
| 73 | push @{ $self->{ subfields } }, utf8_to_marc8($self->{ chars }); | ||||
| 74 | } else { | ||||
| 75 | push @{ $self->{ subfields } }, $self->{ chars } ; | ||||
| 76 | } | ||||
| 77 | |||||
| 78 | $self->{ chars } = ''; | ||||
| 79 | $self->{ subcode } = ''; | ||||
| 80 | } elsif ( $name eq 'controlfield' ) { | ||||
| 81 | $self->{ record }->append_fields( | ||||
| 82 | MARC::Field->new( $self->{ tag }, $self->{ chars } ) | ||||
| 83 | 40000 | 982ms | ); # spent 564ms making 20000 calls to MARC::Field::new, avg 28µs/call
# spent 418ms making 20000 calls to MARC::Record::append_fields, avg 21µs/call | ||
| 84 | $self->{ chars } = ''; | ||||
| 85 | $self->{ tag } = ''; | ||||
| 86 | } elsif ( $name eq 'datafield' ) { | ||||
| 87 | $self->{ record }->append_fields( | ||||
| 88 | MARC::Field->new( | ||||
| 89 | $self->{ tag }, | ||||
| 90 | $self->{ i1 }, | ||||
| 91 | $self->{ i2 }, | ||||
| 92 | 119082 | 4.49s | @{ $self->{ subfields } } # spent 3.24s making 59541 calls to MARC::Field::new, avg 54µs/call
# spent 1.24s making 59541 calls to MARC::Record::append_fields, avg 21µs/call | ||
| 93 | ) | ||||
| 94 | ); | ||||
| 95 | $self->{ tag } = ''; | ||||
| 96 | $self->{ i1 } = ''; | ||||
| 97 | $self->{ i2 } = ''; | ||||
| 98 | $self->{ subfields } = []; | ||||
| 99 | $self->{ chars } = ''; | ||||
| 100 | } elsif ( $name eq 'leader' ) { | ||||
| 101 | my $ldr = $self->{ chars }; | ||||
| 102 | |||||
| 103 | $self->{ transcode }++ | ||||
| 104 | if (substr($ldr,9,1) eq 'a' and $self->{toMARC8}); | ||||
| 105 | |||||
| 106 | substr($ldr,9,1,' ') if ($self->{ transcode }); | ||||
| 107 | |||||
| 108 | 5000 | 60.5ms | $self->{ record }->leader( $ldr ); # spent 60.5ms making 5000 calls to MARC::Record::leader, avg 12µs/call | ||
| 109 | $self->{ chars } = ''; | ||||
| 110 | $self->{ tag } = ''; | ||||
| 111 | } elsif ( $name eq 'record' ) { | ||||
| 112 | push(@{ $self->{ records } }, $self->{ record }); | ||||
| 113 | undef $self->{ record }; | ||||
| 114 | } | ||||
| 115 | } | ||||
| 116 | |||||
| 117 | # spent 2.19s within MARC::File::SAX::characters which was called 365598 times, avg 6µs/call:
# 360598 times (2.16s+0s) by XML::SAX::Base::__ANON__[/usr/share/perl5/XML/SAX/Base.pm:200] at line 200 of XML/SAX/Base.pm, avg 6µs/call
# 5000 times (28.2ms+0s) by XML::SAX::Base::characters at line 201 of XML/SAX/Base.pm, avg 6µs/call | ||||
| 118 | 731196 | 2.80s | my ( $self, $chars ) = @_; | ||
| 119 | if ( | ||||
| 120 | ( exists $self->{ subcode } && $self->{ subcode } ne '') | ||||
| 121 | || ( $self->{ tag } && ( $self->{ tag } eq 'LDR' || $self->{ tag } < 10 )) | ||||
| 122 | ) { | ||||
| 123 | $self->{ chars } .= $chars->{ Data }; | ||||
| 124 | } | ||||
| 125 | } | ||||
| 126 | |||||
| 127 | 1 | 4µs | 1; |