Created
January 30, 2017 20:58
-
-
Save itdaniher/1586f89c859fb92f772f7f4c8ec17c98 to your computer and use it in GitHub Desktop.
python-blosc / python-lz4 profiling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import uuid | |
import timeit | |
import lz4 | |
import os | |
from timeit import Timer | |
import sys | |
import blosc | |
DATA = open(sys.argv[1], "rb").read() | |
LZ4_DATA = lz4.block.compress(DATA) | |
BLOSC_DATA = blosc.compress(DATA, cname='lz4', clevel=5, shuffle=True) | |
LOOPS = 100 | |
print("Data Size:") | |
print(" Input: %d" % len(DATA)) | |
print(" LZ4: %d (%.2f)" % (len(LZ4_DATA), len(LZ4_DATA) / float(len(DATA)))) | |
print(" Blosc: %d (%.2f)" % (len(BLOSC_DATA), len(BLOSC_DATA) / float(len(DATA)))) | |
print(" LZ4 / Blosc: %f" % (float(len(LZ4_DATA)) / float(len(BLOSC_DATA)))) | |
print("Benchmark: %d calls" % LOOPS) | |
print(" LZ4 Compression: %fs" % (Timer("lz4.block.compress(DATA)", "from __main__ import DATA; import lz4").timeit(number=LOOPS)/LOOPS)) | |
print(" Blosc Compression: %fs" % (Timer("blosc.compress(DATA, cname='lz4', clevel=5, shuffle=True)", "from __main__ import DATA; import blosc").timeit(number=LOOPS)/LOOPS)) | |
print(" LZ4 Decompression: %fs" % (Timer("lz4.block.decompress(LZ4_DATA)", "from __main__ import LZ4_DATA; import lz4").timeit(number=LOOPS)/LOOPS)) | |
print(" Blosc Decompression : %fs" % (Timer("blosc.decompress(BLOSC_DATA)", "from __main__ import BLOSC_DATA; import blosc").timeit(number=LOOPS)/LOOPS)) |
Author
itdaniher
commented
Jan 30, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment