Filename | /usr/local/perls/perl-5.26.1/lib/5.26.1/IO/Uncompress/Gunzip.pm |
Statements | Executed 399 statements in 3.78ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 2.59ms | 14.6ms | BEGIN@12 | IO::Uncompress::Gunzip::
3 | 1 | 1 | 941µs | 3.05ms | _readGzipHeader | IO::Uncompress::Gunzip::
3 | 1 | 1 | 149µs | 13.3ms | new | IO::Uncompress::Gunzip::
3 | 1 | 1 | 102µs | 976µs | ckMagic | IO::Uncompress::Gunzip::
3 | 1 | 1 | 66µs | 3.12ms | readHeader | IO::Uncompress::Gunzip::
3 | 1 | 1 | 54µs | 68µs | isGzipMagic | IO::Uncompress::Gunzip::
3 | 1 | 1 | 40µs | 62µs | ckParams | IO::Uncompress::Gunzip::
2 | 1 | 1 | 33µs | 39µs | chkTrailer | IO::Uncompress::Gunzip::
8 | 3 | 1 | 27µs | 27µs | CORE:unpack (opcode) | IO::Uncompress::Gunzip::
1 | 1 | 1 | 22µs | 25µs | BEGIN@8 | IO::Uncompress::Gunzip::
1 | 1 | 1 | 17µs | 270µs | BEGIN@16 | IO::Uncompress::Gunzip::
1 | 1 | 1 | 16µs | 155µs | BEGIN@15 | IO::Uncompress::Gunzip::
1 | 1 | 1 | 14µs | 23µs | BEGIN@17 | IO::Uncompress::Gunzip::
1 | 1 | 1 | 12µs | 14µs | BEGIN@10 | IO::Uncompress::Gunzip::
1 | 1 | 1 | 12µs | 21µs | BEGIN@14 | IO::Uncompress::Gunzip::
1 | 1 | 1 | 11µs | 22µs | BEGIN@9 | IO::Uncompress::Gunzip::
3 | 1 | 1 | 8µs | 8µs | getExtraParams | IO::Uncompress::Gunzip::
0 | 0 | 0 | 0s | 0s | _readFullGzipHeader | IO::Uncompress::Gunzip::
0 | 0 | 0 | 0s | 0s | gunzip | IO::Uncompress::Gunzip::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | |||||
2 | package IO::Uncompress::Gunzip ; | ||||
3 | |||||
4 | 1 | 10µs | require 5.006 ; | ||
5 | |||||
6 | # for RFC1952 | ||||
7 | |||||
8 | 2 | 33µs | 2 | 28µs | # spent 25µs (22+3) within IO::Uncompress::Gunzip::BEGIN@8 which was called:
# once (22µs+3µs) by Compress::Zlib::BEGIN@13 at line 8 # spent 25µs making 1 call to IO::Uncompress::Gunzip::BEGIN@8
# spent 3µs making 1 call to strict::import |
9 | 2 | 30µs | 2 | 33µs | # spent 22µs (11+11) within IO::Uncompress::Gunzip::BEGIN@9 which was called:
# once (11µs+11µs) by Compress::Zlib::BEGIN@13 at line 9 # spent 22µs making 1 call to IO::Uncompress::Gunzip::BEGIN@9
# spent 11µs making 1 call to warnings::import |
10 | 2 | 34µs | 2 | 16µs | # spent 14µs (12+2) within IO::Uncompress::Gunzip::BEGIN@10 which was called:
# once (12µs+2µs) by Compress::Zlib::BEGIN@13 at line 10 # spent 14µs making 1 call to IO::Uncompress::Gunzip::BEGIN@10
# spent 2µs making 1 call to bytes::import |
11 | |||||
12 | 3 | 519µs | 3 | 14.6ms | # spent 14.6ms (2.59+12.0) within IO::Uncompress::Gunzip::BEGIN@12 which was called:
# once (2.59ms+12.0ms) by Compress::Zlib::BEGIN@13 at line 12 # spent 14.6ms making 1 call to IO::Uncompress::Gunzip::BEGIN@12
# spent 21µs making 1 call to Exporter::import
# spent 11µs making 1 call to version::_VERSION |
13 | |||||
14 | 3 | 70µs | 2 | 30µs | # spent 21µs (12+9) within IO::Uncompress::Gunzip::BEGIN@14 which was called:
# once (12µs+9µs) by Compress::Zlib::BEGIN@13 at line 14 # spent 21µs making 1 call to IO::Uncompress::Gunzip::BEGIN@14
# spent 9µs making 1 call to version::_VERSION |
15 | 3 | 56µs | 3 | 294µs | # spent 155µs (16+139) within IO::Uncompress::Gunzip::BEGIN@15 which was called:
# once (16µs+139µs) by Compress::Zlib::BEGIN@13 at line 15 # spent 155µs making 1 call to IO::Uncompress::Gunzip::BEGIN@15
# spent 131µs making 1 call to Exporter::import
# spent 8µs making 1 call to version::_VERSION |
16 | 3 | 54µs | 3 | 523µs | # spent 270µs (17+253) within IO::Uncompress::Gunzip::BEGIN@16 which was called:
# once (17µs+253µs) by Compress::Zlib::BEGIN@13 at line 16 # spent 270µs making 1 call to IO::Uncompress::Gunzip::BEGIN@16
# spent 244µs making 1 call to Exporter::import
# spent 9µs making 1 call to version::_VERSION |
17 | 3 | 1.57ms | 2 | 32µs | # spent 23µs (14+9) within IO::Uncompress::Gunzip::BEGIN@17 which was called:
# once (14µs+9µs) by Compress::Zlib::BEGIN@13 at line 17 # spent 23µs making 1 call to IO::Uncompress::Gunzip::BEGIN@17
# spent 9µs making 1 call to version::_VERSION |
18 | |||||
19 | 1 | 0s | require Exporter ; | ||
20 | |||||
21 | our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $GunzipError); | ||||
22 | |||||
23 | 1 | 21µs | @ISA = qw(IO::Uncompress::RawInflate Exporter); | ||
24 | 1 | 1µs | @EXPORT_OK = qw( $GunzipError gunzip ); | ||
25 | 1 | 1µs | %EXPORT_TAGS = %IO::Uncompress::RawInflate::DEFLATE_CONSTANTS ; | ||
26 | 1 | 2µs | push @{ $EXPORT_TAGS{all} }, @EXPORT_OK ; | ||
27 | 1 | 3µs | 1 | 24µs | Exporter::export_ok_tags('all'); # spent 24µs making 1 call to Exporter::export_ok_tags |
28 | |||||
29 | 1 | 0s | $GunzipError = ''; | ||
30 | |||||
31 | 1 | 1µs | $VERSION = '2.074'; | ||
32 | |||||
33 | sub new | ||||
34 | # spent 13.3ms (149µs+13.1) within IO::Uncompress::Gunzip::new which was called 3 times, avg 4.42ms/call:
# 3 times (149µs+13.1ms) by Compress::Zlib::gzopen at line 142 of Compress/Zlib.pm, avg 4.42ms/call | ||||
35 | 3 | 14µs | my $class = shift ; | ||
36 | 3 | 5µs | $GunzipError = ''; | ||
37 | 3 | 42µs | 3 | 365µs | my $obj = IO::Compress::Base::Common::createSelfTiedObject($class, \$GunzipError); # spent 365µs making 3 calls to IO::Compress::Base::Common::createSelfTiedObject, avg 122µs/call |
38 | |||||
39 | 3 | 65µs | 3 | 12.8ms | $obj->_create(undef, 0, @_); # spent 12.8ms making 3 calls to IO::Uncompress::Base::_create, avg 4.25ms/call |
40 | } | ||||
41 | |||||
42 | sub gunzip | ||||
43 | { | ||||
44 | my $obj = IO::Compress::Base::Common::createSelfTiedObject(undef, \$GunzipError); | ||||
45 | return $obj->_inf(@_) ; | ||||
46 | } | ||||
47 | |||||
48 | sub getExtraParams | ||||
49 | # spent 8µs within IO::Uncompress::Gunzip::getExtraParams which was called 3 times, avg 3µs/call:
# 3 times (8µs+0s) by IO::Uncompress::Base::checkParams at line 350 of IO/Uncompress/Base.pm, avg 3µs/call | ||||
50 | 3 | 14µs | return ( 'parseextra' => [IO::Compress::Base::Common::Parse_boolean, 0] ) ; | ||
51 | } | ||||
52 | |||||
53 | sub ckParams | ||||
54 | # spent 62µs (40+22) within IO::Uncompress::Gunzip::ckParams which was called 3 times, avg 21µs/call:
# 3 times (40µs+22µs) by IO::Uncompress::Base::_create at line 411 of IO/Uncompress/Base.pm, avg 21µs/call | ||||
55 | 3 | 3µs | my $self = shift ; | ||
56 | 3 | 3µs | my $got = shift ; | ||
57 | |||||
58 | # gunzip always needs crc32 | ||||
59 | 3 | 8µs | 3 | 22µs | $got->setValue('crc32' => 1); # spent 22µs making 3 calls to IO::Compress::Base::Parameters::setValue, avg 7µs/call |
60 | |||||
61 | 3 | 34µs | return 1; | ||
62 | } | ||||
63 | |||||
64 | sub ckMagic | ||||
65 | # spent 976µs (102+874) within IO::Uncompress::Gunzip::ckMagic which was called 3 times, avg 325µs/call:
# 3 times (102µs+874µs) by IO::Uncompress::RawInflate::mkUncomp at line 87 of IO/Uncompress/RawInflate.pm, avg 325µs/call | ||||
66 | 3 | 13µs | my $self = shift; | ||
67 | |||||
68 | 3 | 1µs | my $magic ; | ||
69 | 3 | 53µs | 3 | 806µs | $self->smartReadExact(\$magic, GZIP_ID_SIZE); # spent 806µs making 3 calls to IO::Uncompress::Base::smartReadExact, avg 269µs/call |
70 | |||||
71 | 3 | 5µs | *$self->{HeaderPending} = $magic ; | ||
72 | |||||
73 | 3 | 13µs | return $self->HeaderError("Minimum header size is " . | ||
74 | GZIP_MIN_HEADER_SIZE . " bytes") | ||||
75 | if length $magic != GZIP_ID_SIZE ; | ||||
76 | |||||
77 | 3 | 11µs | 3 | 68µs | return $self->HeaderError("Bad Magic") # spent 68µs making 3 calls to IO::Uncompress::Gunzip::isGzipMagic, avg 23µs/call |
78 | if ! isGzipMagic($magic) ; | ||||
79 | |||||
80 | 3 | 9µs | *$self->{Type} = 'rfc1952'; | ||
81 | |||||
82 | 3 | 17µs | return $magic ; | ||
83 | } | ||||
84 | |||||
85 | sub readHeader | ||||
86 | # spent 3.12ms (66µs+3.05) within IO::Uncompress::Gunzip::readHeader which was called 3 times, avg 1.04ms/call:
# 3 times (66µs+3.05ms) by IO::Uncompress::RawInflate::mkUncomp at line 90 of IO/Uncompress/RawInflate.pm, avg 1.04ms/call | ||||
87 | 3 | 15µs | my $self = shift; | ||
88 | 3 | 1µs | my $magic = shift; | ||
89 | |||||
90 | 3 | 92µs | 3 | 3.05ms | return $self->_readGzipHeader($magic); # spent 3.05ms making 3 calls to IO::Uncompress::Gunzip::_readGzipHeader, avg 1.02ms/call |
91 | } | ||||
92 | |||||
93 | sub chkTrailer | ||||
94 | # spent 39µs (33+6) within IO::Uncompress::Gunzip::chkTrailer which was called 2 times, avg 20µs/call:
# 2 times (33µs+6µs) by IO::Uncompress::Base::_raw_read at line 954 of IO/Uncompress/Base.pm, avg 20µs/call | ||||
95 | 2 | 1µs | my $self = shift; | ||
96 | 2 | 1µs | my $trailer = shift; | ||
97 | |||||
98 | # Check CRC & ISIZE | ||||
99 | 2 | 13µs | 2 | 6µs | my ($CRC32, $ISIZE) = unpack("V V", $trailer) ; # spent 6µs making 2 calls to IO::Uncompress::Gunzip::CORE:unpack, avg 3µs/call |
100 | 2 | 3µs | *$self->{Info}{CRC32} = $CRC32; | ||
101 | 2 | 11µs | *$self->{Info}{ISIZE} = $ISIZE; | ||
102 | |||||
103 | 2 | 4µs | if (*$self->{Strict}) { | ||
104 | return $self->TrailerError("CRC mismatch") | ||||
105 | if $CRC32 != *$self->{Uncomp}->crc32() ; | ||||
106 | |||||
107 | my $exp_isize = *$self->{UnCompSize}->get32bit(); | ||||
108 | return $self->TrailerError("ISIZE mismatch. Got $ISIZE" | ||||
109 | . ", expected $exp_isize") | ||||
110 | if $ISIZE != $exp_isize ; | ||||
111 | } | ||||
112 | |||||
113 | 2 | 7µs | return STATUS_OK; | ||
114 | } | ||||
115 | |||||
116 | sub isGzipMagic | ||||
117 | # spent 68µs (54+14) within IO::Uncompress::Gunzip::isGzipMagic which was called 3 times, avg 23µs/call:
# 3 times (54µs+14µs) by IO::Uncompress::Gunzip::ckMagic at line 77, avg 23µs/call | ||||
118 | 3 | 14µs | my $buffer = shift ; | ||
119 | 3 | 13µs | return 0 if length $buffer < GZIP_ID_SIZE ; | ||
120 | 3 | 29µs | 3 | 14µs | my ($id1, $id2) = unpack("C C", $buffer) ; # spent 14µs making 3 calls to IO::Uncompress::Gunzip::CORE:unpack, avg 5µs/call |
121 | 3 | 13µs | return $id1 == GZIP_ID1 && $id2 == GZIP_ID2 ; | ||
122 | } | ||||
123 | |||||
124 | sub _readFullGzipHeader($) | ||||
125 | { | ||||
126 | my ($self) = @_ ; | ||||
127 | my $magic = '' ; | ||||
128 | |||||
129 | $self->smartReadExact(\$magic, GZIP_ID_SIZE); | ||||
130 | |||||
131 | *$self->{HeaderPending} = $magic ; | ||||
132 | |||||
133 | return $self->HeaderError("Minimum header size is " . | ||||
134 | GZIP_MIN_HEADER_SIZE . " bytes") | ||||
135 | if length $magic != GZIP_ID_SIZE ; | ||||
136 | |||||
137 | |||||
138 | return $self->HeaderError("Bad Magic") | ||||
139 | if ! isGzipMagic($magic) ; | ||||
140 | |||||
141 | my $status = $self->_readGzipHeader($magic); | ||||
142 | delete *$self->{Transparent} if ! defined $status ; | ||||
143 | return $status ; | ||||
144 | } | ||||
145 | |||||
146 | sub _readGzipHeader($) | ||||
147 | # spent 3.05ms (941µs+2.11) within IO::Uncompress::Gunzip::_readGzipHeader which was called 3 times, avg 1.02ms/call:
# 3 times (941µs+2.11ms) by IO::Uncompress::Gunzip::readHeader at line 90, avg 1.02ms/call | ||||
148 | 3 | 4µs | my ($self, $magic) = @_ ; | ||
149 | 3 | 13µs | my ($HeaderCRC) ; | ||
150 | 3 | 12µs | my ($buffer) = '' ; | ||
151 | |||||
152 | 3 | 13µs | 3 | 119µs | $self->smartReadExact(\$buffer, GZIP_MIN_HEADER_SIZE - GZIP_ID_SIZE) # spent 119µs making 3 calls to IO::Uncompress::Base::smartReadExact, avg 40µs/call |
153 | or return $self->HeaderError("Minimum header size is " . | ||||
154 | GZIP_MIN_HEADER_SIZE . " bytes") ; | ||||
155 | |||||
156 | 3 | 17µs | my $keep = $magic . $buffer ; | ||
157 | 3 | 5µs | *$self->{HeaderPending} = $keep ; | ||
158 | |||||
159 | # now split out the various parts | ||||
160 | 3 | 24µs | 3 | 7µs | my ($cm, $flag, $mtime, $xfl, $os) = unpack("C C V C C", $buffer) ; # spent 7µs making 3 calls to IO::Uncompress::Gunzip::CORE:unpack, avg 2µs/call |
161 | |||||
162 | 3 | 1µs | $cm == GZIP_CM_DEFLATED | ||
163 | or return $self->HeaderError("Not Deflate (CM is $cm)") ; | ||||
164 | |||||
165 | # check for use of reserved bits | ||||
166 | 3 | 15µs | return $self->HeaderError("Use of Reserved Bits in FLG field.") | ||
167 | if $flag & GZIP_FLG_RESERVED ; | ||||
168 | |||||
169 | 3 | 12µs | my $EXTRA ; | ||
170 | 3 | 2µs | my @EXTRA = () ; | ||
171 | 3 | 16µs | if ($flag & GZIP_FLG_FEXTRA) { | ||
172 | $EXTRA = "" ; | ||||
173 | $self->smartReadExact(\$buffer, GZIP_FEXTRA_HEADER_SIZE) | ||||
174 | or return $self->TruncatedHeader("FEXTRA Length") ; | ||||
175 | |||||
176 | my ($XLEN) = unpack("v", $buffer) ; | ||||
177 | $self->smartReadExact(\$EXTRA, $XLEN) | ||||
178 | or return $self->TruncatedHeader("FEXTRA Body"); | ||||
179 | $keep .= $buffer . $EXTRA ; | ||||
180 | |||||
181 | if ($XLEN && *$self->{'ParseExtra'}) { | ||||
182 | my $bad = IO::Compress::Zlib::Extra::parseRawExtra($EXTRA, | ||||
183 | \@EXTRA, 1, 1); | ||||
184 | return $self->HeaderError($bad) | ||||
185 | if defined $bad; | ||||
186 | } | ||||
187 | } | ||||
188 | |||||
189 | 3 | 15µs | my $origname ; | ||
190 | 3 | 31µs | if ($flag & GZIP_FLG_FNAME) { | ||
191 | 3 | 4µs | $origname = "" ; | ||
192 | 3 | 1µs | while (1) { | ||
193 | 72 | 183µs | 72 | 1.98ms | $self->smartReadExact(\$buffer, 1) # spent 1.98ms making 72 calls to IO::Uncompress::Base::smartReadExact, avg 28µs/call |
194 | or return $self->TruncatedHeader("FNAME"); | ||||
195 | 72 | 168µs | last if $buffer eq GZIP_NULL_BYTE ; | ||
196 | 69 | 57µs | $origname .= $buffer | ||
197 | } | ||||
198 | 3 | 21µs | $keep .= $origname . GZIP_NULL_BYTE ; | ||
199 | |||||
200 | return $self->HeaderError("Non ISO 8859-1 Character found in Name") | ||||
201 | 3 | 5µs | if *$self->{Strict} && $origname =~ /$GZIP_FNAME_INVALID_CHAR_RE/o ; | ||
202 | } | ||||
203 | |||||
204 | 3 | 12µs | my $comment ; | ||
205 | 3 | 12µs | if ($flag & GZIP_FLG_FCOMMENT) { | ||
206 | $comment = ""; | ||||
207 | while (1) { | ||||
208 | $self->smartReadExact(\$buffer, 1) | ||||
209 | or return $self->TruncatedHeader("FCOMMENT"); | ||||
210 | last if $buffer eq GZIP_NULL_BYTE ; | ||||
211 | $comment .= $buffer | ||||
212 | } | ||||
213 | $keep .= $comment . GZIP_NULL_BYTE ; | ||||
214 | |||||
215 | return $self->HeaderError("Non ISO 8859-1 Character found in Comment") | ||||
216 | if *$self->{Strict} && $comment =~ /$GZIP_FCOMMENT_INVALID_CHAR_RE/o ; | ||||
217 | } | ||||
218 | |||||
219 | 3 | 2µs | if ($flag & GZIP_FLG_FHCRC) { | ||
220 | $self->smartReadExact(\$buffer, GZIP_FHCRC_SIZE) | ||||
221 | or return $self->TruncatedHeader("FHCRC"); | ||||
222 | |||||
223 | $HeaderCRC = unpack("v", $buffer) ; | ||||
224 | my $crc16 = Compress::Raw::Zlib::crc32($keep) & 0xFF ; | ||||
225 | |||||
226 | return $self->HeaderError("CRC16 mismatch.") | ||||
227 | if *$self->{Strict} && $crc16 != $HeaderCRC; | ||||
228 | |||||
229 | $keep .= $buffer ; | ||||
230 | } | ||||
231 | |||||
232 | # Assume compression method is deflated for xfl tests | ||||
233 | #if ($xfl) { | ||||
234 | #} | ||||
235 | |||||
236 | 3 | 12µs | *$self->{Type} = 'rfc1952'; | ||
237 | |||||
238 | return { | ||||
239 | 'Type' => 'rfc1952', | ||||
240 | 'FingerprintLength' => 2, | ||||
241 | 'HeaderLength' => length $keep, | ||||
242 | 'TrailerLength' => GZIP_TRAILER_SIZE, | ||||
243 | 'Header' => $keep, | ||||
244 | 'isMinimalHeader' => $keep eq GZIP_MINIMUM_HEADER ? 1 : 0, | ||||
245 | |||||
246 | 'MethodID' => $cm, | ||||
247 | 'MethodName' => $cm == GZIP_CM_DEFLATED ? "Deflated" : "Unknown" , | ||||
248 | 'TextFlag' => $flag & GZIP_FLG_FTEXT ? 1 : 0, | ||||
249 | 'HeaderCRCFlag' => $flag & GZIP_FLG_FHCRC ? 1 : 0, | ||||
250 | 'NameFlag' => $flag & GZIP_FLG_FNAME ? 1 : 0, | ||||
251 | 'CommentFlag' => $flag & GZIP_FLG_FCOMMENT ? 1 : 0, | ||||
252 | 'ExtraFlag' => $flag & GZIP_FLG_FEXTRA ? 1 : 0, | ||||
253 | 'Name' => $origname, | ||||
254 | 'Comment' => $comment, | ||||
255 | 'Time' => $mtime, | ||||
256 | 'OsID' => $os, | ||||
257 | 'OsName' => defined $GZIP_OS_Names{$os} | ||||
258 | 3 | 184µs | ? $GZIP_OS_Names{$os} : "Unknown", | ||
259 | 'HeaderCRC' => $HeaderCRC, | ||||
260 | 'Flags' => $flag, | ||||
261 | 'ExtraFlags' => $xfl, | ||||
262 | 'ExtraFieldRaw' => $EXTRA, | ||||
263 | 'ExtraField' => [ @EXTRA ], | ||||
264 | |||||
265 | |||||
266 | #'CompSize'=> $compsize, | ||||
267 | #'CRC32'=> $CRC32, | ||||
268 | #'OrigSize'=> $ISIZE, | ||||
269 | } | ||||
270 | } | ||||
271 | |||||
272 | |||||
273 | 1 | 13µs | 1; | ||
274 | |||||
275 | __END__ | ||||
# spent 27µs within IO::Uncompress::Gunzip::CORE:unpack which was called 8 times, avg 3µs/call:
# 3 times (14µs+0s) by IO::Uncompress::Gunzip::isGzipMagic at line 120, avg 5µs/call
# 3 times (7µs+0s) by IO::Uncompress::Gunzip::_readGzipHeader at line 160, avg 2µs/call
# 2 times (6µs+0s) by IO::Uncompress::Gunzip::chkTrailer at line 99, avg 3µs/call |