Skip to content

Commit

Permalink
make benchmark easier to reproduce
Browse files Browse the repository at this point in the history
  • Loading branch information
mark committed Aug 22, 2017
1 parent fce492a commit c5d7d13
Show file tree
Hide file tree
Showing 5 changed files with 624 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
*~
*.png
*.json
cache/

6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ MatFile Matlab .mat file ☒ ☒ ☒ ☒ ☒ ☐ ☒ ☒ ☐
* + Rating refers to using a semi-popular package (probably scipy), as opposed to only python and numpy.
* ++ Very easy (☒☒☒) with an unpopular and/or dedicated package, but the rating refers to only python and numpy.

csv and NPY were done with `numpy`_; json was done with `pyjson_tricks`_; png was done with `imgarray`_; fortran unformatted was done with `fortranfile`_; matlab was done with `scipy`_; pickle, base64 and gzipping were done with python built-ins.
You can install all dependencies using `pip install -r rements.pip`. csv and NPY were done with `numpy`_; json was done with `pyjson_tricks`_; png was done with `imgarray`_; fortran unformatted was done with `fortranfile`_; matlab was done with `scipy`_; pickle, base64 and gzipping were done with python built-ins. `pandas`_ is needed for stata (not ready yet) statai files. Seaborn is needed for plotting. You can install all dependencies using `pip install requirements.pip`

Results
---------------------------------------
Expand All @@ -54,7 +54,7 @@ Sparse random matrix
Real data
=======================================

Scattering probabilities for hydrogen and carbon monoxide (many doubles between 0 and 1, most close to 0).
Scattering probabilities for hydrogen and carbon monoxide (many doubles between 0 and 1, most close to 0). You can easily overwrite this by your own file in `testdata.csv`.

.. image:: https://raw.githubusercontent.com/mverleg/array_storage_benchmark/master/result/bm_example.png

Expand All @@ -67,7 +67,7 @@ Pull requests with other methods (serious or otherwise) are welcome! There might
.. _`numpy`: https://docs.scipy.org/doc/numpy/reference/generated/numpy.loadtxt.html
.. _`pyjson_tricks`: https://github.com/mverleg/pyjson_tricks
.. _`imgarray`: https://github.com/mverleg/imgarray
.. _`fortranfile_`: https://pypi.python.org/pypi/fortranfile/0.2.1
.. _`fortranfile`: https://pypi.python.org/pypi/fortranfile/0.2.1
.. _`scipy`: https://docs.scipy.org/doc/scipy-0.18.1/reference/generated/scipy.io.loadmat.html#scipy.io.loadmat


8 changes: 1 addition & 7 deletions benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ def __init__(self, cls, data, data_name=None, reps=50):
@property
def save_time(self):
assert self.done
# mn, mx, st = mean(tuple(inst.save_time for inst in self.done)), max(tuple(inst.save_time for inst in self.done)), std(tuple(inst.save_time for inst in self.done))
# if mx > 2 * mn: #todo
# print('max', self.cls.__name__, mn, mx)
# if st > 0.2 * mn:
# print('std', self.cls.__name__, mn, st)
return mean(tuple(inst.save_time for inst in self.done))

@property
Expand Down Expand Up @@ -94,14 +89,13 @@ def random_data(size, is_sparse=False, is_big=True):
else:
arr = rs.rand(*size).astype('float64')
if is_big:
# arr = (2 * arr - 1) * 1.7976931348623157e+308
# don't use the full range, since some formats (Stata) uses the highest values for special meanings.
arr = (arr - 0.5) * 1.7976931348623157e+308
return arr


def load_example_data():
return loadtxt(join(environ['HOME'], 'testdata.csv'), delimiter=',')
return loadtxt('testdata.csv', delimiter=',')


if __name__ == '__main__':
Expand Down
9 changes: 9 additions & 0 deletions requirements.pip
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
numpy
scipy
json-tricks
imgarray
fortranfile
matplotlib
seaborn
pandas

Loading

0 comments on commit c5d7d13

Please sign in to comment.