Author: bugman Date: Wed Jul 9 10:59:03 2014 New Revision: 24486 URL: http://svn.gna.org/viewcvs/relax?rev=24486&view=rev Log: Added a timeit script and log file showing how numpy.cos() is 10 times slower than math.cos(). This is for single floats. Added: branches/frame_order_cleanup/test_suite/shared_data/frame_order/timings/numpy_vs_math.log branches/frame_order_cleanup/test_suite/shared_data/frame_order/timings/numpy_vs_math.py Added: branches/frame_order_cleanup/test_suite/shared_data/frame_order/timings/numpy_vs_math.log URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/test_suite/shared_data/frame_order/timings/numpy_vs_math.log?rev=24486&view=auto ============================================================================== --- branches/frame_order_cleanup/test_suite/shared_data/frame_order/timings/numpy_vs_math.log (added) +++ branches/frame_order_cleanup/test_suite/shared_data/frame_order/timings/numpy_vs_math.log Wed Jul 9 10:59:03 2014 @@ -0,0 +1,2 @@ +Timing (s): 1.40798211098 +Timing (s): 10.9347679615 Added: branches/frame_order_cleanup/test_suite/shared_data/frame_order/timings/numpy_vs_math.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/test_suite/shared_data/frame_order/timings/numpy_vs_math.py?rev=24486&view=auto ============================================================================== --- branches/frame_order_cleanup/test_suite/shared_data/frame_order/timings/numpy_vs_math.py (added) +++ branches/frame_order_cleanup/test_suite/shared_data/frame_order/timings/numpy_vs_math.py Wed Jul 9 10:59:03 2014 @@ -0,0 +1,23 @@ +# Python module imports. +import math +import numpy +from timeit import timeit + + +def test_math(N=1): + for i in range(N): + math.cos(0.1) + +def test_numpy(N=1): + for i in range(N): + numpy.cos(0.1) + + +N = 10000 +M = 1000 +if __name__ == '__main__': + test_math(N=1) + print("Timing (s): %s" % timeit("test_math(N=N)", setup="from numpy_vs_math import math, test_math, N", number=M)) + + test_numpy(N=1) + print("Timing (s): %s" % timeit("test_numpy(N=N)", setup="from numpy_vs_math import numpy, test_numpy, N", number=M))