Created
March 20, 2015 20:29
-
-
Save koverholt/aef77398efc84de0b79a to your computer and use it in GitHub Desktop.
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
from __future__ import division | |
import bloscpack | |
import cPickle | |
import numpy as np | |
import timeit | |
x = np.empty(10000000) | |
# cPickle without protocol keyword argument | |
s = timeit.Timer('cPickle.dumps(x)', 'from __main__ import cPickle, x') | |
time = s.timeit(1) | |
speed = x.nbytes / 1e6 / time | |
print 'Time: %0.2e s; Speed: %0.2f MB/s' % (time, speed) | |
# cPickle with protocol keyword argument | |
s = timeit.Timer('cPickle.dumps(x, protocol=2)', 'from __main__ import cPickle, x') | |
time = s.timeit(1) | |
speed = x.nbytes / 1e6 / time | |
print 'Time: %0.2e s; Speed: %0.2f MB/s' % (time, speed) | |
# Using bloscpack (serialization library with compression) | |
s = timeit.Timer('bloscpack.pack_ndarray_str(x)', 'from __main__ import bloscpack, x') | |
time = s.timeit(1) | |
speed = x.nbytes / 1e6 / time | |
print 'Time: %0.2e s; Speed: %0.2f MB/s' % (time, speed) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment