12
def test(stmt, setup):
13
return timeit.repeat(stmt, setup, repeat=repeat, number=number)
24
if test_pyeigen and pyeigen is not None:
26
m1 = pyeigen.MatrixXf.random(1000, 1000)
27
m2 = pyeigen.MatrixXf.random(1000, 1000)
28
setup = "from __main__ import m1, m2"
30
print "Add:", test("m1 + m2", setup)
31
print "Matrix multiply:", test("m1 * m2", setup)
32
print "Scalar multiply:", test("m1 * 2.0", setup)
41
if test_numpy and numpy is not None:
43
m1 = numpy.matlib.rand((1000, 1000)).astype(numpy.float32)
44
m2 = numpy.matlib.rand((1000, 1000)).astype(numpy.float32)
45
setup = "from __main__ import m1, m2"
47
print "Add:", test("m1 + m2", setup)
48
print "Matrix multiply:", test("m1 * m2", setup)
49
print "Scalar multiply:", test("m1 * 2.0", setup)
52
if __name__ == "__main__":