Help us understand the problem. What is going on with this article?

gzipの各圧縮レベルでの圧縮率と処理時間の計測

More than 1 year has passed since last update.

gzipの各圧縮レベルでの圧縮率と処理時間の計測

Apache の mod_deflate で DeflateCompressionLevel を調整するにあたり、gzipで各圧縮レベルでの圧縮率と処理時間を調べました。

結果

圧縮率を指定しない場合は 6 が選択されるようです。

レベル サイズ(Byte) 圧縮率 10,000回圧縮時の
処理時間
6とのサイズ比 6とのサイズ差
無圧縮 58,757 - - - -
1 12,377 78.94% 0m23.328s 1.17 1,769
2 11,979 79.61% 0m27.751s 1.13 1,371
3 11,757 79.99% 0m36.023s 1.11 1,149
4 11,076 81.15% 0m43.181s 1.04 468
5 10,771 81.67% 0m43.981s 1.02 163
6(デフォルト) 10,608 81.95% 0m44.991s 1.00 0
7 10,575 82.00% 0m46.586s 1.00 -33
8 10,519 82.10% 0m54.098s 0.99 -89
9 10,480 82.16% 1m03.603s 0.99 -128

1か2が良さそうですね。

サンプルファイル

とあるサイトのトップページ(58,757Byte)

環境

CPU: Core2Duo E8400 3.0GHz
MEM: 5GB
OS: Ubuntu 14.04 32bit

コマンド

それぞれの圧縮レベルで10,000回圧縮した時にかかった時間をtimeコマンドで計測。
timeコマンドのreal値を取りました。

$ for rate in $(seq 1 9) ; do echo "rate ${rate}"; time for i in $(seq 1 10000) ; do gzip -c -${rate} index.html > /dev/null ; done; echo ""; sleep 10; done

読みやすくしてみました。下は試してないので間違ってるかも

$ for rate in $(seq 1 9)
do
  echo "rate ${rate}"
  time for i in $(seq 1 10000) ; \
      do gzip -c -${rate} index.html > /dev/null ; \
    done;
  echo ""
  sleep 10
done
Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away