Comparing gzcompress/gzuncompress and bzcompress/bzdecompress, the bz combo is about 5x slower than gz.(PHP 4 >= 4.0.4, PHP 5, PHP 7, PHP 8)
bzcompress β Π‘ΠΆΠΈΠΌΠ°Π΅Ρ ΡΡΡΠΎΠΊΡ Ρ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΠ΅ΠΌ bzip2
bzcompress() ΡΠΆΠΈΠΌΠ°Π΅Ρ ΠΏΠ΅ΡΠ΅Π΄Π°Π½Π½ΡΡ ΡΡΡΠΎΠΊΡ ΠΈ Π²ΠΎΠ·Π²ΡΠ°ΡΠ°Π΅Ρ Π΅Ρ Π² Π²ΠΈΠ΄Π΅ Π·Π°ΠΊΠΎΠ΄ΠΈΡΠΎΠ²Π°Π½Π½ΡΡ Π΄Π°Π½Π½ΡΡ bzip2.
datablock_sizework_factorwork_factor
ΠΈ ΡΠ²Π»ΡΠ΅ΡΡΡ ΠΎΠ΄Π½ΠΈΠΌ ΠΈ ΡΠ΅ΠΌ ΠΆΠ΅.
Π‘ΠΆΠ°ΡΠ°Ρ ΡΡΡΠΎΠΊΠ° ΠΈΠ»ΠΈ ΠΊΠΎΠ΄ ΠΎΡΠΈΠ±ΠΊΠΈ Π² ΡΠ»ΡΡΠ°Π΅ Π½Π΅ΡΠ΄Π°ΡΠ½ΠΎΠ³ΠΎ Π·Π°Π²Π΅ΡΡΠ΅Π½ΠΈΡ ΡΠ°Π±ΠΎΡΡ.
ΠΡΠΈΠΌΠ΅Ρ #1 Π‘ΠΆΠ°ΡΠΈΠ΅ Π΄Π°Π½Π½ΡΡ
<?php
$str = "sample data";
$bzstr = bzcompress($str, 9);
echo $bzstr;
?>Comparing gzcompress/gzuncompress and bzcompress/bzdecompress, the bz combo is about 5x slower than gz.The blocksize parameter tells bzip to use 100 000 Byte * blocksize blocks to compress the string. In the example above we can see the output size and time needed of bz[2] to bz[9] are nearly the same, because there ware just 189 058 Byte of data to compress and in this case bz[2] to bz[9] means "compress all data et once".
So we may notice a bigger difference in speed and compression rate with bigger files.
the workfactor parameter sets, how fast bzip switches in the slower fallback algorithm, if the standard algorithm gets problems with much repetitive data. 0 means, bzip uses the default value of 30. This option is recommend.
For more information about the parameter look at http://www.bzip.org/1.0.3/html/low-level.html#bzcompress-init