Skip to content

Instantly share code, notes, and snippets.

@itdaniher
Created January 30, 2017 20:58
Show Gist options
  • Save itdaniher/1586f89c859fb92f772f7f4c8ec17c98 to your computer and use it in GitHub Desktop.
Save itdaniher/1586f89c859fb92f772f7f4c8ec17c98 to your computer and use it in GitHub Desktop.
python-blosc / python-lz4 profiling
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))
@itdaniher
Copy link
Author

Data Size:
  Input: 1441872
  LZ4: 401372 (0.28)
  Blosc: 411538 (0.29)
  LZ4 / Blosc: 0.975298
Benchmark: 100 calls
  LZ4 Compression: 0.012510s
  Blosc Compression: 0.010122s
  LZ4 Decompression: 0.015490s
  Blosc Decompression : 0.011054s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment