← Index
NYTProf Performance Profile   « block view • line view • sub view »
For bin/hailo
  Run on Thu Oct 21 22:50:37 2010
Reported on Thu Oct 21 22:52:16 2010

Filename/home/hinrik/perl5/perlbrew/perls/perl-5.13.5/lib/site_perl/5.13.5/Text/Unidecode.pm
StatementsExecuted 27 statements in 827µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111197µs202µsText::Unidecode::::BEGIN@6Text::Unidecode::BEGIN@6
11126µs32µsText::Unidecode::::BEGIN@4Text::Unidecode::BEGIN@4
11122µs24µsText::Unidecode::::unidecodeText::Unidecode::unidecode
11112µs129µsText::Unidecode::::BEGIN@7Text::Unidecode::BEGIN@7
11111µs19µsText::Unidecode::::BEGIN@5Text::Unidecode::BEGIN@5
1117µs7µsText::Unidecode::::BEGIN@13Text::Unidecode::BEGIN@13
1112µs2µsText::Unidecode::::CORE:substText::Unidecode::CORE:subst (opcode)
0000s0sText::Unidecode::::tText::Unidecode::t
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1
2151µsrequire 5.006;
3package Text::Unidecode; # Time-stamp: "2001-07-14 02:29:41 MDT"
4228µs238µs
# spent 32µs (26+6) within Text::Unidecode::BEGIN@4 which was called: # once (26µs+6µs) by Hailo::Tokenizer::Words::BEGIN@8 at line 4
use utf8;
# spent 32µs making 1 call to Text::Unidecode::BEGIN@4 # spent 6µs making 1 call to utf8::import
5225µs228µs
# spent 19µs (11+8) within Text::Unidecode::BEGIN@5 which was called: # once (11µs+8µs) by Hailo::Tokenizer::Words::BEGIN@8 at line 5
use strict;
# spent 19µs making 1 call to Text::Unidecode::BEGIN@5 # spent 8µs making 1 call to strict::import
62211µs2205µs
# spent 202µs (197+4) within Text::Unidecode::BEGIN@6 which was called: # once (197µs+4µs) by Hailo::Tokenizer::Words::BEGIN@8 at line 6
use integer; # vroom vroom!
# spent 202µs making 1 call to Text::Unidecode::BEGIN@6 # spent 4µs making 1 call to integer::import
7266µs2246µs
# spent 129µs (12+117) within Text::Unidecode::BEGIN@7 which was called: # once (12µs+117µs) by Hailo::Tokenizer::Words::BEGIN@8 at line 7
use vars qw($VERSION @ISA @EXPORT @Char $NULLMAP);
# spent 129µs making 1 call to Text::Unidecode::BEGIN@7 # spent 117µs making 1 call to vars::import
812µs$VERSION = '0.04';
911µsrequire Exporter;
1016µs@ISA = ('Exporter');
1111µs@EXPORT = ('unidecode');
12
131349µs17µs
# spent 7µs within Text::Unidecode::BEGIN@13 which was called: # once (7µs+0s) by Hailo::Tokenizer::Words::BEGIN@8 at line 13
BEGIN { *DEBUG = sub () {0} unless defined &DEBUG }
# spent 7µs making 1 call to Text::Unidecode::BEGIN@13
14
15144µs$NULLMAP = [('[?] ') x 0x100]; # for blocks we can't load
16
17#--------------------------------------------------------------------------
18{
1924µs my $x = join '', "\x00" .. "\x7F";
2015µs124µs die "the 7-bit purity test fails!" unless $x eq unidecode($x);
# spent 24µs making 1 call to Text::Unidecode::unidecode
21}
22
23#--------------------------------------------------------------------------
24
25
# spent 24µs (22+2) within Text::Unidecode::unidecode which was called: # once (22µs+2µs) by Hailo::Tokenizer::Words::BEGIN@8 at line 20
sub unidecode {
26 # Destructive in void context -- in other contexts, nondestructive.
27
2811µs unless(@_) {
29 # Nothing coming in
30 return() if wantarray;
31 return '';
32 }
3313µs @_ = map $_, @_ if defined wantarray;
34 # We're in list or scalar context, NOT void context.
35 # So make @_'s items no longer be aliases.
36 # Otherwise, let @_ be aliases, and alter in-place.
37
3813µs foreach my $x (@_) {
391700ns next unless defined $x;
40111µs12µs $x =~ s~([^\x00-\x7f])~${$Char[ord($1)>>8]||t($1)}[ord($1)&255]~egs;
# spent 2µs making 1 call to Text::Unidecode::CORE:subst
41 # Replace character 0xABCD with $Char[0xAB][0xCD], loading
42 # the table as needed.
43 }
44
4511µs return unless defined wantarray; # void context
461700ns return @_ if wantarray; # normal list context -- return the copies
47 # Else normal scalar context:
4815µs return $_[0] if @_ == 1;
49 return join '', @_; # rarer fallthru: a list in, but a scalar out.
50}
51
52sub t {
53 # load (and return) a char table for this character
54 # this should get called only once per table per session.
55 my $bank = ord($_[0]) >> 8;
56 return $Char[$bank] if $Char[$bank];
57
58 {
59 DEBUG and printf "Loading %s::x%02x\n", __PACKAGE__, $bank;
60 local $SIG{'__DIE__'};
61 eval(sprintf 'require %s::x%02x;', __PACKAGE__, $bank);
62 }
63
64 # Now see how that fared...
65 if(ref($Char[$bank] || '') ne 'ARRAY') {
66 DEBUG > 1 and print
67 " Loading failed for bank $bank (err $@). Using null map.\n";
68 return $Char[$bank] = $NULLMAP;
69 } else {
70 DEBUG > 1 and print " Succeeded.\n";
71 if(DEBUG) {
72 # Sanity-check it:
73 my $cb = $Char[$bank];
74 unless(@$cb == 256) {
75 printf "Block x%02x is of size %d -- chopping to 256\n",
76 scalar(@$cb);
77 $#$cb = 255; # pre-extend the array, or chop it to size.
78 }
79 for(my $i = 0; $i < 256; ++$i) {
80 unless(defined $cb->[$i]) {
81 printf "Undef at position %d in block x%02x\n",
82 $i, $bank;
83 $cb->[$i] = '';
84 }
85 }
86 }
87 return $Char[$bank];
88 }
89}
90
91#--------------------------------------------------------------------------
9217µs1;
93__END__
 
# spent 2µs within Text::Unidecode::CORE:subst which was called: # once (2µs+0s) by Text::Unidecode::unidecode at line 40
sub Text::Unidecode::CORE:subst; # opcode