← Index
NYTProf Performance Profile   « block view • line view • sub view »
For conv.pl
  Run on Sun Nov 14 22:06:10 2010
Reported on Sun Nov 14 22:07:09 2010

Filename/usr/share/perl5/MARC/Charset/Table.pm
StatementsExecuted 32 statements in 1.52ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111981µs18.9msMARC::Charset::Table::::BEGIN@36MARC::Charset::Table::BEGIN@36
111934µs7.33msMARC::Charset::Table::::BEGIN@38MARC::Charset::Table::BEGIN@38
111633µs13.0msMARC::Charset::Table::::BEGIN@40MARC::Charset::Table::BEGIN@40
111277µs602µsMARC::Charset::Table::::BEGIN@37MARC::Charset::Table::BEGIN@37
11124µs109µsMARC::Charset::Table::::_initMARC::Charset::Table::_init
11122µs131µsMARC::Charset::Table::::newMARC::Charset::Table::new
11122µs27µsMARC::Charset::Table::::BEGIN@34MARC::Charset::Table::BEGIN@34
11117µs20µsMARC::Charset::Table::::db_pathMARC::Charset::Table::db_path
11116µs42µsMARC::Charset::Table::::BEGIN@35MARC::Charset::Table::BEGIN@35
11115µs466µsMARC::Charset::Table::::BEGIN@39MARC::Charset::Table::BEGIN@39
1113µs3µsMARC::Charset::Table::::CORE:substMARC::Charset::Table::CORE:subst (opcode)
0000s0sMARC::Charset::Table::::add_codeMARC::Charset::Table::add_code
0000s0sMARC::Charset::Table::::brand_newMARC::Charset::Table::brand_new
0000s0sMARC::Charset::Table::::dbMARC::Charset::Table::db
0000s0sMARC::Charset::Table::::get_codeMARC::Charset::Table::get_code
0000s0sMARC::Charset::Table::::lookup_by_marc8MARC::Charset::Table::lookup_by_marc8
0000s0sMARC::Charset::Table::::lookup_by_utf8MARC::Charset::Table::lookup_by_utf8
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package MARC::Charset::Table;
2
3=head1 NAME
4
- -
34338µs232µs
# spent 27µs (22+5) within MARC::Charset::Table::BEGIN@34 which was called: # once (22µs+5µs) by MARC::Charset::BEGIN@13 at line 34
use strict;
# spent 27µs making 1 call to MARC::Charset::Table::BEGIN@34 # spent 5µs making 1 call to strict::import
35339µs268µs
# spent 42µs (16+26) within MARC::Charset::Table::BEGIN@35 which was called: # once (16µs+26µs) by MARC::Charset::BEGIN@13 at line 35
use warnings;
# spent 42µs making 1 call to MARC::Charset::Table::BEGIN@35 # spent 26µs making 1 call to warnings::import
363158µs230.5ms
# spent 18.9ms (981µs+17.9) within MARC::Charset::Table::BEGIN@36 which was called: # once (981µs+17.9ms) by MARC::Charset::BEGIN@13 at line 36
use POSIX;
# spent 18.9ms making 1 call to MARC::Charset::Table::BEGIN@36 # spent 11.6ms making 1 call to POSIX::import
373162µs1602µs
# spent 602µs (277+325) within MARC::Charset::Table::BEGIN@37 which was called: # once (277µs+325µs) by MARC::Charset::BEGIN@13 at line 37
use SDBM_File;
# spent 602µs making 1 call to MARC::Charset::Table::BEGIN@37
383158µs17.33ms
# spent 7.33ms (934µs+6.40) within MARC::Charset::Table::BEGIN@38 which was called: # once (934µs+6.40ms) by MARC::Charset::BEGIN@13 at line 38
use MARC::Charset::Code;
# spent 7.33ms making 1 call to MARC::Charset::Table::BEGIN@38
39347µs2917µs
# spent 466µs (15+451) within MARC::Charset::Table::BEGIN@39 which was called: # once (15µs+451µs) by MARC::Charset::BEGIN@13 at line 39
use MARC::Charset::Constants qw(:all);
# spent 466µs making 1 call to MARC::Charset::Table::BEGIN@39 # spent 451µs making 1 call to Exporter::import
403781µs213.2ms
# spent 13.0ms (633µs+12.4) within MARC::Charset::Table::BEGIN@40 which was called: # once (633µs+12.4ms) by MARC::Charset::BEGIN@13 at line 40
use Storable qw(freeze thaw);
# spent 13.0ms making 1 call to MARC::Charset::Table::BEGIN@40 # spent 164µs making 1 call to Exporter::import
41
42=head2 new()
43
- -
48sub new
49
# spent 131µs (22+109) within MARC::Charset::Table::new which was called: # once (22µs+109µs) by MARC::File::XML::BEGIN@10 at line 44 of MARC/Charset.pm
{
5012µs my $class = shift;
5119µs my $self = bless {}, ref($class) || $class;
5214µs1109µs $self->_init(O_RDONLY);
# spent 109µs making 1 call to MARC::Charset::Table::_init
5315µs return $self;
54}
55
56
57=head2 add_code()
58
- -
64sub add_code
65{
66 my ($self, $code) = @_;
67
68 # the Code object is serialized
69 my $frozen = freeze($code);
70
71 # to support lookup by marc8 and utf8 values we
72 # stash away the rule in the db using two keys
73 my $marc8_key = $code->marc8_hash_code();
74 my $utf8_key = $code->utf8_hash_code();
75
76 # stash away the marc8 lookup key
77 $self->{db}->{$marc8_key} = $frozen;
78
79 # stash away the utf8 lookup key (only if it's not already there!)
80 # this means that the sets that appear in the xml file will have
81 # precedence ascii/ansel
82 $self->{db}->{$utf8_key} = $frozen unless exists $self->{db}->{$utf8_key};
83}
84
85
86=head2 get_code()
87
- -
92sub get_code
93{
94 my ($self, $key) = @_;
95 my $db = $self->db();
96 my $frozen = $db->{$key};
97 return thaw($frozen) if $frozen;
98 return undef;
99}
100
101
102=head2 lookup_by_marc8()
103
- -
112sub lookup_by_marc8
113{
114 my ($self, $charset, $marc8) = @_;
115 $charset = BASIC_LATIN if $charset eq ASCII_DEFAULT;
116 return $self->get_code(sprintf('%s:%s', $charset, $marc8));
117}
118
119
120=head2 lookup_by_utf8()
121
- -
126sub lookup_by_utf8
127{
128 my ($self, $value) = @_;
129 return $self->get_code(ord($value));
130}
131
- -
135=head2 db()
136
- -
142sub db
143{
144 return shift->{db};
145}
146
147
148=head2 db_path()
149
- -
157sub db_path
158
# spent 20µs (17+3) within MARC::Charset::Table::db_path which was called: # once (17µs+3µs) by MARC::Charset::Table::_init at line 187
{
15912µs my $path = $INC{'MARC/Charset/Table.pm'};
160114µs13µs $path =~ s/\.pm$//;
# spent 3µs making 1 call to MARC::Charset::Table::CORE:subst
16117µs return $path;
162}
163
164
165=head2 brand_new()
166
- -
173sub brand_new
174{
175 my $class = shift;
176 my $self = bless {}, ref($class) || $class;
177 $self->_init(O_CREAT|O_RDWR);
178 return $self;
179}
180
181
182# helper function for initializing table internals
183
184sub _init
185
# spent 109µs (24+85) within MARC::Charset::Table::_init which was called: # once (24µs+85µs) by MARC::Charset::Table::new at line 52
{
18611µs my ($self,$opts) = @_;
187181µs285µs tie my %db, 'SDBM_File', db_path(), $opts, 0644;
# spent 65µs making 1 call to SDBM_File::TIEHASH # spent 20µs making 1 call to MARC::Charset::Table::db_path
18817µs $self->{db} = \%db;
189}
190
- -
19519µs1;
 
# spent 3µs within MARC::Charset::Table::CORE:subst which was called: # once (3µs+0s) by MARC::Charset::Table::db_path at line 160
sub MARC::Charset::Table::CORE:subst; # opcode