Bug #13860: Bzip2 bzdecompress function is wery slow...
| From: | mcdouglas at angelfire dot com | Date: | Sun, 28 Oct 2001 20:34:20 +0000 |
| Subject: | Bug #13860: Bzip2 bzdecompress function is wery slow... | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-69213@lists.php.net to get a copy of this message | ||
From: mcdouglas@angelfire.com
Operating system: Windows 98 SE
PHP version: 4.0.6
PHP Bug Type: Bzip2 Related
Bug description: Bzip2 bzdecompress function is wery slow...
I made a little decompresser script:
<?php
$efilename = "d:/pic.bz2"; //A compressed jpg image ( original size:
388kbyte, packed size: 388kbyte)
$ufilename2 = "d:/pic.jpg";
$fp = fopen($efilename, "rb");
$ecd_cont = fread($fp, filesize($efilename)); //read the compressed data
from file
fclose($fp);
$fp = fopen($ufilename2,"wb");
$ecd_cont = bzdecompress($ecd_cont,1); //decompress the readed compressed
data
fwrite($fp, $ecd_cont); //write the decompressed data into file
fclose($fp);
echo "<img src=\"file://d:\\pic.jpg\">";
?>
Ok, this is work... But it is WERY WERY slow!!! It's take 60sec to display
the decompressed image, why??
I made the decompression befor with an other method:
<?php
$efilename = "d:/pic.bz2";
$ufilename2 = "d:/pic.jpg";
$bz = bzopen($efilename, "rb");
$ecd_cont = bzread($bz, 400000); // See below
bzlose($bz);
$fp = fopen($ufilename2,"wb");
fwrite($fp, $ecd_cont);
fclose($fp);
echo "<img src=\"file://d:\\pic.jpg\">";
?>
Ok this is working (And this is fast! The decompressed picture appears
immediately), but there is a little problem:
In the PHP manual I read this about the bzread() function:
"If the optional parameter length is not
specified, bzread() will read 1024 (uncompressed) bytes at a time."
Ok, so it will read 1024 uncompressed bytes from my compressed file, if I
not give the lenght parameter (as I did in the example). But there is a
problem: if I want to be precise then I must give the lenght of the
original file, but how??? I only have the compressed file, which is not
equal with the original (ok, in my example it is, but only because the
original jpg-compressed file), so I cant use the filesize() function,
because it gave only the compressed filesize, neither the strlen() because
I havnt got a string yet :)
And I think you agree with me if I dont want to write 400Mbyte to
parameter... this is not a correct solution. I think the correct solution
if the bzread() function is read the entire file if I dont give the lenght
parameter.
--
Edit bug report at: http://bugs.php.net/?id=13860&edit=1