apppublic/test/brotli_test.py

15 lines
281 B
Python
Raw Normal View History

2021-07-13 16:14:20 +08:00
import sys
from brotli import compress, decompress
2021-07-14 12:33:53 +08:00
import zlib
2021-07-13 16:14:20 +08:00
def do(fn):
with open(fn, 'rb') as f:
b = f.read()
c = compress(b)
2021-07-14 12:33:53 +08:00
zc = zlib.compress(b)
2021-07-13 16:14:20 +08:00
print(fn,'\t',
2021-07-14 12:33:53 +08:00
float(len(c))/float(len(b)), float(len(zc))/float(len(b)))
2021-07-13 16:14:20 +08:00
fns = sys.argv[1:]
for fn in fns:
do(fn)