← Index
NYTProf Performance Profile   « block view • line view • sub view »
For /usr/share/koha/opac/cgi-bin/opac/opac-search.pl
  Run on Tue Oct 15 17:10:45 2013
Reported on Tue Oct 15 17:11:27 2013

Filename/usr/share/perl5/Business/ISBN13.pm
StatementsExecuted 24 statements in 730µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11117µs21µsBusiness::ISBN13::::BEGIN@4Business::ISBN13::BEGIN@4
11115µs67µsBusiness::ISBN13::::BEGIN@23Business::ISBN13::BEGIN@23
11114µs50µsBusiness::ISBN13::::BEGIN@8Business::ISBN13::BEGIN@8
11111µs198µsBusiness::ISBN13::::BEGIN@7Business::ISBN13::BEGIN@7
11110µs37µsBusiness::ISBN13::::BEGIN@10Business::ISBN13::BEGIN@10
11110µs62µsBusiness::ISBN13::::BEGIN@5Business::ISBN13::BEGIN@5
1119µs112µsBusiness::ISBN13::::BEGIN@18Business::ISBN13::BEGIN@18
0000s0sBusiness::ISBN13::::_checksumBusiness::ISBN13::_checksum
0000s0sBusiness::ISBN13::::_hyphen_positionsBusiness::ISBN13::_hyphen_positions
0000s0sBusiness::ISBN13::::_max_lengthBusiness::ISBN13::_max_length
0000s0sBusiness::ISBN13::::_parse_prefixBusiness::ISBN13::_parse_prefix
0000s0sBusiness::ISBN13::::_set_prefixBusiness::ISBN13::_set_prefix
0000s0sBusiness::ISBN13::::_set_typeBusiness::ISBN13::_set_type
0000s0sBusiness::ISBN13::::as_isbn10Business::ISBN13::as_isbn10
0000s0sBusiness::ISBN13::::as_isbn13Business::ISBN13::as_isbn13
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# $Revision: 2.8 $
2# $Id: ISBN13.pm,v 2.8 2007/09/17 02:34:58 comdog Exp $
3package Business::ISBN13;
4335µs225µs
# spent 21µs (17+4) within Business::ISBN13::BEGIN@4 which was called: # once (17µs+4µs) by Business::ISBN::BEGIN@133 at line 4
use strict;
# spent 21µs making 1 call to Business::ISBN13::BEGIN@4 # spent 4µs making 1 call to strict::import
5335µs2114µs
# spent 62µs (10+52) within Business::ISBN13::BEGIN@5 which was called: # once (10µs+52µs) by Business::ISBN::BEGIN@133 at line 5
use base qw(Business::ISBN);
# spent 62µs making 1 call to Business::ISBN13::BEGIN@5 # spent 52µs making 1 call to base::import
6
7336µs2386µs
# spent 198µs (11+188) within Business::ISBN13::BEGIN@7 which was called: # once (11µs+188µs) by Business::ISBN::BEGIN@133 at line 7
use Business::ISBN qw(:all);
# spent 198µs making 1 call to Business::ISBN13::BEGIN@7 # spent 187µs making 1 call to Exporter::import
8342µs287µs
# spent 50µs (14+37) within Business::ISBN13::BEGIN@8 which was called: # once (14µs+37µs) by Business::ISBN::BEGIN@133 at line 8
use Data::Dumper;
# spent 50µs making 1 call to Business::ISBN13::BEGIN@8 # spent 37µs making 1 call to Exporter::import
9
10126µs
# spent 37µs (10+26) within Business::ISBN13::BEGIN@10 which was called: # once (10µs+26µs) by Business::ISBN::BEGIN@133 at line 17
use subs qw(
# spent 26µs making 1 call to subs::import
11 _checksum
12 INVALID_COUNTRY_CODE
13 INVALID_PUBLISHER_CODE
14 BAD_CHECKSUM
15 GOOD_ISBN
16 BAD_ISBN
17328µs137µs );
# spent 37µs making 1 call to Business::ISBN13::BEGIN@10
181103µs
# spent 112µs (9+103) within Business::ISBN13::BEGIN@18 which was called: # once (9µs+103µs) by Business::ISBN::BEGIN@133 at line 21
use vars qw(
# spent 103µs making 1 call to vars::import
19 $VERSION
20 $debug
21353µs1112µs );
# spent 112µs making 1 call to Business::ISBN13::BEGIN@18
22
233495µs2119µs
# spent 67µs (15+52) within Business::ISBN13::BEGIN@23 which was called: # once (15µs+52µs) by Business::ISBN::BEGIN@133 at line 23
use Carp qw(carp croak cluck);
# spent 67µs making 1 call to Business::ISBN13::BEGIN@23 # spent 52µs making 1 call to Exporter::import
24
251700nsmy $debug = 0;
26
271500ns$VERSION = '2.05';
28
29sub _max_length { 13 }
30
31sub _set_type { $_[0]->{type} = 'ISBN13' }
32
33sub _parse_prefix
34 {
35 my $isbn = $_[0]->isbn; # stupid workaround for 'Can't modify non-lvalue subroutine call'
36 ( $isbn =~ /\A(97[89])(.{10})\z/g )[0];
37 }
38
39sub _set_prefix
40 {
41 croak "Cannot set prefix [$_[1]] on an ISBN-13"
42 unless $_[1] =~ m/\A97[89]\z/;
43
44 $_[0]->{prefix} = $_[1];
45 }
46
47sub _hyphen_positions
48 {
49 [
50 $_[0]->_prefix_length,
51 $_[0]->_prefix_length + $_[0]->_group_code_length,
52 $_[0]->_prefix_length + $_[0]->_group_code_length + $_[0]->_publisher_code_length,
53 $_[0]->_checksum_pos,
54 ]
55 }
56
57# sub group { 'Bookland' }
58
59sub as_isbn10
60 {
61 my $self = shift;
62
63 return unless $self->prefix eq '978';
64
65 my $isbn10 = Business::ISBN->new(
66 substr( $self->isbn, 3 )
67 );
68 $isbn10->fix_checksum;
69
70 return $isbn10;
71 }
72
73sub as_isbn13
74 {
75 my $self = shift;
76
77 my $isbn13 = Business::ISBN->new( $self->as_string );
78 $isbn13->fix_checksum;
79
80 return $isbn13;
81 }
82
83#internal function. you don't get to use this one.
84sub _checksum
85 {
86 my $data = $_[0]->isbn;
87
88 return unless defined $data;
89
90 my @digits = split //, $data;
91 my $sum = 0;
92
93 foreach my $index ( 0, 2, 4, 6, 8, 10 )
94 {
95 $sum += substr($data, $index, 1);
96 $sum += 3 * substr($data, $index + 1, 1);
97 }
98
99 #take the next higher multiple of 10 and subtract the sum.
100 #if $sum is 37, the next highest multiple of ten is 40. the
101 #check digit would be 40 - 37 => 3.
102 my $checksum = ( 10 * ( int( $sum / 10 ) + 1 ) - $sum ) % 10;
103
104 return $checksum;
105 }
106
107
10814µs1;
109
110__END__