python 速度 memmap_使用python测量文件的读写速度
我目前正在使用python來讀寫大型圖像(使用OpenCV和numpy的memmap函數)。具體地說,我正在制作圖像金字塔。在
在python中,可以監視文件的當前讀寫速度嗎?一、 e.類似移動平均值(MB/秒)。在
我不認為這很重要,但我的代碼中最重要的部分是:for y in range(ysize):
#Open a previously defined temp image file
bigIMG = np.memmap('tempfile.bin', dtype='uint8', mode='r+', shape=(ysize,xsize,3))
#Grap a chunk of the full image, save it, shrink it,
#and put it into the next lower level of the pyramid
for x in range(xsize):
chunk = bigIMG[y*block:(y+1)*block,x*block:(x+1)*block]
cv2.imwrite('+str(x)+"_"+str(y)+".png",chunk)
down = cv2.resize(chunk,None,fx=0.5, fy=0.5, interpolation = cv2.INTER_LINEAR)
smallerIMG[(y*block)/2:((y+1)*block)/2,(x*block)/2:((x+1)*block)/2] = down
#Flush changes to HDD
del smallerIMG
如你所見,我正在從硬盤上寫和讀很多數據,我想監控這些操作的性能。在
謝謝!在
總結
以上是生活随笔為你收集整理的python 速度 memmap_使用python测量文件的读写速度的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 正则不能全为某个值_TensorFlow
- 下一篇: websocket python爬虫_p