G-zip, does compression level matter?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Spaceman-Spiff
Forum Newbie
Posts: 8
Joined: Wed Nov 06, 2002 2:46 am

G-zip, does compression level matter?

Post by Spaceman-Spiff »

When using g-zip compression in gzcompress() function, we can select the compression level. I know its a trade-off between speed & server usage and output filesize. The question is, is there a significant difference in the filesize between level 9 and level 1 when using g-zip for HTML files?
I've read a few tutorials on g-zip, but none mentioned about the difference in compression level besides 9 = maximum compression level and 0 = none.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

imho the standard level is quite fine for text/html.
Spaceman-Spiff
Forum Newbie
Posts: 8
Joined: Wed Nov 06, 2002 2:46 am

Post by Spaceman-Spiff »

by standard, u mean level 5?
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post by BDKR »

Are you using a Linux box? If so, you could just as easily do a little testing yourself. Just create a file or take an existing one and compress it at the various levels and check the resulting sizes.

Cheers,
BDKR
User avatar
mydimension
Moderator
Posts: 531
Joined: Tue Apr 23, 2002 6:00 pm
Location: Lowell, MA USA
Contact:

Post by mydimension »

any where between 3 and 5 gives you pretty good results and the difference between those is pretty small.
Spaceman-Spiff
Forum Newbie
Posts: 8
Joined: Wed Nov 06, 2002 2:46 am

Post by Spaceman-Spiff »

i did a little test, if anyone interested:

File: mysql manual
Size: 2.5 MB
Type: html

Image

conclusion: use default (level 5 or 6)
Last edited by Spaceman-Spiff on Sat Aug 23, 2003 3:28 pm, edited 1 time in total.
User avatar
mydimension
Moderator
Posts: 531
Joined: Tue Apr 23, 2002 6:00 pm
Location: Lowell, MA USA
Contact:

Post by mydimension »

hmm, pretty useful. thanx for that. although do remember that compression also is affected by the actual structure of the document, regardless of its size. sometimes the copression algoithim fits the contents nicely, other times not so nice. the differnece is almost negligable but i feel its needs pointing out next to a one time case study such as yours.
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post by BDKR »

Good show!
Post Reply