← Index
NYTProf Performance Profile   « block view • line view • sub view »
For 05.Domain_and_Item.t
  Run on Tue May 4 17:21:41 2010
Reported on Tue May 4 17:22:28 2010

File /usr/local/lib/perl5/5.10.1/utf8_heavy.pl
Statements Executed 8378
Statement Execution Time 22.5ms
Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
44420.6ms23.2msutf8::::SWASHNEWutf8::SWASHNEW
41681122.42ms2.42msutf8::::CORE:matchutf8::CORE:match (opcode)
58212391µs391µsutf8::::encodeutf8::encode (xsub)
13923187µs187µsutf8::::downgradeutf8::downgrade (xsub)
412183µs183µsutf8::::CORE:sortutf8::CORE:sort (opcode)
165228µs28µsutf8::::CORE:substutf8::CORE:subst (opcode)
11122µs58µsutf8::::BEGIN@76utf8::BEGIN@76
11121µs54µsutf8::::BEGIN@211utf8::BEGIN@211
11120µs28µsutf8::::BEGIN@2utf8::BEGIN@2
11117µs40µsutf8::::BEGIN@155utf8::BEGIN@155
11114µs38µsutf8::::BEGIN@3utf8::BEGIN@3
0000s0sutf8::::DESTROYutf8::DESTROY
0000s0sutf8::::croakutf8::croak
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package utf8;
2335µs236µs
# spent 28µs (20+8) within utf8::BEGIN@2 which was called # once (20µs+8µs) by utf8::AUTOLOAD at line 2
use strict;
# spent 28µs making 1 call to utf8::BEGIN@2 # spent 8µs making 1 call to strict::import
33620µs261µs
# spent 38µs (14+24) within utf8::BEGIN@3 which was called # once (14µs+24µs) by utf8::AUTOLOAD at line 3
use warnings;
# spent 38µs making 1 call to utf8::BEGIN@3 # spent 24µs making 1 call to warnings::import
4
5sub DEBUG () { 0 }
6
7sub DESTROY {}
8
91400nsmy %Cache;
10
1111µsour (%PropertyAlias, %PA_reverse, %PropValueAlias, %PVA_reverse, %PVA_abbr_map);
12
13sub croak { require Carp; Carp::croak(@_) }
14
15##
16## "SWASH" == "SWATCH HASH". A "swatch" is a swatch of the Unicode landscape.
17## It's a data structure that encodes a set of Unicode characters.
18##
19
20
# spent 23.2ms (20.6+2.63) within utf8::SWASHNEW which was called 4 times, avg 5.80ms/call: # once (13.4ms+2.49ms) by DateTime::TimeZone::new at line 39 of DateTime/TimeZone.pm # once (6.74ms+85µs) by SimpleDB::Class::Types::CORE:match at line 199 of ../lib/SimpleDB/Class/Types.pm # once (317µs+35µs) by SimpleDB::Class::Cache::CORE:subst at line 129 of ../lib/SimpleDB/Class/Cache.pm # once (97µs+19µs) by Moose::Util::TypeConstraints::OptimizedConstraints::CORE:match at line 18 of utf8.pm
sub SWASHNEW {
2172538µs my ($class, $type, $list, $minbits, $none) = @_;
22 local $^D = 0 if $^D;
23
24 print STDERR "SWASHNEW @_\n" if DEBUG;
25
26 ##
27 ## Get the list of codepoints for the type.
28 ## Called from swash_init (see utf8.c) or SWASHNEW itself.
29 ##
30 ## Callers of swash_init:
31 ## op.c:pmtrans -- for tr/// and y///
32 ## regexec.c:regclass_swash -- for /[]/, \p, and \P
33 ## utf8.c:is_utf8_common -- for common Unicode properties
34 ## utf8.c:to_utf8_case -- for lc, uc, ucfirst, etc. and //i
35 ##
36 ## Given a $type, our goal is to fill $list with the set of codepoint
37 ## ranges. If $type is false, $list passed is used.
38 ##
39 ## $minbits:
40 ## For binary properties, $minbits must be 1.
41 ## For character mappings (case and transliteration), $minbits must
42 ## be a number except 1.
43 ##
44 ## $list (or that filled according to $type):
45 ## Refer to perlunicode.pod, "User-Defined Character Properties."
46 ##
47 ## For binary properties, only characters with the property value
48 ## of True should be listed. The 3rd column, if any, will be ignored.
49 ##
50 ## To make the parsing of $type clear, this code takes the a rather
51 ## unorthodox approach of last'ing out of the block once we have the
52 ## info we need. Were this to be a subroutine, the 'last' would just
53 ## be a 'return'.
54 ##
55 my $file; ## file to load data from, and also part of the %Cache key.
56 my $ListSorted = 0;
57
581844µs if ($type)
59 {
60 $type =~ s/^\s+//;
# spent 6µs making 3 calls to utf8::CORE:subst, avg 2µs/call
61 $type =~ s/\s+$//;
# spent 6µs making 3 calls to utf8::CORE:subst, avg 2µs/call
62
63 print STDERR "type = $type\n" if DEBUG;
64
65325.59ms32µs GETFILE:
# spent 2µs making 3 calls to utf8::CORE:subst, avg 533ns/call
66 {
67 ##
68 ## It could be a user-defined property.
69 ##
70
71 my $caller1 = $type =~ s/(.+)::// ? $1 : caller(1);
72
73616µs37µs if (defined $caller1 && $type =~ /^(?:\w+)$/) {
# spent 7µs making 3 calls to utf8::CORE:match, avg 2µs/call
74 my $prop = "${caller1}::$type";
75 if (exists &{$prop}) {
763698µs293µs
# spent 58µs (22+36) within utf8::BEGIN@76 which was called # once (22µs+36µs) by utf8::AUTOLOAD at line 76
no strict 'refs';
# spent 58µs making 1 call to utf8::BEGIN@76 # spent 36µs making 1 call to strict::unimport
77
78 $list = &{$prop};
79 last GETFILE;
80 }
81 }
82
83 my $wasIs;
84
85 ($wasIs = $type =~ s/^Is(?:\s+|[-_])?//i)
# spent 11µs making 6 calls to utf8::CORE:subst, avg 2µs/call
86 or
87 $type =~ s/^(?:(?:General(?:\s+|_)?)?Category|gc)\s*[:=]\s*//i
88 or
89 $type =~ s/^(?:Script|sc)\s*[:=]\s*//i
90 or
91 $type =~ s/^Block\s*[:=]\s*/In/i;
92
93
94 ##
95 ## See if it's in some enumeration.
96 ##
97 require "unicore/PVA.pl";
98924µs311µs if ($type =~ /^([\w\s]+)[:=]\s*(.*)/) {
# spent 11µs making 3 calls to utf8::CORE:match, avg 4µs/call
99 my ($enum, $val) = (lc $1, lc $2);
100 $enum =~ tr/ _-//d;
101 $val =~ tr/ _-//d;
102
103 my $pa = $PropertyAlias{$enum} ? $enum : $PA_reverse{$enum};
104 my $f = $PropValueAlias{$pa}{$val} ? $val : $PVA_reverse{$pa}{lc $val};
105
106 if ($pa and $f) {
107 $pa = "gc_sc" if $pa eq "gc" or $pa eq "sc";
108 $file = "unicore/lib/$pa/$PVA_abbr_map{$pa}{lc $f}.pl";
109 last GETFILE;
110 }
111 }
112 else {
113 my $t = lc $type;
114 $t =~ tr/ _-//d;
115
116 if ($PropValueAlias{gc}{$t} or $PropValueAlias{sc}{$t}) {
117 $file = "unicore/lib/gc_sc/$PVA_abbr_map{gc_sc}{$t}.pl";
118 last GETFILE;
119 }
120 }
121
122 ##
123 ## See if it's in the direct mapping table.
124 ##
125 require "unicore/Exact.pl";
12646µs if (my $base = $utf8::Exact{$type}) {
127 $file = "unicore/lib/gc_sc/$base.pl";
128 last GETFILE;
129 }
130
131 ##
132 ## If not there exactly, try the canonical form. The canonical
133 ## form is lowercased, with any separators (\s+|[-_]) removed.
134 ##
135 my $canonical = lc $type;
136 $canonical =~ s/(?<=[a-z\d])(?:\s+|[-_])(?=[a-z\d])//g;
# spent 3µs making 1 call to utf8::CORE:subst
137 print STDERR "canonical = $canonical\n" if DEBUG;
138
139 require "unicore/Canonical.pl";
140 if (my $base = ($utf8::Canonical{$canonical} || $utf8::Canonical{ lc $utf8::PropertyAlias{$canonical} })) {
141 $file = "unicore/lib/gc_sc/$base.pl";
142 last GETFILE;
143 }
144
145 ##
146 ## See if it's a user-level "To".
147 ##
148
149 my $caller0 = caller(0);
150
15124µs13µs if (defined $caller0 && $type =~ /^To(?:\w+)$/) {
# spent 3µs making 1 call to utf8::CORE:match
152 my $map = $caller0 . "::" . $type;
153
154 if (exists &{$map}) {
1553401µs264µs
# spent 40µs (17+23) within utf8::BEGIN@155 which was called # once (17µs+23µs) by utf8::AUTOLOAD at line 155
no strict 'refs';
# spent 40µs making 1 call to utf8::BEGIN@155 # spent 23µs making 1 call to strict::unimport
156
157 $list = &{$map};
158 last GETFILE;
159 }
160 }
161
162 ##
163 ## Last attempt -- see if it's a standard "To" name
164 ## (e.g. "ToLower") ToTitle is used by ucfirst().
165 ## The user-level way to access ToDigit() and ToFold()
166 ## is to use Unicode::UCD.
167 ##
16825µs13µs if ($type =~ /^To(Digit|Fold|Lower|Title|Upper)$/) {
# spent 3µs making 1 call to utf8::CORE:match
169 $file = "unicore/To/$1.pl";
170 ## would like to test to see if $file actually exists....
171 last GETFILE;
172 }
173
174 ##
175 ## If we reach this line, it's because we couldn't figure
176 ## out what to do with $type. Ouch.
177 ##
178
179 return $type;
180 }
181
182151.16ms if (defined $file) {
183 print STDERR "found it (file='$file')\n" if DEBUG;
184
185 ##
186 ## If we reach here, it was due to a 'last GETFILE' above
187 ## (exception: user-defined properties and mappings), so we
188 ## have a filename, so now we load it if we haven't already.
189 ## If we have, return the cached results. The cache key is the
190 ## class and file to load.
191 ##
192 my $found = $Cache{$class, $file};
193 if ($found and ref($found) eq $class) {
194 print STDERR "Returning cached '$file' for \\p{$type}\n" if DEBUG;
195 return $found;
196 }
197
198 $list = do $file; die $@ if $@;
199 }
200
201 $ListSorted = 1; ## we know that these lists are sorted
202 }
203
204 my $extras;
205 my $bits = $minbits;
206
207 my $ORIG = $list;
208162.61ms if ($list) {
209 my @tmp = split(/^/m, $list);
210 my %seen;
21131.06ms287µs
# spent 54µs (21+33) within utf8::BEGIN@211 which was called # once (21µs+33µs) by utf8::AUTOLOAD at line 211
no warnings;
# spent 54µs making 1 call to utf8::BEGIN@211 # spent 33µs making 1 call to warnings::unimport
212 $extras = join '', grep /^[^0-9a-fA-F]/, @tmp;
# spent 221µs making 1050 calls to utf8::CORE:match, avg 210ns/call
213 $list = join '',
214 map { $_->[1] }
215 sort { $a->[0] <=> $b->[0] }
# spent 548µs making 1049 calls to utf8::CORE:match, avg 522ns/call
216 map { /^([0-9a-fA-F]+)/; [ CORE::hex($1), $_ ] }
# spent 557µs making 1050 calls to utf8::CORE:match, avg 530ns/call
21731485.82ms4183µs grep { /^([0-9a-fA-F]+)/ and not $seen{$1}++ } @tmp; # XXX doesn't do ranges right
# spent 183µs making 4 calls to utf8::CORE:sort, avg 46µs/call
218 }
219
220 if ($none) {
221 my $hextra = sprintf "%04x", $none + 1;
222 $list =~ s/\tXXXX$/\t$hextra/mg;
223 }
224
225417µs if ($minbits != 1 && $minbits < 32) { # not binary property
226 my $top = 0;
227 while ($list =~ /^([0-9a-fA-F]+)(?:[\t]([0-9a-fA-F]+)?)(?:[ \t]([0-9a-fA-F]+))?/mg) {
# spent 9µs making 1 call to utf8::CORE:match
22850203.83ms my $min = CORE::hex $1;
229 my $max = defined $2 ? CORE::hex $2 : $min;
230 my $val = defined $3 ? CORE::hex $3 : 0;
231 $val += $max - $min if defined $3;
232 $top = $val if $val > $top;
# spent 1.06ms making 1004 calls to utf8::CORE:match, avg 1µs/call
233 }
234 my $topbits =
235 $top > 0xffff ? 32 :
236 $top > 0xff ? 16 : 8;
237 $bits = $topbits if $bits < $topbits;
238 }
239
240 my @extras;
241 for my $x ($extras) {
242836µs pos $x = 0;
243 while ($x =~ /^([^0-9a-fA-F\n])(.*)/mg) {
# spent 4µs making 4 calls to utf8::CORE:match, avg 1µs/call
244418µs my $char = $1;
245 my $name = $2;
246 print STDERR "$1 => $2\n" if DEBUG;
247 if ($char =~ /[-+!&]/) {
# spent 4µs making 2 calls to utf8::CORE:match, avg 2µs/call
248 my ($c,$t) = split(/::/, $name, 2); # bogus use of ::, really
249 my $subobj;
250 if ($c eq 'utf8') {
251 $subobj = utf8->SWASHNEW($t, "", $minbits, 0);
252 }
253 elsif (exists &$name) {
254 $subobj = utf8->SWASHNEW($name, "", $minbits, 0);
255 }
256 elsif ($c =~ /^([0-9a-fA-F]+)/) {
257 $subobj = utf8->SWASHNEW("", $c, $minbits, 0);
258 }
259 return $subobj unless ref $subobj;
260 push @extras, $name => $subobj;
261 $bits = $subobj->{BITS} if $bits < $subobj->{BITS};
262 }
263 }
264 }
265
266 print STDERR "CLASS = $class, TYPE => $type, BITS => $bits, NONE => $none\nEXTRAS =>\n$extras\nLIST =>\n$list\n" if DEBUG;
267
268 my $SWASH = bless {
269 TYPE => $type,
270 BITS => $bits,
271 EXTRAS => $extras,
272 LIST => $list,
273 NONE => $none,
274 @extras,
275 } => $class;
276
277 if ($file) {
278 $Cache{$class, $file} = $SWASH;
279 }
280
281 return $SWASH;
282}
283
284# Now SWASHGET is recasted into a C function S_swash_get (see utf8.c).
285
286111µs1;
# spent 2.42ms within utf8::CORE:match which was called 4168 times, avg 581ns/call: # 1050 times (557µs+0s) by utf8::SWASHNEW at line 216 of utf8_heavy.pl, avg 530ns/call # 1050 times (221µs+0s) by utf8::SWASHNEW at line 212 of utf8_heavy.pl, avg 210ns/call # 1049 times (548µs+0s) by utf8::SWASHNEW at line 215 of utf8_heavy.pl, avg 522ns/call # 1004 times (1.06ms+0s) by utf8::SWASHNEW at line 232 of utf8_heavy.pl, avg 1µs/call # 4 times (4µs+0s) by utf8::SWASHNEW at line 243 of utf8_heavy.pl, avg 1µs/call # 3 times (11µs+0s) by utf8::SWASHNEW at line 98 of utf8_heavy.pl, avg 4µs/call # 3 times (7µs+0s) by utf8::SWASHNEW at line 73 of utf8_heavy.pl, avg 2µs/call # 2 times (4µs+0s) by utf8::SWASHNEW at line 247 of utf8_heavy.pl, avg 2µs/call # once (9µs+0s) by utf8::SWASHNEW at line 227 of utf8_heavy.pl # once (3µs+0s) by utf8::SWASHNEW at line 168 of utf8_heavy.pl # once (3µs+0s) by utf8::SWASHNEW at line 151 of utf8_heavy.pl
sub utf8::CORE:match; # xsub
# spent 183µs within utf8::CORE:sort which was called 4 times, avg 46µs/call: # 4 times (183µs+0s) by utf8::SWASHNEW at line 217 of utf8_heavy.pl, avg 46µs/call
sub utf8::CORE:sort; # xsub
# spent 28µs within utf8::CORE:subst which was called 16 times, avg 2µs/call: # 6 times (11µs+0s) by utf8::SWASHNEW at line 85 of utf8_heavy.pl, avg 2µs/call # 3 times (6µs+0s) by utf8::SWASHNEW at line 60 of utf8_heavy.pl, avg 2µs/call # 3 times (6µs+0s) by utf8::SWASHNEW at line 61 of utf8_heavy.pl, avg 2µs/call # 3 times (2µs+0s) by utf8::SWASHNEW at line 65 of utf8_heavy.pl, avg 533ns/call # once (3µs+0s) by utf8::SWASHNEW at line 136 of utf8_heavy.pl
sub utf8::CORE:subst; # xsub
# spent 187µs within utf8::downgrade which was called 139 times, avg 1µs/call: # 98 times (154µs+0s) by HTTP::Message::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/HTTP/Message.pm:18] at line 16 of HTTP/Message.pm, avg 2µs/call # 41 times (33µs+0s) by Net::HTTP::Methods::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/Net/HTTP/Methods.pm:19] at line 14 of Net/HTTP/Methods.pm, avg 798ns/call
sub utf8::downgrade; # xsub
# spent 391µs within utf8::encode which was called 582 times, avg 671ns/call: # 582 times (391µs+0s) by URI::Escape::uri_escape_utf8 at line 190 of URI/Escape.pm, avg 671ns/call
sub utf8::encode; # xsub