10w左右数据量,不加jit效率高,
100w左右数据量,加了jit效果高8倍以上
40w左右数据量,效率持平
from numba import jit from numpy import arange import datetime len=399999 @jit def sumjit(arr): M, N = arr.shape result = 0.0 for i in range(M): for j in range(N): result += arr[i, j] return result a = arange(len).reshape(len//3, 3) start = datetime.datetime.now() print(sumjit(a)) print ("jit",(datetime.datetime.now()-start).microseconds) def sum2d(arr): M, N = arr.shape result = 0.0 for i in range(M): for j in range(N): result += arr[i, j] return result a = arange(len).reshape(len//3, 3) start = datetime.datetime.now() print(sum2d(a)) print ("noj",(datetime.datetime.now()-start).microseconds)