[Scipy-svn] r5568 - in trunk/scipy/io/matlab: . benchmarks tests
scipy-svn at scipy.org
scipy-svn at scipy.org
Thu Feb 19 11:39:56 EST 2009
Author: matthew.brett at gmail.com
Date: 2009-02-19 10:39:48 -0600 (Thu, 19 Feb 2009)
New Revision: 5568
Added:
trunk/scipy/io/matlab/benchmarks/
trunk/scipy/io/matlab/benchmarks/bench_gzipstreams.py
Modified:
trunk/scipy/io/matlab/tests/test_mio.py
Log:
Added benchmarks
Added: trunk/scipy/io/matlab/benchmarks/bench_gzipstreams.py
===================================================================
--- trunk/scipy/io/matlab/benchmarks/bench_gzipstreams.py 2009-02-19 05:27:20 UTC (rev 5567)
+++ trunk/scipy/io/matlab/benchmarks/bench_gzipstreams.py 2009-02-19 16:39:48 UTC (rev 5568)
@@ -0,0 +1,38 @@
+
+from numpy.testing import *
+
+from cStringIO import StringIO
+from zlib import compress, decompress
+
+from numpy import linspace, inf
+from scipy.io.matlab.zlibstreams import ZlibInputStream, \
+ TwoShotZlibInputStream
+
+def print_header(klass):
+ print
+ print ' %s reading gzip streams' % klass
+ print '='*40
+ print 'time(s) | nbytes'
+ print '-'*40
+ print
+
+def bench_run():
+ test_sizes = [1e6, 5e6]
+ for klass in (ZlibInputStream, TwoShotZlibInputStream):
+ print_header(klass)
+ for size in test_sizes:
+ data = linspace(1, 100, num=size).astype('float32')
+ zdata = compress(data.tostring())
+ zstream = klass(StringIO(zdata), len(zdata))
+ read_time = measure('zstream.read()')
+ raw_read_time = measure('decompress(zdata)')
+ if raw_read_time > 0:
+ ratio = read_time / raw_read_time
+ else:
+ ratio = inf
+ print '%.3f | %.3f | %d' % (read_time,
+ read_time / raw_read_time,
+ data.nbytes)
+
+if __name__ == '__main__' :
+ run_module_suite()
Modified: trunk/scipy/io/matlab/tests/test_mio.py
===================================================================
--- trunk/scipy/io/matlab/tests/test_mio.py 2009-02-19 05:27:20 UTC (rev 5567)
+++ trunk/scipy/io/matlab/tests/test_mio.py 2009-02-19 16:39:48 UTC (rev 5568)
@@ -11,12 +11,11 @@
import warnings
import shutil
import gzip
-import copy
from numpy.testing import \
assert_array_almost_equal, \
assert_equal, \
- assert_raises, dec
+ assert_raises
from nose.tools import assert_true
@@ -197,7 +196,6 @@
'expected': {'testscalarobject': mlarr(1, dtype=object)}
})
'''
-
def types_compatible(var1, var2):
''' Check if types are same or compatible
@@ -260,6 +258,7 @@
# Something numeric
assert_array_almost_equal(actual, expected, err_msg=label, decimal=5)
+
def _load_check_case(name, files, case):
for file_name in files:
matdict = loadmat(file_name, struct_as_record=True)
@@ -269,6 +268,7 @@
assert_true(k in matdict, "Missing key at %s" % k_label)
_check_level(k_label, expected, matdict[k])
+
# Round trip tests
def _rt_check_case(name, expected, format):
mat_stream = StringIO()
@@ -410,6 +410,7 @@
assert_raises(ValueError, savemat, StringIO(),
{'longstruct': cell}, format='5', long_field_names=False)
+
def test_cell_with_one_thing_in_it():
# Regression test - make a cell array that's 1 x 2 and put two
# strings in it. It works. Make a cell array that's 1 x 1 and put
More information about the Scipy-svn
mailing list