| Filename | /usr/share/koha/lib/C4/ClassSortRoutine/Dewey.pm |
| Statements | Executed 29 statements in 567µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 5 | 5 | 1 | 86µs | 12.4ms | C4::ClassSortRoutine::Dewey::CORE:subst (opcode) |
| 1 | 1 | 1 | 80µs | 12.5ms | C4::ClassSortRoutine::Dewey::get_class_sort_key |
| 1 | 1 | 1 | 19µs | 24µs | C4::ClassSortRoutine::Dewey::BEGIN@20 |
| 1 | 1 | 1 | 17µs | 42µs | C4::ClassSortRoutine::Dewey::BEGIN@21 |
| 1 | 1 | 1 | 15µs | 105µs | C4::ClassSortRoutine::Dewey::BEGIN@23 |
| 2 | 1 | 1 | 5µs | 5µs | C4::ClassSortRoutine::Dewey::CORE:match (opcode) |
| 2 | 1 | 1 | 3µs | 3µs | C4::ClassSortRoutine::Dewey::CORE:substcont (opcode) |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package 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 | |||||
| 20 | 3 | 46µs | 2 | 30µs | # spent 24µs (19+5) within C4::ClassSortRoutine::Dewey::BEGIN@20 which was called:
# once (19µs+5µs) by C4::ClassSource::BEGIN@25 at line 20 # spent 24µs making 1 call to C4::ClassSortRoutine::Dewey::BEGIN@20
# spent 5µs making 1 call to strict::import |
| 21 | 3 | 59µs | 2 | 67µs | # spent 42µs (17+25) within C4::ClassSortRoutine::Dewey::BEGIN@21 which was called:
# once (17µs+25µs) by C4::ClassSource::BEGIN@25 at line 21 # spent 42µs making 1 call to C4::ClassSortRoutine::Dewey::BEGIN@21
# spent 25µs making 1 call to warnings::import |
| 22 | |||||
| 23 | 3 | 291µs | 2 | 194µs | # spent 105µs (15+89) within C4::ClassSortRoutine::Dewey::BEGIN@23 which was called:
# once (15µs+89µs) by C4::ClassSource::BEGIN@25 at line 23 # spent 105µs making 1 call to C4::ClassSortRoutine::Dewey::BEGIN@23
# spent 90µs making 1 call to vars::import |
| 24 | |||||
| 25 | # set the version for version checking | ||||
| 26 | 1 | 2µs | $VERSION = 3.07.00.049; | ||
| 27 | |||||
| 28 | =head1 NAME | ||||
| 29 | |||||
| - - | |||||
| 58 | # spent 12.5ms (80µs+12.5) within C4::ClassSortRoutine::Dewey::get_class_sort_key which was called:
# once (80µs+12.5ms) by C4::ClassSource::BEGIN@25 at line 1 of (eval 1018)[/usr/share/koha/lib/C4/ClassSortRoutine.pm:58] | ||||
| 59 | 16 | 77µs | my ($cn_class, $cn_item) = @_; | ||
| 60 | |||||
| 61 | $cn_class = '' unless defined $cn_class; | ||||
| 62 | $cn_item = '' unless defined $cn_item; | ||||
| 63 | my $init = uc "$cn_class $cn_item"; | ||||
| 64 | 1 | 2µs | $init =~ s/^\s+//; # spent 2µs making 1 call to C4::ClassSortRoutine::Dewey::CORE:subst | ||
| 65 | 1 | 2µs | $init =~ s/\s+$//; # spent 2µs making 1 call to C4::ClassSortRoutine::Dewey::CORE:subst | ||
| 66 | 1 | 400ns | $init =~ s!/!!g; # spent 400ns making 1 call to C4::ClassSortRoutine::Dewey::CORE:subst | ||
| 67 | 1 | 35µs | 4 | 12.7ms | $init =~ s/^([\p{IsAlpha}]+)/$1 /; # spent 6.38ms making 1 call to C4::ClassSortRoutine::Dewey::CORE:subst
# spent 6.35ms making 1 call to utf8::SWASHNEW
# spent 3µs making 2 calls to C4::ClassSortRoutine::Dewey::CORE:substcont, avg 1µs/call |
| 68 | my @tokens = split /\.|\s+/, $init; | ||||
| 69 | my $digit_group_count = 0; | ||||
| 70 | 2 | 16µs | for (my $i = 0; $i <= $#tokens; $i++) { | ||
| 71 | 2 | 5µs | if ($tokens[$i] =~ /^\d+$/) { # spent 5µs making 2 calls to C4::ClassSortRoutine::Dewey::CORE:match, avg 3µs/call | ||
| 72 | $digit_group_count++; | ||||
| 73 | if (2 == $digit_group_count) { | ||||
| 74 | $tokens[$i] = sprintf("%-15.15s", $tokens[$i]); | ||||
| 75 | $tokens[$i] =~ tr/ /0/; | ||||
| 76 | } | ||||
| 77 | } | ||||
| 78 | } | ||||
| 79 | # Pad the first digit_group if there was only one | ||||
| 80 | if (1 == $digit_group_count) { | ||||
| 81 | $tokens[0] .= '_000000000000000' | ||||
| 82 | } | ||||
| 83 | my $key = join("_", @tokens); | ||||
| 84 | 1 | 38µs | 2 | 12.1ms | $key =~ s/[^\p{IsAlnum}_]//g; # spent 6.06ms making 1 call to C4::ClassSortRoutine::Dewey::CORE:subst
# spent 6.01ms making 1 call to utf8::SWASHNEW |
| 85 | |||||
| 86 | return $key; | ||||
| 87 | |||||
| 88 | } | ||||
| 89 | |||||
| 90 | 1 | 4µs | 1; | ||
| 91 | |||||
| 92 | =head1 AUTHOR | ||||
| 93 | |||||
| - - | |||||
# spent 5µs within C4::ClassSortRoutine::Dewey::CORE:match which was called 2 times, avg 3µs/call:
# 2 times (5µs+0s) by C4::ClassSortRoutine::Dewey::get_class_sort_key at line 71, avg 3µs/call | |||||
# spent 12.4ms (86µs+12.4) within C4::ClassSortRoutine::Dewey::CORE:subst which was called 5 times, avg 2.49ms/call:
# once (31µs+6.35ms) by C4::ClassSortRoutine::Dewey::get_class_sort_key at line 67
# once (50µs+6.01ms) by C4::ClassSortRoutine::Dewey::get_class_sort_key at line 84
# once (2µs+0s) by C4::ClassSortRoutine::Dewey::get_class_sort_key at line 64
# once (2µ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 66 | |||||
# spent 3µs within C4::ClassSortRoutine::Dewey::CORE:substcont which was called 2 times, avg 1µs/call:
# 2 times (3µs+0s) by C4::ClassSortRoutine::Dewey::get_class_sort_key at line 67, avg 1µs/call |