我希望尽可能地提高响应速度,并测试我的绘图功能,它花费2.9~3.2秒。
任何提高速度的技巧,从算法,程序,网站设计…
“用户单击绘图按钮”和“在浏览器中显示图片”之间的时间太长,使用python和django,如何缩短时间?提前谢谢。
load 1.999396
angle2plane 3.0000000000196536e-05
getPoint 7.000000000090267e-06
getGrid 0.003222000000000058
D2MapD3 0.584085
getValue 0.032258999999999816
show 0.35327399999999987
total 2.982803
beg=time.clock()
ds=loadArray(filepath, (110,110,187))
end=time.clock()
print("load", str(end-beg))
ds=np.clip(ds, 0, 1)
print("alpha, beta, gamma:", alpha, beta, gamma)
beg=time.clock()
plane=angle2plane(alpha, beta, gamma, dis)
end=time.clock()
print("angle2plane", str(end-beg))
beg=time.clock()
A, B, C=getPoint(plane)
end=time.clock()
print("getPoint", str(end-beg))
beg=time.clock()
grid=getGrid(width, height)
end=time.clock()
print("getGrid", str(end-beg))
rowgrid=len(grid)
colgrid=len(grid[0])
beg=time.clock()
mpmatrix=D2MapD3(A, B, C, grid)
end=time.clock()
beg=time.clock()
values=getValue(mpmatrix, ds, width, height)
end=time.clock()
print("getValue", str(end-beg))
values=values.reshape(rowgrid, colgrid)
beg=time.clock()
plt.imshow(values)
plt.savefig("test.png")
end=time.clock()
print("show", str(end-beg))