← Index
NYTProf Performance Profile   « line view »
For svc/members/upsert
  Run on Tue Jan 13 11:50:22 2015
Reported on Tue Jan 13 12:09:49 2015

Filename/mnt/catalyst/koha/C4/ClassSortRoutine/Dewey.pm
StatementsExecuted 26 statements in 1.08ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111546µs562µsC4::ClassSortRoutine::Dewey::::BEGIN@20C4::ClassSortRoutine::Dewey::BEGIN@20
11134µs43µsC4::ClassSortRoutine::Dewey::::get_class_sort_keyC4::ClassSortRoutine::Dewey::get_class_sort_key
1118µs13µsC4::ClassSortRoutine::Dewey::::BEGIN@21C4::ClassSortRoutine::Dewey::BEGIN@21
1116µs24µsC4::ClassSortRoutine::Dewey::::BEGIN@23C4::ClassSortRoutine::Dewey::BEGIN@23
5516µs6µsC4::ClassSortRoutine::Dewey::::CORE:substC4::ClassSortRoutine::Dewey::CORE:subst (opcode)
2112µs2µsC4::ClassSortRoutine::Dewey::::CORE:substcontC4::ClassSortRoutine::Dewey::CORE:substcont (opcode)
2111µs1µsC4::ClassSortRoutine::Dewey::::CORE:matchC4::ClassSortRoutine::Dewey::CORE:match (opcode)
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package C4::ClassSortRoutine::Dewey;
2
3# Copyright (C) 2007 LibLime
4#
5# This file is part of Koha.
6#
7# Koha is free software; you can redistribute it and/or modify it under the
8# terms of the GNU General Public License as published by the Free Software
9# Foundation; either version 2 of the License, or (at your option) any later
10# version.
11#
12# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License along
17# with Koha; if not, write to the Free Software Foundation, Inc.,
18# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20228µs2578µs
# spent 562µs (546+16) within C4::ClassSortRoutine::Dewey::BEGIN@20 which was called: # once (546µs+16µs) by C4::ClassSource::BEGIN@25 at line 20
use strict;
# spent 562µs making 1 call to C4::ClassSortRoutine::Dewey::BEGIN@20 # spent 16µs making 1 call to strict::import
21229µs218µs
# spent 13µs (8+5) within C4::ClassSortRoutine::Dewey::BEGIN@21 which was called: # once (8µs+5µs) by C4::ClassSource::BEGIN@25 at line 21
use warnings;
# spent 13µs making 1 call to C4::ClassSortRoutine::Dewey::BEGIN@21 # spent 5µs making 1 call to warnings::import
22
232116µs242µs
# spent 24µs (6+18) within C4::ClassSortRoutine::Dewey::BEGIN@23 which was called: # once (6µs+18µs) by C4::ClassSource::BEGIN@25 at line 23
use vars qw($VERSION);
# spent 24µs making 1 call to C4::ClassSortRoutine::Dewey::BEGIN@23 # spent 18µs making 1 call to vars::import
24
25# set the version for version checking
2612µs$VERSION = 3.07.00.049;
27
28=head1 NAME
29
30C4::ClassSortRoutine::Dewey - generic call number sorting key routine
31
32=head1 SYNOPSIS
33
34use C4::ClassSortRoutine;
35
36my $cn_sort = GetClassSortKey('Dewey', $cn_class, $cn_item);
37
38=head1 FUNCTIONS
39
40=head2 get_class_sort_key
41
42 my $cn_sort = C4::ClassSortRoutine::Dewey::Dewey($cn_class, $cn_item);
43
44Generates sorting key using the following rules:
45
46* Concatenates class and item part.
47* Converts to uppercase.
48* Removes leading and trailing whitespace and '/'
49* Separates alphabetic prefix from the rest of the call number
50* Splits into tokens on whitespaces and periods.
51* Leaves first digit group as is.
52* Converts second digit group to 15-digit long group, padded on right with zeroes.
53* Converts each run of whitespace to an underscore.
54* Removes any remaining non-alphabetical, non-numeric, non-underscore characters.
55
56=cut
57
58
# spent 43µs (34+8) within C4::ClassSortRoutine::Dewey::get_class_sort_key which was called: # once (34µs+8µs) by C4::ClassSource::BEGIN@25 at line 1 of (eval 43)[C4/ClassSortRoutine.pm:58]
sub get_class_sort_key {
591700ns my ($cn_class, $cn_item) = @_;
60
611200ns $cn_class = '' unless defined $cn_class;
6210s $cn_item = '' unless defined $cn_item;
6311µs my $init = uc "$cn_class $cn_item";
6418µs12µs $init =~ s/^\s+//;
# spent 2µs making 1 call to C4::ClassSortRoutine::Dewey::CORE:subst
6513µs11µs $init =~ s/\s+$//;
# spent 1µs making 1 call to C4::ClassSortRoutine::Dewey::CORE:subst
6612µs1200ns $init =~ s!/!!g;
# spent 200ns making 1 call to C4::ClassSortRoutine::Dewey::CORE:subst
671690µs4777µs $init =~ s/^([\p{IsAlpha}]+)/$1 /;
# spent 774µs making 1 call to utf8::SWASHNEW # spent 2µs making 1 call to C4::ClassSortRoutine::Dewey::CORE:subst # spent 2µs making 2 calls to C4::ClassSortRoutine::Dewey::CORE:substcont, avg 750ns/call
6813µs my @tokens = split /\.|\s+/, $init;
691200ns my $digit_group_count = 0;
701100ns my $first_digit_group_idx;
7112µs for (my $i = 0; $i <= $#tokens; $i++) {
7226µs21µs if ($tokens[$i] =~ /^\d+$/) {
# spent 1µs making 2 calls to C4::ClassSortRoutine::Dewey::CORE:match, avg 500ns/call
73 $digit_group_count++;
74 if (1 == $digit_group_count) {
75 $first_digit_group_idx = $i;
76 }
77 if (2 == $digit_group_count) {
78 $tokens[$i] = sprintf("%-15.15s", $tokens[$i]);
79 $tokens[$i] =~ tr/ /0/;
80 }
81 }
82 }
83 # Pad the first digit_group if there was only one
841100ns if (1 == $digit_group_count) {
85 $tokens[$first_digit_group_idx] .= '_000000000000000'
86 }
871900ns my $key = join("_", @tokens);
881186µs2662µs $key =~ s/[^\p{IsAlnum}_]//g;
# spent 661µs making 1 call to utf8::SWASHNEW # spent 400ns making 1 call to C4::ClassSortRoutine::Dewey::CORE:subst
89
9014µs return $key;
91
92}
93
9413µs1;
95
96=head1 AUTHOR
97
98Koha Development Team <http://koha-community.org/>
99
100=cut
101
 
# spent 1µs within C4::ClassSortRoutine::Dewey::CORE:match which was called 2 times, avg 500ns/call: # 2 times (1µs+0s) by C4::ClassSortRoutine::Dewey::get_class_sort_key at line 72, avg 500ns/call
sub C4::ClassSortRoutine::Dewey::CORE:match; # opcode
# spent 6µs within C4::ClassSortRoutine::Dewey::CORE:subst which was called 5 times, avg 1µs/call: # once (2µs+0s) by C4::ClassSortRoutine::Dewey::get_class_sort_key at line 67 # once (2µs+0s) by C4::ClassSortRoutine::Dewey::get_class_sort_key at line 64 # once (1µs+0s) by C4::ClassSortRoutine::Dewey::get_class_sort_key at line 65 # once (400ns+0s) by C4::ClassSortRoutine::Dewey::get_class_sort_key at line 88 # once (200ns+0s) by C4::ClassSortRoutine::Dewey::get_class_sort_key at line 66
sub C4::ClassSortRoutine::Dewey::CORE:subst; # opcode
# spent 2µs within C4::ClassSortRoutine::Dewey::CORE:substcont which was called 2 times, avg 750ns/call: # 2 times (2µs+0s) by C4::ClassSortRoutine::Dewey::get_class_sort_key at line 67, avg 750ns/call
sub C4::ClassSortRoutine::Dewey::CORE:substcont; # opcode