apppublic/test/brotli_test.py

15 lines
281 B
Python
Raw Normal View History

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