← Index
NYTProf Performance Profile   « line view »
For starman worker -M FindBin --max-requests 50 --workers 2 --user=kohadev-koha --group kohadev-koha --pid /var/run/koha/kohadev/plack.pid --daemonize --access-log /var/log/koha/kohadev/plack.log --error-log /var/log/koha/kohadev/plack-error.log -E deployment --socket /var/run/koha/kohadev/plack.sock /etc/koha/sites/kohadev/plack.psgi
  Run on Fri Jan 8 14:31:06 2016
Reported on Fri Jan 8 14:31:39 2016

Filename/usr/share/perl/5.20/Text/Abbrev.pm
StatementsExecuted 126 statements in 115µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
21180µs80µsText::Abbrev::::abbrevText::Abbrev::abbrev
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Text::Abbrev;
2114µsrequire 5.005; # Probably works on earlier versions too.
31900nsrequire Exporter;
4
51400nsour $VERSION = '1.02';
6
7=head1 NAME
8
9Text::Abbrev - abbrev - create an abbreviation table from a list
10
11=head1 SYNOPSIS
12
13 use Text::Abbrev;
14 abbrev $hashref, LIST
15
16
17=head1 DESCRIPTION
18
19Stores all unambiguous truncations of each element of LIST
20as keys in the associative array referenced by C<$hashref>.
21The values are the original list elements.
22
23=head1 EXAMPLE
24
25 $hashref = abbrev qw(list edit send abort gripe);
26
27 %hash = abbrev qw(list edit send abort gripe);
28
29 abbrev $hashref, qw(list edit send abort gripe);
30
31 abbrev(*hash, qw(list edit send abort gripe));
32
33=cut
34
3518µs@ISA = qw(Exporter);
361500ns@EXPORT = qw(abbrev);
37
38# Usage:
39# abbrev \%foo, LIST;
40# ...
41# $long = $foo{$short};
42
43
# spent 80µs within Text::Abbrev::abbrev which was called 2 times, avg 40µs/call: # 2 times (80µs+0s) by CGI::Session::parse_dsn at line 149 of CGI/Session.pm, avg 40µs/call
sub abbrev {
442500ns my ($word, $hashref, $glob, %table, $returnvoid);
45
462600ns @_ or return; # So we don't autovivify onto @_ and trigger warning
4722µs if (ref($_[0])) { # hash reference preferably
48 $hashref = shift;
49 $returnvoid = 1;
50 } elsif (ref \$_[0] eq 'GLOB') { # is actually a glob (deprecated)
51 $hashref = \%{shift()};
52 $returnvoid = 1;
53 }
5422µs %{$hashref} = ();
55
5622µs WORD: foreach $word (@_) {
57613µs for (my $len = (length $word) - 1; $len > 0; --$len) {
58308µs my $abbrev = substr($word,0,$len);
593024µs my $seen = ++$table{$abbrev};
603013µs if ($seen == 1) { # We're the first word so far to have
61 # this abbreviation.
62 $hashref->{$abbrev} = $word;
63 } elsif ($seen == 2) { # We're the second word to have this
64 # abbreviation, so we can't use it.
65 delete $hashref->{$abbrev};
66 } else { # We're the third word to have this
67 # abbreviation, so skip to the next word.
68 next WORD;
69 }
70 }
71 }
72 # Non-abbreviations always get entered, even if they aren't unique
7322µs foreach $word (@_) {
7467µs $hashref->{$word} = $word;
75 }
762300ns return if $returnvoid;
77210µs if (wantarray) {
78 %{$hashref};
79 } else {
802500ns $hashref;
81 }
82}
83
8416µs1;