Brotli - new compression algorithm from Google

To install the utility for compression, need to clone the Brotli git repository:

git clone https://github.com/google/brotli.git

next, move to folder tools:

cd brotli/tools

and compile source code:

make

For convenience, let's copy our utility to a user binary folder:

cp bro /usr/local/sbin

And list of options:

bro [--force] [--quality n] [--decompress] [--input filename] [--output filename] [--repeat iters] [--verbose] [--window n]

Now it's time for tests in which I will compare Brotli with GZip by two parameters: result size and compression time.

Test 1. Compress the CSS file with higher compression quality

For the test, I chose the CSS file of Semantic UI CSS Framework

wget https://raw.githubusercontent.com/Semantic-Org/Semantic-UI/master/dist/semantic.min.css

brotli:

$ time bro --quality 11 --input semantic.min.css --output semantic.min.css.11.br
  real    0m1.109s
  user    0m1.076s
  sys    0m0.016s

gzip:

$ time gzip -9 -c -n semantic.min.css > semantic.min.css.9.gz
  real    0m0.026s
  user    0m0.024s
  sys    0m0.000s

P.S. Brotli compression range is from 1 to 11,  GZip - from 1 to 9.

Brotli is significantly slower then gzip :(

Result file size:

$ ls -l
-rw-r--r--  1 gulch     gulch     522321 Jan 24 18:28 semantic.min.css
-rw-------  1 gulch     gulch      69870 Jan 24 18:30 semantic.min.css.11.br
-rw-r--r--  1 gulch     gulch      88946 Jan 24 18:35 semantic.min.css.9.gz

Brotli - 13.38% of the original file size, gzip - 17.03%, difference - 3.65%

Test 2. Default compression quality

GZip default compression quality value is 5, Brotli - 6.

brotli:

$ time bro --quality 6 --input semantic.min.css --output semantic.min.css.6.br
  real    0m0.022s
  user    0m0.020s
  sys    0m0.000s

gzip:

$ time gzip -6 -c -n semantic.min.css > semantic.min.css.6.gz
  real    0m0.014s
  user    0m0.016s
  sys    0m0.000s

In this case, the time difference is not so significant.

$ ls -l
-rw-r--r--  1 gulch     gulch     522321 Jan 24 18:28 semantic.min.css
-rw-------  1 gulch     gulch      79737 Jan 24 18:50 semantic.min.css.6.br
-rw-r--r--  1 gulch     gulch      89480 Jan 24 18:51 semantic.min.css.6.gz

Brotli - 15.26% of the original file size, gzip - 17.13%, difference 1.87%

Interestingly, the difference between the size of the compressed file at 5 and 9 in gzip is negligible - 0.1%, then in brotli, the difference between 6 and 11 is 1.88%.

Useful links: