# HG changeset patch # User Frederic Bastien # Date 1212690546 14400 # Node ID 6255359318bfb28afe3516278ccfa1f1029dd6a4 # Parent 271a16d4207237cce4d74555f9bffa7f2646844a moved test_speed() in its own file diff -r 271a16d42072 -r 6255359318bf test_dataset.py --- a/test_dataset.py Thu Jun 05 14:16:46 2008 -0400 +++ b/test_dataset.py Thu Jun 05 14:29:06 2008 -0400 @@ -476,74 +476,10 @@ raise NotImplementedError() -def test_speed(array, ds): - print "test_speed", ds.__class__ - - mat = numpy.random.rand(400,100) - - @print_timing - def f_array_full(a): - a+1 - @print_timing - def f_array_index(a): - for id in range(a.shape[0]): -# pass - a[id]+1 -# a[id]*mat - @print_timing - def f_array_iter(a): - for r in a: -# pass - r+1 -# r*mat - @print_timing - def f_ds_index(ds): - for id in range(len(ds)): -# pass - ds[id][0]+1 -# ds[id][0]*mat - @print_timing - def f_ds_iter(ds): - for ex in ds: -# pass - ex[0]+1 -# a[0]*mat - @print_timing - def f_ds_mb1(ds,mb_size): - for exs in ds.minibatches(minibatch_size = mb_size): - for ex in exs: -# pass - ex[0]+1 -# ex[0]*mat - @print_timing - def f_ds_mb2(ds,mb_size): - for exs in ds.minibatches(minibatch_size = mb_size): -# pass - exs[0]+1 -# ex[0]*mat - - f_array_full(array) - f_array_index(array) - f_array_iter(array) - - f_ds_index(ds) - f_ds_iter(ds) - - f_ds_mb1(ds,10) - f_ds_mb1(ds,100) - f_ds_mb1(ds,1000) - f_ds_mb1(ds,10000) - f_ds_mb2(ds,10) - f_ds_mb2(ds,100) - f_ds_mb2(ds,1000) - f_ds_mb2(ds,10000) - - if __name__=='__main__': test1() test_ArrayDataSet() test_CachedDataSet() test_ApplyFunctionDataSet() - #test_speed() #test pmat.py diff -r 271a16d42072 -r 6255359318bf test_speed.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test_speed.py Thu Jun 05 14:29:06 2008 -0400 @@ -0,0 +1,79 @@ +import numpy +from dataset import * +from misc import * +def test_speed(array, ds): + print "test_speed", ds.__class__ + + mat = numpy.random.rand(400,100) + + @print_timing + def f_array_full(a): + a+1 + @print_timing + def f_array_index(a): + for id in range(a.shape[0]): +# pass + a[id]+1 +# a[id]*mat + @print_timing + def f_array_iter(a): + for r in a: +# pass + r+1 +# r*mat + @print_timing + def f_ds_index(ds): + for id in range(len(ds)): +# pass + ds[id][0]+1 +# ds[id][0]*mat + @print_timing + def f_ds_iter(ds): + for ex in ds: +# pass + ex[0]+1 +# a[0]*mat + @print_timing + def f_ds_mb1(ds,mb_size): + for exs in ds.minibatches(minibatch_size = mb_size): + for ex in exs: +# pass + ex[0]+1 +# ex[0]*mat + @print_timing + def f_ds_mb2(ds,mb_size): + for exs in ds.minibatches(minibatch_size = mb_size): +# pass + exs[0]+1 +# ex[0]*mat + + f_array_full(array) + f_array_index(array) + f_array_iter(array) + + f_ds_index(ds) + f_ds_iter(ds) + + f_ds_mb1(ds,10) + f_ds_mb1(ds,100) + f_ds_mb1(ds,1000) + f_ds_mb1(ds,10000) + f_ds_mb2(ds,10) + f_ds_mb2(ds,100) + f_ds_mb2(ds,1000) + f_ds_mb2(ds,10000) + +if __name__=='__main__': + a2 = numpy.random.rand(100000,400) + ds1 = ArrayDataSet(a2,{'all':slice(0,a2.shape[1],1)}) + test_speed(a2,ds1) + a1 = numpy.random.rand(100000,40) + ds4 = ArrayDataSet(a1,LookupList(["f"+str(x)for x in range(a1.shape[1])], + range(a1.shape[1]))) + test_speed(a2,ds4) + ds2=CachedDataSet(ds1,cache_all_upon_construction=False) + test_speed(a2,ds2) + ds3=CachedDataSet(ds1,cache_all_upon_construction=True) + test_speed(a2,ds3) + del a2,ds1,ds2,ds3 +