| Filename | /usr/share/koha/lib/C4/Utils.pm |
| Statements | Executed 16 statements in 504µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 23µs | 28µs | C4::Utils::BEGIN@24 |
| 1 | 1 | 1 | 22µs | 22µs | C4::Utils::BEGIN@28 |
| 1 | 1 | 1 | 11µs | 201µs | C4::Utils::BEGIN@26 |
| 1 | 1 | 1 | 10µs | 23µs | C4::Utils::BEGIN@25 |
| 0 | 0 | 0 | 0s | 0s | C4::Utils::hashdump |
| 0 | 0 | 0 | 0s | 0s | C4::Utils::maxwidth |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package C4::Utils; | ||||
| 2 | |||||
| 3 | # Copyright 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 | |||||
| 21 | # Useful code I didn't feel like duplicating all over the place. | ||||
| 22 | # | ||||
| 23 | |||||
| 24 | 3 | 30µs | 2 | 32µs | # spent 28µs (23+5) within C4::Utils::BEGIN@24 which was called:
# once (23µs+5µs) by C4::Auth_with_cas::BEGIN@25 at line 24 # spent 28µs making 1 call to C4::Utils::BEGIN@24
# spent 5µs making 1 call to strict::import |
| 25 | 3 | 32µs | 2 | 35µs | # spent 23µs (10+12) within C4::Utils::BEGIN@25 which was called:
# once (10µs+12µs) by C4::Auth_with_cas::BEGIN@25 at line 25 # spent 23µs making 1 call to C4::Utils::BEGIN@25
# spent 12µs making 1 call to warnings::import |
| 26 | 3 | 103µs | 2 | 390µs | # spent 201µs (11+189) within C4::Utils::BEGIN@26 which was called:
# once (11µs+189µs) by C4::Auth_with_cas::BEGIN@25 at line 26 # spent 201µs making 1 call to C4::Utils::BEGIN@26
# spent 189µs making 1 call to vars::import |
| 27 | |||||
| 28 | # spent 22µs within C4::Utils::BEGIN@28 which was called:
# once (22µs+0s) by C4::Auth_with_cas::BEGIN@25 at line 35 | ||||
| 29 | 6 | 21µs | require Exporter; | ||
| 30 | $VERSION = 3.07.00.049; # set the version for version checking | ||||
| 31 | $debug = $ENV{DEBUG} || 0; | ||||
| 32 | @ISA = qw(Exporter); | ||||
| 33 | @EXPORT_OK = qw(&maxwidth &hashdump); | ||||
| 34 | %EXPORT_TAGS = ( all => [qw(&maxwidth &hashdump)], ); | ||||
| 35 | 1 | 314µs | 1 | 22µs | } # spent 22µs making 1 call to C4::Utils::BEGIN@28 |
| 36 | |||||
| 37 | |||||
| 38 | sub maxwidth { | ||||
| 39 | (@_) or return 0; | ||||
| 40 | return (sort {$a <=> $b} map {length} @_)[-1]; | ||||
| 41 | } | ||||
| 42 | |||||
| 43 | sub hashdump { | ||||
| 44 | my $pre = shift; | ||||
| 45 | my $val = shift; | ||||
| 46 | if (ref($val) =~ /HASH/) { | ||||
| 47 | print "$pre = HASH w/ " . scalar(keys %$val) . " keys.\n"; | ||||
| 48 | my $w2 = maxwidth(keys %$val); | ||||
| 49 | foreach (sort keys %$val) { | ||||
| 50 | &hashdump($pre . '->{' . sprintf('%' . $w2 .'s', $_) . '}', $val->{$_}); | ||||
| 51 | } | ||||
| 52 | print "\n"; | ||||
| 53 | } elsif (ref($val) =~ /ARRAY/) { | ||||
| 54 | print "$pre = ARRAY w/ " . scalar(@$val) . " members.\n"; | ||||
| 55 | my $w2 = maxwidth(@$val); | ||||
| 56 | foreach (@$val) { | ||||
| 57 | &hashdump($pre . '->{' . sprintf('%' . $w2 .'s', $_) . '}', $_); | ||||
| 58 | } | ||||
| 59 | print "\n"; | ||||
| 60 | } else { | ||||
| 61 | print "$pre = $val\n"; | ||||
| 62 | } | ||||
| 63 | } | ||||
| 64 | |||||
| 65 | 1 | 3µs | 1; | ||
| 66 | __END__ |