Last active
December 15, 2015 21:29
-
-
Save esc/5326039 to your computer and use it in GitHub Desktop.
Benchmarking two techniques for compressing numpy arrays with python-blosc.
This file contains hidden or 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
""" Benchmarking two techniques for compressing numpy arrays with python-blosc. | |
""" | |
import numpy | |
import numpy.random | |
import time | |
import blosc | |
import blosc.blosc_extension as ext | |
in_ = numpy.arange(3e7) | |
print in_ | |
tic = (time.time()) | |
c = blosc.pack_array(in_) | |
out = blosc.unpack_array(c) | |
assert((in_ == out).all()) | |
toc = (time.time()) | |
print toc-tic | |
tic = (time.time()) | |
c = ext.compress_ptr(in_.__array_interface__['data'][0], | |
in_.size*in_.dtype.itemsize, | |
in_.dtype.itemsize, 9, True) | |
out = numpy.empty(in_.size, dtype=in_.dtype) | |
d = ext.decompress_ptr(c, out.__array_interface__['data'][0]) | |
assert((in_ == out).all()) | |
assert(d == in_.size*in_.dtype.itemsize) | |
toc = (time.time()) | |
print toc-tic | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment