Filename | /usr/lib/perl/5.10/Compress/Zlib.pm |
Statements | Executed 1218 statements in 542ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
50 | 1 | 1 | 400ms | 562ms | memGunzip | Compress::Zlib::
1 | 1 | 1 | 6.09ms | 13.2ms | BEGIN@11 | Compress::Zlib::
1 | 1 | 1 | 3.78ms | 6.21ms | BEGIN@12 | Compress::Zlib::
1 | 1 | 1 | 1.79ms | 16.7ms | BEGIN@14 | Compress::Zlib::
50 | 1 | 1 | 1.79ms | 2.85ms | _removeGzipHeader | Compress::Zlib::
1 | 1 | 1 | 1.69ms | 16.4ms | BEGIN@13 | Compress::Zlib::
1 | 1 | 1 | 1.02ms | 1.74ms | BEGIN@9 | Compress::Zlib::
100 | 2 | 1 | 516µs | 516µs | CORE:unpack (opcode) | Compress::Zlib::
1 | 1 | 1 | 27µs | 387µs | BEGIN@455 | Compress::Zlib::
1 | 1 | 1 | 22µs | 178µs | BEGIN@6 | Compress::Zlib::
1 | 1 | 1 | 22µs | 56µs | BEGIN@8 | Compress::Zlib::
1 | 1 | 1 | 19µs | 87µs | BEGIN@7 | Compress::Zlib::
1 | 1 | 1 | 13µs | 57µs | BEGIN@55 | Compress::Zlib::
1 | 1 | 1 | 12µs | 18µs | BEGIN@16 | Compress::Zlib::
1 | 1 | 1 | 12µs | 16µs | BEGIN@18 | Compress::Zlib::
1 | 1 | 1 | 12µs | 73µs | BEGIN@54 | Compress::Zlib::
1 | 1 | 1 | 12µs | 29µs | BEGIN@17 | Compress::Zlib::
1 | 1 | 1 | 10µs | 35µs | BEGIN@49 | Compress::Zlib::
1 | 1 | 1 | 9µs | 46µs | BEGIN@56 | Compress::Zlib::
1 | 1 | 1 | 9µs | 40µs | BEGIN@57 | Compress::Zlib::
1 | 1 | 1 | 7µs | 7µs | BEGIN@40 | Compress::Zlib::
0 | 0 | 0 | 0s | 0s | AUTOLOAD | Compress::Zlib::
0 | 0 | 0 | 0s | 0s | __ANON__[:50] | Compress::Zlib::
0 | 0 | 0 | 0s | 0s | _save_gzerr | Compress::Zlib::
0 | 0 | 0 | 0s | 0s | _set_gzerr | Compress::Zlib::
0 | 0 | 0 | 0s | 0s | compress | Compress::Zlib::
0 | 0 | 0 | 0s | 0s | deflateInit | Compress::Zlib::
0 | 0 | 0 | 0s | 0s | gzclose | Compress::Zlib::gzFile::
0 | 0 | 0 | 0s | 0s | gzeof | Compress::Zlib::gzFile::
0 | 0 | 0 | 0s | 0s | gzerror | Compress::Zlib::gzFile::
0 | 0 | 0 | 0s | 0s | gzflush | Compress::Zlib::gzFile::
0 | 0 | 0 | 0s | 0s | gzread | Compress::Zlib::gzFile::
0 | 0 | 0 | 0s | 0s | gzreadline | Compress::Zlib::gzFile::
0 | 0 | 0 | 0s | 0s | gzseek | Compress::Zlib::gzFile::
0 | 0 | 0 | 0s | 0s | gzsetparams | Compress::Zlib::gzFile::
0 | 0 | 0 | 0s | 0s | gztell | Compress::Zlib::gzFile::
0 | 0 | 0 | 0s | 0s | gzwrite | Compress::Zlib::gzFile::
0 | 0 | 0 | 0s | 0s | gzopen | Compress::Zlib::
0 | 0 | 0 | 0s | 0s | inflateInit | Compress::Zlib::
0 | 0 | 0 | 0s | 0s | memGzip | Compress::Zlib::
0 | 0 | 0 | 0s | 0s | uncompress | Compress::Zlib::
0 | 0 | 0 | 0s | 0s | deflate | Zlib::OldDeflate::
0 | 0 | 0 | 0s | 0s | flush | Zlib::OldDeflate::
0 | 0 | 0 | 0s | 0s | inflate | Zlib::OldInflate::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | |||||
2 | package Compress::Zlib; | ||||
3 | |||||
4 | 1 | 19µs | require 5.004 ; | ||
5 | 1 | 800ns | require Exporter; | ||
6 | 3 | 38µs | 2 | 333µs | # spent 178µs (22+156) within Compress::Zlib::BEGIN@6 which was called:
# once (22µs+156µs) by Cache::Memcached::BEGIN@1 at line 6 # spent 178µs making 1 call to Compress::Zlib::BEGIN@6
# spent 156µs making 1 call to AutoLoader::import |
7 | 3 | 56µs | 2 | 155µs | # spent 87µs (19+68) within Compress::Zlib::BEGIN@7 which was called:
# once (19µs+68µs) by Cache::Memcached::BEGIN@1 at line 7 # spent 87µs making 1 call to Compress::Zlib::BEGIN@7
# spent 68µs making 1 call to Exporter::import |
8 | 3 | 47µs | 2 | 90µs | # spent 56µs (22+34) within Compress::Zlib::BEGIN@8 which was called:
# once (22µs+34µs) by Cache::Memcached::BEGIN@1 at line 8 # spent 56µs making 1 call to Compress::Zlib::BEGIN@8
# spent 34µs making 1 call to Exporter::import |
9 | 3 | 170µs | 2 | 1.86ms | # spent 1.74ms (1.02+722µs) within Compress::Zlib::BEGIN@9 which was called:
# once (1.02ms+722µs) by Cache::Memcached::BEGIN@1 at line 9 # spent 1.74ms making 1 call to Compress::Zlib::BEGIN@9
# spent 114µs making 1 call to Exporter::import |
10 | |||||
11 | 3 | 266µs | 3 | 13.5ms | # spent 13.2ms (6.09+7.15) within Compress::Zlib::BEGIN@11 which was called:
# once (6.09ms+7.15ms) by Cache::Memcached::BEGIN@1 at line 11 # spent 13.2ms making 1 call to Compress::Zlib::BEGIN@11
# spent 250µs making 1 call to Exporter::import
# spent 43µs making 1 call to UNIVERSAL::VERSION |
12 | 3 | 223µs | 3 | 6.70ms | # spent 6.21ms (3.78+2.43) within Compress::Zlib::BEGIN@12 which was called:
# once (3.78ms+2.43ms) by Cache::Memcached::BEGIN@1 at line 12 # spent 6.21ms making 1 call to Compress::Zlib::BEGIN@12
# spent 457µs making 1 call to Exporter::import
# spent 27µs making 1 call to UNIVERSAL::VERSION |
13 | 3 | 243µs | 3 | 16.5ms | # spent 16.4ms (1.69+14.7) within Compress::Zlib::BEGIN@13 which was called:
# once (1.69ms+14.7ms) by Cache::Memcached::BEGIN@1 at line 13 # spent 16.4ms making 1 call to Compress::Zlib::BEGIN@13
# spent 78µs making 1 call to Exporter::import
# spent 22µs making 1 call to UNIVERSAL::VERSION |
14 | 3 | 188µs | 3 | 16.8ms | # spent 16.7ms (1.79+15.0) within Compress::Zlib::BEGIN@14 which was called:
# once (1.79ms+15.0ms) by Cache::Memcached::BEGIN@1 at line 14 # spent 16.7ms making 1 call to Compress::Zlib::BEGIN@14
# spent 36µs making 1 call to Exporter::import
# spent 16µs making 1 call to UNIVERSAL::VERSION |
15 | |||||
16 | 3 | 26µs | 2 | 23µs | # spent 18µs (12+5) within Compress::Zlib::BEGIN@16 which was called:
# once (12µs+5µs) by Cache::Memcached::BEGIN@1 at line 16 # spent 18µs making 1 call to Compress::Zlib::BEGIN@16
# spent 5µs making 1 call to strict::import |
17 | 3 | 28µs | 2 | 45µs | # spent 29µs (12+17) within Compress::Zlib::BEGIN@17 which was called:
# once (12µs+17µs) by Cache::Memcached::BEGIN@1 at line 17 # spent 29µs making 1 call to Compress::Zlib::BEGIN@17
# spent 17µs making 1 call to warnings::import |
18 | 3 | 115µs | 2 | 19µs | # spent 16µs (12+3) within Compress::Zlib::BEGIN@18 which was called:
# once (12µs+3µs) by Cache::Memcached::BEGIN@1 at line 18 # spent 16µs making 1 call to Compress::Zlib::BEGIN@18
# spent 3µs making 1 call to bytes::import |
19 | 1 | 1µs | our ($VERSION, $XS_VERSION, @ISA, @EXPORT, $AUTOLOAD); | ||
20 | |||||
21 | 1 | 500ns | $VERSION = '2.020'; | ||
22 | 1 | 300ns | $XS_VERSION = $VERSION; | ||
23 | 1 | 23µs | $VERSION = eval $VERSION; # spent 4µs executing statements in string eval | ||
24 | |||||
25 | 1 | 10µs | @ISA = qw(Exporter); | ||
26 | # Items to export into callers namespace by default. Note: do not export | ||||
27 | # names by default without a very good reason. Use EXPORT_OK instead. | ||||
28 | # Do not simply export all your public functions/methods/constants. | ||||
29 | 1 | 2µs | @EXPORT = qw( | ||
30 | deflateInit inflateInit | ||||
31 | |||||
32 | compress uncompress | ||||
33 | |||||
34 | gzopen $gzerrno | ||||
35 | ); | ||||
36 | |||||
37 | 1 | 13µs | push @EXPORT, @Compress::Raw::Zlib::EXPORT ; | ||
38 | |||||
39 | BEGIN | ||||
40 | # spent 7µs within Compress::Zlib::BEGIN@40 which was called:
# once (7µs+0s) by Cache::Memcached::BEGIN@1 at line 42 | ||||
41 | 1 | 8µs | *zlib_version = \&Compress::Raw::Zlib::zlib_version; | ||
42 | 1 | 84µs | 1 | 7µs | } # spent 7µs making 1 call to Compress::Zlib::BEGIN@40 |
43 | |||||
44 | sub AUTOLOAD { | ||||
45 | my($constname); | ||||
46 | ($constname = $AUTOLOAD) =~ s/.*:://; | ||||
47 | my ($error, $val) = Compress::Raw::Zlib::constant($constname); | ||||
48 | Carp::croak $error if $error; | ||||
49 | 3 | 120µs | 2 | 61µs | # spent 35µs (10+25) within Compress::Zlib::BEGIN@49 which was called:
# once (10µs+25µs) by Cache::Memcached::BEGIN@1 at line 49 # spent 35µs making 1 call to Compress::Zlib::BEGIN@49
# spent 25µs making 1 call to strict::unimport |
50 | *{$AUTOLOAD} = sub { $val }; | ||||
51 | goto &{$AUTOLOAD}; | ||||
52 | } | ||||
53 | |||||
54 | 3 | 62µs | 2 | 133µs | # spent 73µs (12+61) within Compress::Zlib::BEGIN@54 which was called:
# once (12µs+61µs) by Cache::Memcached::BEGIN@1 at line 54 # spent 73µs making 1 call to Compress::Zlib::BEGIN@54
# spent 61µs making 1 call to constant::import |
55 | 3 | 34µs | 2 | 101µs | # spent 57µs (13+44) within Compress::Zlib::BEGIN@55 which was called:
# once (13µs+44µs) by Cache::Memcached::BEGIN@1 at line 55 # spent 57µs making 1 call to Compress::Zlib::BEGIN@55
# spent 44µs making 1 call to constant::import |
56 | 3 | 30µs | 2 | 83µs | # spent 46µs (9+37) within Compress::Zlib::BEGIN@56 which was called:
# once (9µs+37µs) by Cache::Memcached::BEGIN@1 at line 56 # spent 46µs making 1 call to Compress::Zlib::BEGIN@56
# spent 37µs making 1 call to constant::import |
57 | 3 | 2.00ms | 2 | 71µs | # spent 40µs (9+31) within Compress::Zlib::BEGIN@57 which was called:
# once (9µs+31µs) by Cache::Memcached::BEGIN@1 at line 57 # spent 40µs making 1 call to Compress::Zlib::BEGIN@57
# spent 31µs making 1 call to constant::import |
58 | |||||
59 | 1 | 200ns | our (@my_z_errmsg); | ||
60 | |||||
61 | 1 | 2µs | @my_z_errmsg = ( | ||
62 | "need dictionary", # Z_NEED_DICT 2 | ||||
63 | "stream end", # Z_STREAM_END 1 | ||||
64 | "", # Z_OK 0 | ||||
65 | "file error", # Z_ERRNO (-1) | ||||
66 | "stream error", # Z_STREAM_ERROR (-2) | ||||
67 | "data error", # Z_DATA_ERROR (-3) | ||||
68 | "insufficient memory", # Z_MEM_ERROR (-4) | ||||
69 | "buffer error", # Z_BUF_ERROR (-5) | ||||
70 | "incompatible version",# Z_VERSION_ERROR(-6) | ||||
71 | ); | ||||
72 | |||||
73 | |||||
74 | sub _set_gzerr | ||||
75 | { | ||||
76 | my $value = shift ; | ||||
77 | |||||
78 | if ($value == 0) { | ||||
79 | $Compress::Zlib::gzerrno = 0 ; | ||||
80 | } | ||||
81 | elsif ($value == Z_ERRNO() || $value > 2) { | ||||
82 | $Compress::Zlib::gzerrno = $! ; | ||||
83 | } | ||||
84 | else { | ||||
85 | $Compress::Zlib::gzerrno = dualvar($value+0, $my_z_errmsg[2 - $value]); | ||||
86 | } | ||||
87 | |||||
88 | return $value ; | ||||
89 | } | ||||
90 | |||||
91 | sub _save_gzerr | ||||
92 | { | ||||
93 | my $gz = shift ; | ||||
94 | my $test_eof = shift ; | ||||
95 | |||||
96 | my $value = $gz->errorNo() || 0 ; | ||||
97 | |||||
98 | if ($test_eof) { | ||||
99 | #my $gz = $self->[0] ; | ||||
100 | # gzread uses Z_STREAM_END to denote a successful end | ||||
101 | $value = Z_STREAM_END() if $gz->eof() && $value == 0 ; | ||||
102 | } | ||||
103 | |||||
104 | _set_gzerr($value) ; | ||||
105 | } | ||||
106 | |||||
107 | sub gzopen($$) | ||||
108 | { | ||||
109 | my ($file, $mode) = @_ ; | ||||
110 | |||||
111 | my $gz ; | ||||
112 | my %defOpts = (Level => Z_DEFAULT_COMPRESSION(), | ||||
113 | Strategy => Z_DEFAULT_STRATEGY(), | ||||
114 | ); | ||||
115 | |||||
116 | my $writing ; | ||||
117 | $writing = ! ($mode =~ /r/i) ; | ||||
118 | $writing = ($mode =~ /[wa]/i) ; | ||||
119 | |||||
120 | $defOpts{Level} = $1 if $mode =~ /(\d)/; | ||||
121 | $defOpts{Strategy} = Z_FILTERED() if $mode =~ /f/i; | ||||
122 | $defOpts{Strategy} = Z_HUFFMAN_ONLY() if $mode =~ /h/i; | ||||
123 | $defOpts{Append} = 1 if $mode =~ /a/i; | ||||
124 | |||||
125 | my $infDef = $writing ? 'deflate' : 'inflate'; | ||||
126 | my @params = () ; | ||||
127 | |||||
128 | croak "gzopen: file parameter is not a filehandle or filename" | ||||
129 | unless isaFilehandle $file || isaFilename $file || | ||||
130 | (ref $file && ref $file eq 'SCALAR'); | ||||
131 | |||||
132 | return undef unless $mode =~ /[rwa]/i ; | ||||
133 | |||||
134 | _set_gzerr(0) ; | ||||
135 | |||||
136 | if ($writing) { | ||||
137 | $gz = new IO::Compress::Gzip($file, Minimal => 1, AutoClose => 1, | ||||
138 | %defOpts) | ||||
139 | or $Compress::Zlib::gzerrno = $IO::Compress::Gzip::GzipError; | ||||
140 | } | ||||
141 | else { | ||||
142 | $gz = new IO::Uncompress::Gunzip($file, | ||||
143 | Transparent => 1, | ||||
144 | Append => 0, | ||||
145 | AutoClose => 1, | ||||
146 | MultiStream => 1, | ||||
147 | Strict => 0) | ||||
148 | or $Compress::Zlib::gzerrno = $IO::Uncompress::Gunzip::GunzipError; | ||||
149 | } | ||||
150 | |||||
151 | return undef | ||||
152 | if ! defined $gz ; | ||||
153 | |||||
154 | bless [$gz, $infDef], 'Compress::Zlib::gzFile'; | ||||
155 | } | ||||
156 | |||||
157 | sub Compress::Zlib::gzFile::gzread | ||||
158 | { | ||||
159 | my $self = shift ; | ||||
160 | |||||
161 | return _set_gzerr(Z_STREAM_ERROR()) | ||||
162 | if $self->[1] ne 'inflate'; | ||||
163 | |||||
164 | my $len = defined $_[1] ? $_[1] : 4096 ; | ||||
165 | |||||
166 | if ($self->gzeof() || $len == 0) { | ||||
167 | # Zap the output buffer to match ver 1 behaviour. | ||||
168 | $_[0] = "" ; | ||||
169 | return 0 ; | ||||
170 | } | ||||
171 | |||||
172 | my $gz = $self->[0] ; | ||||
173 | my $status = $gz->read($_[0], $len) ; | ||||
174 | _save_gzerr($gz, 1); | ||||
175 | return $status ; | ||||
176 | } | ||||
177 | |||||
178 | sub Compress::Zlib::gzFile::gzreadline | ||||
179 | { | ||||
180 | my $self = shift ; | ||||
181 | |||||
182 | my $gz = $self->[0] ; | ||||
183 | { | ||||
184 | # Maintain backward compatibility with 1.x behaviour | ||||
185 | # It didn't support $/, so this can't either. | ||||
186 | local $/ = "\n" ; | ||||
187 | $_[0] = $gz->getline() ; | ||||
188 | } | ||||
189 | _save_gzerr($gz, 1); | ||||
190 | return defined $_[0] ? length $_[0] : 0 ; | ||||
191 | } | ||||
192 | |||||
193 | sub Compress::Zlib::gzFile::gzwrite | ||||
194 | { | ||||
195 | my $self = shift ; | ||||
196 | my $gz = $self->[0] ; | ||||
197 | |||||
198 | return _set_gzerr(Z_STREAM_ERROR()) | ||||
199 | if $self->[1] ne 'deflate'; | ||||
200 | |||||
201 | $] >= 5.008 and (utf8::downgrade($_[0], 1) | ||||
202 | or croak "Wide character in gzwrite"); | ||||
203 | |||||
204 | my $status = $gz->write($_[0]) ; | ||||
205 | _save_gzerr($gz); | ||||
206 | return $status ; | ||||
207 | } | ||||
208 | |||||
209 | sub Compress::Zlib::gzFile::gztell | ||||
210 | { | ||||
211 | my $self = shift ; | ||||
212 | my $gz = $self->[0] ; | ||||
213 | my $status = $gz->tell() ; | ||||
214 | _save_gzerr($gz); | ||||
215 | return $status ; | ||||
216 | } | ||||
217 | |||||
218 | sub Compress::Zlib::gzFile::gzseek | ||||
219 | { | ||||
220 | my $self = shift ; | ||||
221 | my $offset = shift ; | ||||
222 | my $whence = shift ; | ||||
223 | |||||
224 | my $gz = $self->[0] ; | ||||
225 | my $status ; | ||||
226 | eval { $status = $gz->seek($offset, $whence) ; }; | ||||
227 | if ($@) | ||||
228 | { | ||||
229 | my $error = $@; | ||||
230 | $error =~ s/^.*: /gzseek: /; | ||||
231 | $error =~ s/ at .* line \d+\s*$//; | ||||
232 | croak $error; | ||||
233 | } | ||||
234 | _save_gzerr($gz); | ||||
235 | return $status ; | ||||
236 | } | ||||
237 | |||||
238 | sub Compress::Zlib::gzFile::gzflush | ||||
239 | { | ||||
240 | my $self = shift ; | ||||
241 | my $f = shift ; | ||||
242 | |||||
243 | my $gz = $self->[0] ; | ||||
244 | my $status = $gz->flush($f) ; | ||||
245 | my $err = _save_gzerr($gz); | ||||
246 | return $status ? 0 : $err; | ||||
247 | } | ||||
248 | |||||
249 | sub Compress::Zlib::gzFile::gzclose | ||||
250 | { | ||||
251 | my $self = shift ; | ||||
252 | my $gz = $self->[0] ; | ||||
253 | |||||
254 | my $status = $gz->close() ; | ||||
255 | my $err = _save_gzerr($gz); | ||||
256 | return $status ? 0 : $err; | ||||
257 | } | ||||
258 | |||||
259 | sub Compress::Zlib::gzFile::gzeof | ||||
260 | { | ||||
261 | my $self = shift ; | ||||
262 | my $gz = $self->[0] ; | ||||
263 | |||||
264 | return 0 | ||||
265 | if $self->[1] ne 'inflate'; | ||||
266 | |||||
267 | my $status = $gz->eof() ; | ||||
268 | _save_gzerr($gz); | ||||
269 | return $status ; | ||||
270 | } | ||||
271 | |||||
272 | sub Compress::Zlib::gzFile::gzsetparams | ||||
273 | { | ||||
274 | my $self = shift ; | ||||
275 | croak "Usage: Compress::Zlib::gzFile::gzsetparams(file, level, strategy)" | ||||
276 | unless @_ eq 2 ; | ||||
277 | |||||
278 | my $gz = $self->[0] ; | ||||
279 | my $level = shift ; | ||||
280 | my $strategy = shift; | ||||
281 | |||||
282 | return _set_gzerr(Z_STREAM_ERROR()) | ||||
283 | if $self->[1] ne 'deflate'; | ||||
284 | |||||
285 | my $status = *$gz->{Compress}->deflateParams(-Level => $level, | ||||
286 | -Strategy => $strategy); | ||||
287 | _save_gzerr($gz); | ||||
288 | return $status ; | ||||
289 | } | ||||
290 | |||||
291 | sub Compress::Zlib::gzFile::gzerror | ||||
292 | { | ||||
293 | my $self = shift ; | ||||
294 | my $gz = $self->[0] ; | ||||
295 | |||||
296 | return $Compress::Zlib::gzerrno ; | ||||
297 | } | ||||
298 | |||||
299 | |||||
300 | sub compress($;$) | ||||
301 | { | ||||
302 | my ($x, $output, $err, $in) =('', '', '', '') ; | ||||
303 | |||||
304 | if (ref $_[0] ) { | ||||
305 | $in = $_[0] ; | ||||
306 | croak "not a scalar reference" unless ref $in eq 'SCALAR' ; | ||||
307 | } | ||||
308 | else { | ||||
309 | $in = \$_[0] ; | ||||
310 | } | ||||
311 | |||||
312 | $] >= 5.008 and (utf8::downgrade($$in, 1) | ||||
313 | or croak "Wide character in compress"); | ||||
314 | |||||
315 | my $level = (@_ == 2 ? $_[1] : Z_DEFAULT_COMPRESSION() ); | ||||
316 | |||||
317 | $x = new Compress::Raw::Zlib::Deflate -AppendOutput => 1, -Level => $level | ||||
318 | or return undef ; | ||||
319 | |||||
320 | $err = $x->deflate($in, $output) ; | ||||
321 | return undef unless $err == Z_OK() ; | ||||
322 | |||||
323 | $err = $x->flush($output) ; | ||||
324 | return undef unless $err == Z_OK() ; | ||||
325 | |||||
326 | return $output ; | ||||
327 | |||||
328 | } | ||||
329 | |||||
330 | sub uncompress($) | ||||
331 | { | ||||
332 | my ($x, $output, $err, $in) =('', '', '', '') ; | ||||
333 | |||||
334 | if (ref $_[0] ) { | ||||
335 | $in = $_[0] ; | ||||
336 | croak "not a scalar reference" unless ref $in eq 'SCALAR' ; | ||||
337 | } | ||||
338 | else { | ||||
339 | $in = \$_[0] ; | ||||
340 | } | ||||
341 | |||||
342 | $] >= 5.008 and (utf8::downgrade($$in, 1) | ||||
343 | or croak "Wide character in uncompress"); | ||||
344 | |||||
345 | $x = new Compress::Raw::Zlib::Inflate -ConsumeInput => 0 or return undef ; | ||||
346 | |||||
347 | $err = $x->inflate($in, $output) ; | ||||
348 | return undef unless $err == Z_STREAM_END() ; | ||||
349 | |||||
350 | return $output ; | ||||
351 | } | ||||
352 | |||||
- - | |||||
355 | sub deflateInit(@) | ||||
356 | { | ||||
357 | my ($got) = ParseParameters(0, | ||||
358 | { | ||||
359 | 'Bufsize' => [1, 1, Parse_unsigned, 4096], | ||||
360 | 'Level' => [1, 1, Parse_signed, Z_DEFAULT_COMPRESSION()], | ||||
361 | 'Method' => [1, 1, Parse_unsigned, Z_DEFLATED()], | ||||
362 | 'WindowBits' => [1, 1, Parse_signed, MAX_WBITS()], | ||||
363 | 'MemLevel' => [1, 1, Parse_unsigned, MAX_MEM_LEVEL()], | ||||
364 | 'Strategy' => [1, 1, Parse_unsigned, Z_DEFAULT_STRATEGY()], | ||||
365 | 'Dictionary' => [1, 1, Parse_any, ""], | ||||
366 | }, @_ ) ; | ||||
367 | |||||
368 | croak "Compress::Zlib::deflateInit: Bufsize must be >= 1, you specified " . | ||||
369 | $got->value('Bufsize') | ||||
370 | unless $got->value('Bufsize') >= 1; | ||||
371 | |||||
372 | my $obj ; | ||||
373 | |||||
374 | my $status = 0 ; | ||||
375 | ($obj, $status) = | ||||
376 | Compress::Raw::Zlib::_deflateInit(0, | ||||
377 | $got->value('Level'), | ||||
378 | $got->value('Method'), | ||||
379 | $got->value('WindowBits'), | ||||
380 | $got->value('MemLevel'), | ||||
381 | $got->value('Strategy'), | ||||
382 | $got->value('Bufsize'), | ||||
383 | $got->value('Dictionary')) ; | ||||
384 | |||||
385 | my $x = ($status == Z_OK() ? bless $obj, "Zlib::OldDeflate" : undef) ; | ||||
386 | return wantarray ? ($x, $status) : $x ; | ||||
387 | } | ||||
388 | |||||
389 | sub inflateInit(@) | ||||
390 | { | ||||
391 | my ($got) = ParseParameters(0, | ||||
392 | { | ||||
393 | 'Bufsize' => [1, 1, Parse_unsigned, 4096], | ||||
394 | 'WindowBits' => [1, 1, Parse_signed, MAX_WBITS()], | ||||
395 | 'Dictionary' => [1, 1, Parse_any, ""], | ||||
396 | }, @_) ; | ||||
397 | |||||
398 | |||||
399 | croak "Compress::Zlib::inflateInit: Bufsize must be >= 1, you specified " . | ||||
400 | $got->value('Bufsize') | ||||
401 | unless $got->value('Bufsize') >= 1; | ||||
402 | |||||
403 | my $status = 0 ; | ||||
404 | my $obj ; | ||||
405 | ($obj, $status) = Compress::Raw::Zlib::_inflateInit(FLAG_CONSUME_INPUT, | ||||
406 | $got->value('WindowBits'), | ||||
407 | $got->value('Bufsize'), | ||||
408 | $got->value('Dictionary')) ; | ||||
409 | |||||
410 | my $x = ($status == Z_OK() ? bless $obj, "Zlib::OldInflate" : undef) ; | ||||
411 | |||||
412 | wantarray ? ($x, $status) : $x ; | ||||
413 | } | ||||
414 | |||||
415 | package Zlib::OldDeflate ; | ||||
416 | |||||
417 | 1 | 200ns | our (@ISA); | ||
418 | 1 | 8µs | @ISA = qw(Compress::Raw::Zlib::deflateStream); | ||
419 | |||||
420 | |||||
421 | sub deflate | ||||
422 | { | ||||
423 | my $self = shift ; | ||||
424 | my $output ; | ||||
425 | |||||
426 | my $status = $self->SUPER::deflate($_[0], $output) ; | ||||
427 | wantarray ? ($output, $status) : $output ; | ||||
428 | } | ||||
429 | |||||
430 | sub flush | ||||
431 | { | ||||
432 | my $self = shift ; | ||||
433 | my $output ; | ||||
434 | my $flag = shift || Compress::Zlib::Z_FINISH(); | ||||
435 | my $status = $self->SUPER::flush($output, $flag) ; | ||||
436 | |||||
437 | wantarray ? ($output, $status) : $output ; | ||||
438 | } | ||||
439 | |||||
440 | package Zlib::OldInflate ; | ||||
441 | |||||
442 | 1 | 200ns | our (@ISA); | ||
443 | 1 | 6µs | @ISA = qw(Compress::Raw::Zlib::inflateStream); | ||
444 | |||||
445 | sub inflate | ||||
446 | { | ||||
447 | my $self = shift ; | ||||
448 | my $output ; | ||||
449 | my $status = $self->SUPER::inflate($_[0], $output) ; | ||||
450 | wantarray ? ($output, $status) : $output ; | ||||
451 | } | ||||
452 | |||||
453 | package Compress::Zlib ; | ||||
454 | |||||
455 | 3 | 700µs | 3 | 748µs | # spent 387µs (27+360) within Compress::Zlib::BEGIN@455 which was called:
# once (27µs+360µs) by Cache::Memcached::BEGIN@1 at line 455 # spent 387µs making 1 call to Compress::Zlib::BEGIN@455
# spent 335µs making 1 call to Exporter::import
# spent 25µs making 1 call to UNIVERSAL::VERSION |
456 | |||||
457 | sub memGzip($) | ||||
458 | { | ||||
459 | my $out; | ||||
460 | |||||
461 | # if the deflation buffer isn't a reference, make it one | ||||
462 | my $string = (ref $_[0] ? $_[0] : \$_[0]) ; | ||||
463 | |||||
464 | $] >= 5.008 and (utf8::downgrade($$string, 1) | ||||
465 | or croak "Wide character in memGzip"); | ||||
466 | |||||
467 | IO::Compress::Gzip::gzip($string, \$out, Minimal => 1) | ||||
468 | or return undef ; | ||||
469 | |||||
470 | return $out; | ||||
471 | } | ||||
472 | |||||
473 | |||||
474 | sub _removeGzipHeader($) | ||||
475 | # spent 2.85ms (1.79+1.07) within Compress::Zlib::_removeGzipHeader which was called 50 times, avg 57µs/call:
# 50 times (1.79ms+1.07ms) by Compress::Zlib::memGunzip at line 541, avg 57µs/call | ||||
476 | 500 | 2.16ms | my $string = shift ; | ||
477 | |||||
478 | return Z_DATA_ERROR() | ||||
479 | if length($$string) < GZIP_MIN_HEADER_SIZE ; | ||||
480 | |||||
481 | 50 | 368µs | my ($magic1, $magic2, $method, $flags, $time, $xflags, $oscode) = # spent 368µs making 50 calls to Compress::Zlib::CORE:unpack, avg 7µs/call | ||
482 | unpack ('CCCCVCC', $$string); | ||||
483 | |||||
484 | 50 | 482µs | return Z_DATA_ERROR() # spent 419µs making 49 calls to Compress::Raw::Zlib::__ANON__[Compress/Raw/Zlib.pm:79], avg 9µs/call
# spent 62µs making 1 call to Compress::Raw::Zlib::AUTOLOAD | ||
485 | unless $magic1 == GZIP_ID1 and $magic2 == GZIP_ID2 and | ||||
486 | $method == Z_DEFLATED() and !($flags & GZIP_FLG_RESERVED) ; | ||||
487 | substr($$string, 0, GZIP_MIN_HEADER_SIZE) = '' ; | ||||
488 | |||||
489 | # skip extra field | ||||
490 | if ($flags & GZIP_FLG_FEXTRA) | ||||
491 | { | ||||
492 | return Z_DATA_ERROR() | ||||
493 | if length($$string) < GZIP_FEXTRA_HEADER_SIZE ; | ||||
494 | |||||
495 | my ($extra_len) = unpack ('v', $$string); | ||||
496 | $extra_len += GZIP_FEXTRA_HEADER_SIZE; | ||||
497 | return Z_DATA_ERROR() | ||||
498 | if length($$string) < $extra_len ; | ||||
499 | |||||
500 | substr($$string, 0, $extra_len) = ''; | ||||
501 | } | ||||
502 | |||||
503 | # skip orig name | ||||
504 | if ($flags & GZIP_FLG_FNAME) | ||||
505 | { | ||||
506 | my $name_end = index ($$string, GZIP_NULL_BYTE); | ||||
507 | return Z_DATA_ERROR() | ||||
508 | if $name_end == -1 ; | ||||
509 | substr($$string, 0, $name_end + 1) = ''; | ||||
510 | } | ||||
511 | |||||
512 | # skip comment | ||||
513 | if ($flags & GZIP_FLG_FCOMMENT) | ||||
514 | { | ||||
515 | my $comment_end = index ($$string, GZIP_NULL_BYTE); | ||||
516 | return Z_DATA_ERROR() | ||||
517 | if $comment_end == -1 ; | ||||
518 | substr($$string, 0, $comment_end + 1) = ''; | ||||
519 | } | ||||
520 | |||||
521 | # skip header crc | ||||
522 | if ($flags & GZIP_FLG_FHCRC) | ||||
523 | { | ||||
524 | return Z_DATA_ERROR() | ||||
525 | if length ($$string) < GZIP_FHCRC_SIZE ; | ||||
526 | substr($$string, 0, GZIP_FHCRC_SIZE) = ''; | ||||
527 | } | ||||
528 | |||||
529 | 50 | 214µs | return Z_OK(); # spent 198µs making 49 calls to Compress::Raw::Zlib::__ANON__[Compress/Raw/Zlib.pm:79], avg 4µs/call
# spent 17µs making 1 call to Compress::Raw::Zlib::AUTOLOAD | ||
530 | } | ||||
531 | |||||
532 | |||||
533 | sub memGunzip($) | ||||
534 | # spent 562ms (400+163) within Compress::Zlib::memGunzip which was called 50 times, avg 11.2ms/call:
# 50 times (400ms+163ms) by Cache::Memcached::__ANON__[/usr/share/perl5/Cache/Memcached.pm:714] at line 698 of Cache/Memcached.pm, avg 11.2ms/call | ||||
535 | # if the buffer isn't a reference, make it one | ||||
536 | 650 | 535ms | my $string = (ref $_[0] ? $_[0] : \$_[0]); | ||
537 | |||||
538 | 50 | 133µs | $] >= 5.008 and (utf8::downgrade($$string, 1) # spent 133µs making 50 calls to utf8::downgrade, avg 3µs/call | ||
539 | or croak "Wide character in memGunzip"); | ||||
540 | |||||
541 | 100 | 2.94ms | _removeGzipHeader($string) == Z_OK() # spent 2.85ms making 50 calls to Compress::Zlib::_removeGzipHeader, avg 57µs/call
# spent 86µs making 50 calls to Compress::Raw::Zlib::__ANON__[Compress/Raw/Zlib.pm:79], avg 2µs/call | ||
542 | or return undef; | ||||
543 | |||||
544 | my $bufsize = length $$string > 4096 ? length $$string : 4096 ; | ||||
545 | 100 | 24.2ms | my $x = new Compress::Raw::Zlib::Inflate({-WindowBits => - MAX_WBITS(), # spent 24.0ms making 50 calls to Compress::Raw::Zlib::Inflate::new, avg 481µs/call
# spent 183µs making 49 calls to Compress::Raw::Zlib::__ANON__[Compress/Raw/Zlib.pm:79], avg 4µs/call
# spent 14µs making 1 call to Compress::Raw::Zlib::AUTOLOAD | ||
546 | -Bufsize => $bufsize}) | ||||
547 | |||||
548 | or return undef; | ||||
549 | |||||
550 | my $output = "" ; | ||||
551 | 50 | 69.0ms | my $status = $x->inflate($string, $output); # spent 69.0ms making 50 calls to Compress::Raw::Zlib::inflateStream::inflate, avg 1.38ms/call | ||
552 | return undef | ||||
553 | 50 | 308µs | unless $status == Z_STREAM_END(); # spent 269µs making 49 calls to Compress::Raw::Zlib::__ANON__[Compress/Raw/Zlib.pm:79], avg 5µs/call
# spent 39µs making 1 call to Compress::Raw::Zlib::AUTOLOAD | ||
554 | |||||
555 | if (length $$string >= 8) | ||||
556 | { | ||||
557 | 50 | 148µs | my ($crc, $len) = unpack ("VV", substr($$string, 0, 8)); # spent 148µs making 50 calls to Compress::Zlib::CORE:unpack, avg 3µs/call | ||
558 | substr($$string, 0, 8) = ''; | ||||
559 | return undef | ||||
560 | 50 | 65.4ms | unless $len == length($output) and # spent 65.4ms making 50 calls to Compress::Raw::Zlib::crc32, avg 1.31ms/call | ||
561 | $crc == crc32($output); | ||||
562 | } | ||||
563 | else | ||||
564 | { | ||||
565 | $$string = ''; | ||||
566 | } | ||||
567 | return $output; | ||||
568 | } | ||||
569 | |||||
570 | # Autoload methods go after __END__, and are processed by the autosplit program. | ||||
571 | |||||
572 | 1 | 12µs | 1; | ||
573 | __END__ | ||||
sub Compress::Zlib::CORE:unpack; # opcode |