Filename | /usr/lib64/perl5/vendor_perl/5.16.0/File/MimeInfo/Magic.pm |
Statements | Executed 619845 statements in 11.2s |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
62936 | 1 | 1 | 5.99s | 7.74s | _check_rule | File::MimeInfo::Magic::
2564 | 2 | 1 | 2.51s | 10.8s | _magic | File::MimeInfo::Magic::
62936 | 1 | 1 | 734ms | 734ms | CORE:read (opcode) | File::MimeInfo::Magic::
64556 | 3 | 1 | 449ms | 449ms | CORE:regcomp (opcode) | File::MimeInfo::Magic::
2560 | 1 | 1 | 386ms | 12.3s | mimetype | File::MimeInfo::Magic::
62936 | 1 | 1 | 382ms | 382ms | CORE:seek (opcode) | File::MimeInfo::Magic::
1 | 1 | 1 | 232ms | 342ms | _hash_magic | File::MimeInfo::Magic::
64901 | 3 | 1 | 226ms | 226ms | CORE:match (opcode) | File::MimeInfo::Magic::
2561 | 2 | 1 | 140ms | 140ms | CORE:open (opcode) | File::MimeInfo::Magic::
2560 | 1 | 1 | 55.6ms | 55.6ms | CORE:ftsize (opcode) | File::MimeInfo::Magic::
3444 | 6 | 1 | 37.4ms | 37.4ms | CORE:unpack (opcode) | File::MimeInfo::Magic::
2560 | 1 | 1 | 13.4ms | 13.4ms | CORE:fteread (opcode) | File::MimeInfo::Magic::
2561 | 2 | 1 | 10.3ms | 10.3ms | CORE:binmode (opcode) | File::MimeInfo::Magic::
810 | 1 | 1 | 9.42ms | 9.42ms | CORE:subst (opcode) | File::MimeInfo::Magic::
810 | 1 | 1 | 9.41ms | 9.41ms | CORE:qr (opcode) | File::MimeInfo::Magic::
208 | 1 | 1 | 7.00ms | 7.00ms | _find_branch | File::MimeInfo::Magic::
1 | 1 | 1 | 5.80ms | 7.59ms | BEGIN@7 | File::MimeInfo::Magic::
1157 | 3 | 1 | 5.52ms | 5.52ms | CORE:readline (opcode) | File::MimeInfo::Magic::
15 | 1 | 1 | 4.11ms | 4.32ms | _mask_regex | File::MimeInfo::Magic::
1 | 1 | 1 | 655µs | 655µs | CORE:sort (opcode) | File::MimeInfo::Magic::
1 | 1 | 1 | 260µs | 260µs | BEGIN@11 | File::MimeInfo::Magic::
1 | 1 | 1 | 249µs | 345ms | _rehash | File::MimeInfo::Magic::
45 | 1 | 1 | 202µs | 202µs | CORE:rcatline (opcode) | File::MimeInfo::Magic::
5 | 2 | 1 | 150µs | 150µs | CORE:close (opcode) | File::MimeInfo::Magic::
1 | 1 | 1 | 88µs | 192µs | BEGIN@4 | File::MimeInfo::Magic::
8 | 2 | 1 | 66µs | 66µs | CORE:pack (opcode) | File::MimeInfo::Magic::
1 | 1 | 1 | 59µs | 309µs | BEGIN@5 | File::MimeInfo::Magic::
1 | 1 | 1 | 55µs | 183µs | BEGIN@6 | File::MimeInfo::Magic::
1 | 1 | 1 | 55µs | 129µs | BEGIN@12 | File::MimeInfo::Magic::
0 | 0 | 0 | 0s | 0s | _escape_bytes | File::MimeInfo::Magic::
0 | 0 | 0 | 0s | 0s | magic | File::MimeInfo::Magic::
0 | 0 | 0 | 0s | 0s | rehash | File::MimeInfo::Magic::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | |||||
2 | package File::MimeInfo::Magic; | ||||
3 | |||||
4 | 2 | 203µs | 2 | 297µs | # spent 192µs (88+104) within File::MimeInfo::Magic::BEGIN@4 which was called:
# once (88µs+104µs) by RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@32 at line 4 # spent 192µs making 1 call to File::MimeInfo::Magic::BEGIN@4
# spent 104µs making 1 call to strict::import |
5 | 2 | 168µs | 2 | 558µs | # spent 309µs (59+250) within File::MimeInfo::Magic::BEGIN@5 which was called:
# once (59µs+250µs) by RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@32 at line 5 # spent 309µs making 1 call to File::MimeInfo::Magic::BEGIN@5
# spent 250µs making 1 call to Exporter::import |
6 | 2 | 158µs | 2 | 311µs | # spent 183µs (55+128) within File::MimeInfo::Magic::BEGIN@6 which was called:
# once (55µs+128µs) by RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@32 at line 6 # spent 183µs making 1 call to File::MimeInfo::Magic::BEGIN@6
# spent 128µs making 1 call to Exporter::import |
7 | 2 | 770µs | 2 | 8.01ms | # spent 7.59ms (5.80+1.79) within File::MimeInfo::Magic::BEGIN@7 which was called:
# once (5.80ms+1.79ms) by RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@32 at line 7 # spent 7.59ms making 1 call to File::MimeInfo::Magic::BEGIN@7
# spent 415µs making 1 call to Exporter::import |
8 | 1 | 489µs | require File::MimeInfo; | ||
9 | 1 | 3µs | require Exporter; | ||
10 | |||||
11 | # spent 260µs within File::MimeInfo::Magic::BEGIN@11 which was called:
# once (260µs+0s) by RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@32 at line 16 | ||||
12 | 2 | 271µs | 2 | 203µs | # spent 129µs (55+74) within File::MimeInfo::Magic::BEGIN@12 which was called:
# once (55µs+74µs) by RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@32 at line 12 # spent 129µs making 1 call to File::MimeInfo::Magic::BEGIN@12
# spent 74µs making 1 call to strict::unimport |
13 | 1 | 27µs | for (qw/extensions describe globs inodetype default/) { | ||
14 | 5 | 235µs | *{$_} = \&{"File::MimeInfo::$_"}; | ||
15 | } | ||||
16 | 1 | 7.94ms | 1 | 260µs | } # spent 260µs making 1 call to File::MimeInfo::Magic::BEGIN@11 |
17 | |||||
18 | 1 | 32µs | our @ISA = qw(Exporter File::MimeInfo); | ||
19 | 1 | 5µs | our @EXPORT = qw(mimetype); | ||
20 | 1 | 7µs | our @EXPORT_OK = qw(extensions describe globs inodetype magic); | ||
21 | 1 | 2µs | our $VERSION = '0.15'; | ||
22 | 1 | 700ns | our $DEBUG; | ||
23 | |||||
24 | 1 | 1µs | our $_hashed = 0; | ||
25 | 1 | 2µs | our (@magic_80, @magic, $max_buffer); | ||
26 | # @magic_80 and @magic are used to store the parse tree of magic data | ||||
27 | # @magic_80 contains magic rules with priority 80 and higher, @magic the rest | ||||
28 | # $max_buffer contains the maximum number of chars to be buffered from a non-seekable | ||||
29 | # filehandle in order to do magic mimetyping | ||||
30 | |||||
31 | # spent 12.3s (386ms+11.9) within File::MimeInfo::Magic::mimetype which was called 2560 times, avg 4.79ms/call:
# 2560 times (386ms+11.9s) by RTP::Webmerge::Process::CSS::Inlinedata::inline_url at line 294 of webmerge/scripts/modules/RTP/Webmerge/Process/CSS/Inlinedata.pm, avg 4.79ms/call | ||||
32 | 2560 | 10.5ms | my $file = pop; | ||
33 | 2560 | 3.65ms | croak 'subroutine "mimetype" needs a filename as argument' unless defined $file; | ||
34 | |||||
35 | 2560 | 3.69ms | return magic($file) || default($file) if ref $file; | ||
36 | 2560 | 136ms | 5120 | 69.0ms | return &File::MimeInfo::mimetype($file) unless -s $file and -r _; # spent 55.6ms making 2560 calls to File::MimeInfo::Magic::CORE:ftsize, avg 22µs/call
# spent 13.4ms making 2560 calls to File::MimeInfo::Magic::CORE:fteread, avg 5µs/call |
37 | |||||
38 | 2560 | 5.76ms | my ($mimet, $fh); | ||
39 | 2560 | 34.5ms | 2560 | 190ms | return $mimet if $mimet = inodetype($file); # spent 190ms making 2560 calls to File::MimeInfo::inodetype, avg 74µs/call |
40 | |||||
41 | 2560 | 44.2ms | 2560 | 10.6s | ($mimet, $fh) = _magic($file, \@magic_80); # high priority rules # spent 10.6s making 2560 calls to File::MimeInfo::Magic::_magic, avg 4.12ms/call |
42 | 2560 | 2.73ms | return $mimet if $mimet; | ||
43 | |||||
44 | 2560 | 200ms | 2560 | 866ms | return $mimet if $mimet = globs($file); # spent 866ms making 2560 calls to File::MimeInfo::globs, avg 338µs/call |
45 | |||||
46 | 4 | 373µs | 4 | 199ms | ($mimet, $fh) = _magic($fh, \@magic); # lower priority rules # spent 199ms making 4 calls to File::MimeInfo::Magic::_magic, avg 49.7ms/call |
47 | 4 | 248µs | 4 | 123µs | close $fh unless ref $file; # spent 123µs making 4 calls to File::MimeInfo::Magic::CORE:close, avg 31µs/call |
48 | |||||
49 | 4 | 148µs | return $mimet if $mimet; | ||
50 | return default($file); | ||||
51 | } | ||||
52 | |||||
53 | sub magic { | ||||
54 | my $file = pop; | ||||
55 | croak 'subroutine "magic" needs a filename as argument' unless defined $file; | ||||
56 | return undef unless ref($file) || -s $file; | ||||
57 | print STDERR "> Checking all magic rules\n" if $DEBUG; | ||||
58 | |||||
59 | my ($mimet, $fh) = _magic($file, \@magic_80, \@magic); | ||||
60 | close $fh unless ref $file; | ||||
61 | |||||
62 | return $mimet; | ||||
63 | } | ||||
64 | |||||
65 | sub _magic { | ||||
66 | 2564 | 22.7ms | my ($file, @rules) = @_; | ||
67 | 2564 | 2.48ms | 1 | 345ms | _rehash() unless $_hashed; # spent 345ms making 1 call to File::MimeInfo::Magic::_rehash |
68 | |||||
69 | 2564 | 2.89ms | my $fh; | ||
70 | 2564 | 9.84ms | unless (ref $file) { | ||
71 | 2560 | 231ms | 2560 | 140ms | open $fh, '<', $file || return undef; # spent 140ms making 2560 calls to File::MimeInfo::Magic::CORE:open, avg 55µs/call |
72 | 2560 | 67.4ms | 2560 | 10.3ms | binmode $fh; # spent 10.3ms making 2560 calls to File::MimeInfo::Magic::CORE:binmode, avg 4µs/call |
73 | } | ||||
74 | 4 | 10µs | else { $fh = $file } | ||
75 | |||||
76 | 2564 | 79.6ms | for my $type (map @$_, @rules) { | ||
77 | 54656 | 731ms | for (2..$#$type) { | ||
78 | 62936 | 752ms | 62936 | 7.74s | next unless _check_rule($$type[$_], $fh, 0); # spent 7.74s making 62936 calls to File::MimeInfo::Magic::_check_rule, avg 123µs/call |
79 | 4 | 12µs | close $fh unless ref $file; | ||
80 | 4 | 118µs | return ($$type[1], $fh); | ||
81 | } | ||||
82 | } | ||||
83 | 2560 | 48.1ms | return (undef, $fh); | ||
84 | } | ||||
85 | |||||
86 | # spent 7.74s (5.99+1.75) within File::MimeInfo::Magic::_check_rule which was called 62936 times, avg 123µs/call:
# 62936 times (5.99s+1.75s) by File::MimeInfo::Magic::_magic at line 78, avg 123µs/call | ||||
87 | 62936 | 178ms | my ($ref, $fh, $lev) = @_; | ||
88 | 62936 | 33.0ms | my $line; | ||
89 | |||||
90 | # Read | ||||
91 | 62936 | 264ms | if (ref $fh eq 'GLOB') { | ||
92 | 62936 | 1.55s | 62936 | 382ms | seek($fh, $$ref[0], SEEK_SET); # seek offset # spent 382ms making 62936 calls to File::MimeInfo::Magic::CORE:seek, avg 6µs/call |
93 | 62936 | 2.07s | 62936 | 734ms | read($fh, $line, $$ref[1]); # read max length # spent 734ms making 62936 calls to File::MimeInfo::Magic::CORE:read, avg 12µs/call |
94 | } | ||||
95 | else { # allowing for IO::Something | ||||
96 | $fh->seek($$ref[0], SEEK_SET); # seek offset | ||||
97 | $fh->read($line, $$ref[1]); # read max length | ||||
98 | } | ||||
99 | |||||
100 | # Match regex | ||||
101 | 62936 | 238ms | 2596 | 31.4ms | $line = unpack 'b*', $line if $$ref[2]; # unpack to bits if using mask # spent 31.4ms making 2596 calls to File::MimeInfo::Magic::CORE:unpack, avg 12µs/call |
102 | 62936 | 4.15s | 125872 | 607ms | return undef unless $line =~ $$ref[3]; # match regex # spent 396ms making 62936 calls to File::MimeInfo::Magic::CORE:regcomp, avg 6µs/call
# spent 210ms making 62936 calls to File::MimeInfo::Magic::CORE:match, avg 3µs/call |
103 | 4 | 7µs | print STDERR '>', '>'x$lev, ' Value "', _escape_bytes($2), | ||
104 | '" at offset ', $$ref[1]+length($1), | ||||
105 | " matches at $$ref[4]\n" | ||||
106 | if $DEBUG; | ||||
107 | 4 | 68µs | return 1 unless $#$ref > 4; | ||
108 | |||||
109 | # Check nested rules and recurs | ||||
110 | for (5..$#$ref) { | ||||
111 | return 1 if _check_rule($$ref[$_], $fh, $lev+1); | ||||
112 | } | ||||
113 | print STDERR "> Failed nested rules\n" if $DEBUG && ! $lev; | ||||
114 | return 0; | ||||
115 | } | ||||
116 | |||||
117 | sub rehash { | ||||
118 | &File::MimeInfo::rehash(); | ||||
119 | &_rehash(); | ||||
120 | #use Data::Dumper; | ||||
121 | #print Dumper \@magic_80, \@magic; | ||||
122 | } | ||||
123 | |||||
124 | # spent 345ms (249µs+345) within File::MimeInfo::Magic::_rehash which was called:
# once (249µs+345ms) by File::MimeInfo::Magic::_magic at line 67 | ||||
125 | 1 | 2µs | local $_; # limit scope of $_ ... :S | ||
126 | 1 | 5µs | ($max_buffer, @magic_80, @magic) = (32); # clear data | ||
127 | my @magicfiles = @File::MimeInfo::DIRS | ||||
128 | 1 | 31µs | 1 | 2.04ms | ? ( grep {-e $_ && -r $_} # spent 2.04ms making 1 call to File::BaseDir::data_files |
129 | map "$_/magic", @File::MimeInfo::DIRS ) | ||||
130 | : ( reverse data_files('mime/magic') ) ; | ||||
131 | 1 | 2µs | my @done; | ||
132 | 1 | 10µs | for my $file (@magicfiles) { | ||
133 | 1 | 5µs | next if grep {$file eq $_} @done; | ||
134 | 1 | 17µs | 1 | 342ms | _hash_magic($file); # spent 342ms making 1 call to File::MimeInfo::Magic::_hash_magic |
135 | 1 | 11µs | push @done, $file; | ||
136 | } | ||||
137 | 1 | 700µs | 1 | 655µs | @magic = sort {$$b[0] <=> $$a[0]} @magic; # spent 655µs making 1 call to File::MimeInfo::Magic::CORE:sort |
138 | 1 | 7µs | while ($magic[0][0] >= 80) { | ||
139 | 21 | 73µs | push @magic_80, shift @magic; | ||
140 | } | ||||
141 | 1 | 37µs | $_hashed = 1; | ||
142 | } | ||||
143 | |||||
144 | # spent 342ms (232+110) within File::MimeInfo::Magic::_hash_magic which was called:
# once (232ms+110ms) by File::MimeInfo::Magic::_rehash at line 134 | ||||
145 | 1 | 8µs | my $file = shift; | ||
146 | |||||
147 | 1 | 113µs | 1 | 66µs | open MAGIC, '<', $file # spent 66µs making 1 call to File::MimeInfo::Magic::CORE:open |
148 | || croak "Could not open file '$file' for reading"; | ||||
149 | 1 | 47µs | 1 | 9µs | binmode MAGIC; # spent 9µs making 1 call to File::MimeInfo::Magic::CORE:binmode |
150 | 1 | 95µs | 1 | 49µs | <MAGIC> eq "MIME-Magic\x00\n" # spent 49µs making 1 call to File::MimeInfo::Magic::CORE:readline |
151 | or carp "Magic file '$file' doesn't seem to be a magic file"; | ||||
152 | 1 | 4µs | my $line = 1; | ||
153 | 1 | 30.0ms | 346 | 1.52ms | while (<MAGIC>) { # spent 1.52ms making 346 calls to File::MimeInfo::Magic::CORE:readline, avg 4µs/call |
154 | 1155 | 948µs | $line++; | ||
155 | |||||
156 | 1155 | 17.4ms | 1155 | 6.22ms | if (/^\[(\d+):(.*?)\]\n$/) { # spent 6.22ms making 1155 calls to File::MimeInfo::Magic::CORE:match, avg 5µs/call |
157 | 345 | 4.55ms | push @magic, [$1,$2]; | ||
158 | 345 | 895µs | next; | ||
159 | } | ||||
160 | |||||
161 | s/^(\d*)>(\d+)=(.{2})//s | ||||
162 | 810 | 18.0ms | 810 | 9.42ms | || warn "$file line $line skipped\n" && next; # spent 9.42ms making 810 calls to File::MimeInfo::Magic::CORE:subst, avg 12µs/call |
163 | 810 | 19.5ms | 810 | 5.76ms | my ($i, $o, $l) = ($1, $2, unpack 'n', $3); # spent 5.76ms making 810 calls to File::MimeInfo::Magic::CORE:unpack, avg 7µs/call |
164 | # indent, offset, value length | ||||
165 | 810 | 3.39ms | while (length($_) <= $l) { | ||
166 | 45 | 733µs | 45 | 202µs | $_ .= <MAGIC>; # spent 202µs making 45 calls to File::MimeInfo::Magic::CORE:rcatline, avg 4µs/call |
167 | 45 | 184µs | $line++; | ||
168 | } | ||||
169 | |||||
170 | 810 | 3.24ms | my $v = substr $_, 0, $l, ''; # value | ||
171 | |||||
172 | 810 | 57.4ms | 1620 | 39.7ms | /^(?:&(.{$l}))?(?:~(\d+))?(?:\+(\d+))?\n$/s # spent 30.2ms making 810 calls to File::MimeInfo::Magic::CORE:regcomp, avg 37µs/call
# spent 9.46ms making 810 calls to File::MimeInfo::Magic::CORE:match, avg 12µs/call |
173 | || warn "$file line $line skipped\n" && next; | ||||
174 | 810 | 6.11ms | my ($m, $w, $r) = ($1, $2 || 1, $3 || 1); | ||
175 | # mask, word size, range | ||||
176 | 810 | 1.19ms | my $mdef = defined $m; | ||
177 | |||||
178 | # possible big endian to little endian conversion | ||||
179 | # as a bonus perl also takes care of weird endian cases | ||||
180 | 810 | 699µs | if ( $w != 1 ) { | ||
181 | 8 | 11µs | my ( $utpl, $ptpl ); | ||
182 | 8 | 24µs | if ( 2 == $w ) { | ||
183 | 4 | 155µs | 8 | 48µs | $v = pack 'S', unpack 'n', $v; # spent 33µs making 4 calls to File::MimeInfo::Magic::CORE:pack, avg 8µs/call
# spent 16µs making 4 calls to File::MimeInfo::Magic::CORE:unpack, avg 4µs/call |
184 | 4 | 8µs | $m = pack 'S', unpack 'n', $m if $mdef; | ||
185 | } | ||||
186 | elsif ( 4 == $w ) { | ||||
187 | 4 | 167µs | 8 | 49µs | $v = pack 'L', unpack 'N', $v; # spent 33µs making 4 calls to File::MimeInfo::Magic::CORE:pack, avg 8µs/call
# spent 16µs making 4 calls to File::MimeInfo::Magic::CORE:unpack, avg 4µs/call |
188 | 4 | 8µs | $m = pack 'L', unpack 'N', $m if $mdef; | ||
189 | } | ||||
190 | else { | ||||
191 | warn "Unsupported word size: $w octets ". | ||||
192 | " at $file line $line\n" | ||||
193 | } | ||||
194 | } | ||||
195 | |||||
196 | 810 | 3.59ms | my $end = $o + $l + $r - 1; | ||
197 | 810 | 907µs | $max_buffer = $end if $max_buffer < $end; | ||
198 | 810 | 4.04ms | 208 | 7.00ms | my $ref = $i ? _find_branch($i) : $magic[-1]; # spent 7.00ms making 208 calls to File::MimeInfo::Magic::_find_branch, avg 34µs/call |
199 | 810 | 585µs | $r--; # 1-based => 0-based range for regex | ||
200 | 810 | 403µs | $r *= 8 if $mdef; # bytes => bits for matching a mask | ||
201 | 810 | 4.28ms | 15 | 4.32ms | my $reg = '^' # spent 4.32ms making 15 calls to File::MimeInfo::Magic::_mask_regex, avg 288µs/call |
202 | . ( $r ? "(.{0,$r}?)" : '()' ) | ||||
203 | . ( $mdef ? '('. _mask_regex($v, $m) .')' | ||||
204 | : '('. quotemeta($v) .')' ) ; | ||||
205 | 810 | 133ms | 1620 | 32.0ms | push @$ref, [ # spent 22.6ms making 810 calls to File::MimeInfo::Magic::CORE:regcomp, avg 28µs/call
# spent 9.41ms making 810 calls to File::MimeInfo::Magic::CORE:qr, avg 12µs/call |
206 | $o, $end, # offset, offset+length+range | ||||
207 | $mdef, # boolean for mask | ||||
208 | qr/$reg/sm, # the regex to match | ||||
209 | undef # debug data | ||||
210 | ]; | ||||
211 | 810 | 18.0ms | 810 | 3.95ms | $$ref[-1][-1] = "$file line $line" if $DEBUG; # spent 3.95ms making 810 calls to File::MimeInfo::Magic::CORE:readline, avg 5µs/call |
212 | } | ||||
213 | 1 | 87µs | 1 | 28µs | close MAGIC; # spent 28µs making 1 call to File::MimeInfo::Magic::CORE:close |
214 | } | ||||
215 | |||||
216 | # spent 7.00ms within File::MimeInfo::Magic::_find_branch which was called 208 times, avg 34µs/call:
# 208 times (7.00ms+0s) by File::MimeInfo::Magic::_hash_magic at line 198, avg 34µs/call | ||||
217 | 208 | 424µs | my $i = shift; | ||
218 | 208 | 558µs | my $ref = $magic[-1]; | ||
219 | 484 | 3.71ms | for (1..$i) { $ref = $$ref[-1] } | ||
220 | 208 | 3.06ms | return $ref; | ||
221 | } | ||||
222 | |||||
223 | # spent 4.32ms (4.11+212µs) within File::MimeInfo::Magic::_mask_regex which was called 15 times, avg 288µs/call:
# 15 times (4.11ms+212µs) by File::MimeInfo::Magic::_hash_magic at line 201, avg 288µs/call | ||||
224 | 15 | 55µs | my ($v, $m) = @_; | ||
225 | 15 | 1.18ms | 15 | 136µs | my @v = split '', unpack "b*", $v; # spent 136µs making 15 calls to File::MimeInfo::Magic::CORE:unpack, avg 9µs/call |
226 | 15 | 985µs | 15 | 76µs | my @m = split '', unpack "b*", $m; # spent 76µs making 15 calls to File::MimeInfo::Magic::CORE:unpack, avg 5µs/call |
227 | 15 | 34µs | my $re = ''; | ||
228 | 15 | 121µs | for (0 .. $#m) { | ||
229 | 784 | 1.39ms | $re .= $m[$_] ? $v[$_] : '.' ; | ||
230 | # If $mask = 1 than ($input && $mask) will be same as $input | ||||
231 | # If $mask = 0 than ($input && $mask) is always 0 | ||||
232 | # But $mask = 0 only makes sense if $value = 0 | ||||
233 | # So if $mask = 0 we ignore that bit of $input | ||||
234 | } | ||||
235 | 15 | 587µs | return $re; | ||
236 | } | ||||
237 | |||||
238 | sub _escape_bytes { # used for debug output | ||||
239 | my $string = shift; | ||||
240 | if ($string =~ /[\x00-\x1F\x7F]/) { | ||||
241 | $string = join '', map { | ||||
242 | my $o = ord($_); | ||||
243 | ($o < 32) ? '^' . chr($o + 64) : | ||||
244 | ($o == 127) ? '^?' : $_ ; | ||||
245 | } split '', $string; | ||||
246 | } | ||||
247 | return $string; | ||||
248 | } | ||||
249 | |||||
250 | 1 | 29µs | 1; | ||
251 | |||||
252 | __END__ | ||||
sub File::MimeInfo::Magic::CORE:binmode; # opcode | |||||
sub File::MimeInfo::Magic::CORE:close; # opcode | |||||
# spent 13.4ms within File::MimeInfo::Magic::CORE:fteread which was called 2560 times, avg 5µs/call:
# 2560 times (13.4ms+0s) by File::MimeInfo::Magic::mimetype at line 36, avg 5µs/call | |||||
# spent 55.6ms within File::MimeInfo::Magic::CORE:ftsize which was called 2560 times, avg 22µs/call:
# 2560 times (55.6ms+0s) by File::MimeInfo::Magic::mimetype at line 36, avg 22µs/call | |||||
# spent 226ms within File::MimeInfo::Magic::CORE:match which was called 64901 times, avg 3µs/call:
# 62936 times (210ms+0s) by File::MimeInfo::Magic::_check_rule at line 102, avg 3µs/call
# 1155 times (6.22ms+0s) by File::MimeInfo::Magic::_hash_magic at line 156, avg 5µs/call
# 810 times (9.46ms+0s) by File::MimeInfo::Magic::_hash_magic at line 172, avg 12µs/call | |||||
sub File::MimeInfo::Magic::CORE:open; # opcode | |||||
sub File::MimeInfo::Magic::CORE:pack; # opcode | |||||
# spent 9.41ms within File::MimeInfo::Magic::CORE:qr which was called 810 times, avg 12µs/call:
# 810 times (9.41ms+0s) by File::MimeInfo::Magic::_hash_magic at line 205, avg 12µs/call | |||||
# spent 202µs within File::MimeInfo::Magic::CORE:rcatline which was called 45 times, avg 4µs/call:
# 45 times (202µs+0s) by File::MimeInfo::Magic::_hash_magic at line 166, avg 4µs/call | |||||
# spent 734ms within File::MimeInfo::Magic::CORE:read which was called 62936 times, avg 12µs/call:
# 62936 times (734ms+0s) by File::MimeInfo::Magic::_check_rule at line 93, avg 12µs/call | |||||
# spent 5.52ms within File::MimeInfo::Magic::CORE:readline which was called 1157 times, avg 5µs/call:
# 810 times (3.95ms+0s) by File::MimeInfo::Magic::_hash_magic at line 211, avg 5µs/call
# 346 times (1.52ms+0s) by File::MimeInfo::Magic::_hash_magic at line 153, avg 4µs/call
# once (49µs+0s) by File::MimeInfo::Magic::_hash_magic at line 150 | |||||
# spent 449ms within File::MimeInfo::Magic::CORE:regcomp which was called 64556 times, avg 7µs/call:
# 62936 times (396ms+0s) by File::MimeInfo::Magic::_check_rule at line 102, avg 6µs/call
# 810 times (30.2ms+0s) by File::MimeInfo::Magic::_hash_magic at line 172, avg 37µs/call
# 810 times (22.6ms+0s) by File::MimeInfo::Magic::_hash_magic at line 205, avg 28µs/call | |||||
# spent 382ms within File::MimeInfo::Magic::CORE:seek which was called 62936 times, avg 6µs/call:
# 62936 times (382ms+0s) by File::MimeInfo::Magic::_check_rule at line 92, avg 6µs/call | |||||
# spent 655µs within File::MimeInfo::Magic::CORE:sort which was called:
# once (655µs+0s) by File::MimeInfo::Magic::_rehash at line 137 | |||||
# spent 9.42ms within File::MimeInfo::Magic::CORE:subst which was called 810 times, avg 12µs/call:
# 810 times (9.42ms+0s) by File::MimeInfo::Magic::_hash_magic at line 162, avg 12µs/call | |||||
# spent 37.4ms within File::MimeInfo::Magic::CORE:unpack which was called 3444 times, avg 11µs/call:
# 2596 times (31.4ms+0s) by File::MimeInfo::Magic::_check_rule at line 101, avg 12µs/call
# 810 times (5.76ms+0s) by File::MimeInfo::Magic::_hash_magic at line 163, avg 7µs/call
# 15 times (136µs+0s) by File::MimeInfo::Magic::_mask_regex at line 225, avg 9µs/call
# 15 times (76µs+0s) by File::MimeInfo::Magic::_mask_regex at line 226, avg 5µs/call
# 4 times (16µs+0s) by File::MimeInfo::Magic::_hash_magic at line 187, avg 4µs/call
# 4 times (16µs+0s) by File::MimeInfo::Magic::_hash_magic at line 183, avg 4µs/call |