Skip to content

Instantly share code, notes, and snippets.

@lesteve
Created March 11, 2015 09:22
Show Gist options
  • Save lesteve/f85bdee54e582165b40f to your computer and use it in GitHub Desktop.
Save lesteve/f85bdee54e582165b40f to your computer and use it in GitHub Desktop.
joblib simple benchmark
import time
import sys
import numpy as np
np.random.seed(0)
N = int(1e7)
big_array = np.random.random(N)
big_dict = {i: np.random.random(10) for i in range(int(1e5))}
def test(joblib_module, to_pickle):
tic = time.time()
joblib_module.dump(to_pickle, '/tmp/big_array.gz', compress=1)
toc = time.time()
print('Dumping took {:.1f} s'.format(toc - tic))
tic = time.time()
joblib_module.load('/tmp/big_array.gz')
toc = time.time()
print('Loading took {:.1f} s'.format(toc - tic))
def test_harness(joblib):
print('=' * 80)
print('joblib file:', joblib.__file__)
print('-' * 20)
print('big array')
test(joblib, big_array)
print('-' * 20)
print('big dict')
test(joblib, big_dict)
from sklearn.externals import joblib as joblib_stable
import joblib as joblib_dev
print('Python: {0[0]}.{0[1]}'.format(sys.version_info))
test_harness(joblib_stable)
test_harness(joblib_dev)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment