comparison test_dataset.py @ 250:474be3d12c23

make test_speed generic
author Frederic Bastien <bastienf@iro.umontreal.ca>
date Tue, 03 Jun 2008 12:18:22 -0400
parents 0fb75fdd727d
children bf0a1ebc6e52
comparison
equal deleted inserted replaced
247:9502f100eda5 250:474be3d12c23
491 def test_ArrayFieldsDataSet(): 491 def test_ArrayFieldsDataSet():
492 print "test_ArrayFieldsDataSet" 492 print "test_ArrayFieldsDataSet"
493 raise NotImplementedError() 493 raise NotImplementedError()
494 494
495 495
496 def test_speed(): 496 def test_speed(array, ds):
497 print "test_speed" 497 print "test_speed", ds.__class__
498 import time 498
499 a2 = numpy.random.rand(100000,400)
500 ds = ArrayDataSet(a2,{'all':slice(0,a2.shape[1],1)})
501 mat = numpy.random.rand(400,100) 499 mat = numpy.random.rand(400,100)
500
502 @print_timing 501 @print_timing
503 def f_array_full(a): 502 def f_array_full(a):
504 a+1 503 a+1
505 @print_timing 504 @print_timing
506 def f_array_index(a): 505 def f_array_index(a):
538 for exs in ds.minibatches(minibatch_size = mb_size): 537 for exs in ds.minibatches(minibatch_size = mb_size):
539 # pass 538 # pass
540 exs[0]+1 539 exs[0]+1
541 # ex[0]*mat 540 # ex[0]*mat
542 541
543 f_array_full(a2) 542 f_array_full(array)
544 f_array_index(a2) 543 f_array_index(array)
545 f_array_iter(a2) 544 f_array_iter(array)
546 545
547 f_ds_index(ds) 546 f_ds_index(ds)
548 f_ds_iter(ds) 547 f_ds_iter(ds)
549 548
550 f_ds_mb1(ds,10) 549 f_ds_mb1(ds,10)
554 f_ds_mb2(ds,10) 553 f_ds_mb2(ds,10)
555 f_ds_mb2(ds,100) 554 f_ds_mb2(ds,100)
556 f_ds_mb2(ds,1000) 555 f_ds_mb2(ds,1000)
557 f_ds_mb2(ds,10000) 556 f_ds_mb2(ds,10000)
558 557
559 del a2, ds
560 558
561 if __name__=='__main__': 559 if __name__=='__main__':
562 test1() 560 test1()
563 test_LookupList() 561 test_LookupList()
564 test_ArrayDataSet() 562 test_ArrayDataSet()