I'm currently trying to improve python/openCV performances using tmpfs, as i'm stuck around 5-10 FPS while trying to record a USB camera on a raspberry Pi 3, at 640x480.
On my system, i get these raw write transfer rates, using dd command: SD Card : 2.5Mo/s tmpfs : 380 Mo/s
Sadly, when writing my opencv video file on a tmpfs folder, i didn't get any improvement. Here is my benchmark code :
import cv2
import numpy as np
import time
x = np.random.randint(255, size=(480, 640,3)).astype('uint8')
writer1 = cv2.VideoWriter('/home/pi/testDX1.avi',cv2.cv.CV_FOURCC('D','X','5','0'), 10, (640, 480), True)
ctime=time.time()
for i in range(250):
writer1.write(x)
writer1.release()
print("SDCard took : "+`time.time()-ctime`)
writer2 = cv2.VideoWriter('/var/tmp/testDX2.avi',cv2.cv.CV_FOURCC('D','X','5','0'), 10, (640, 480), True)
ctime=time.time()
for i in range(250):
writer2.write(x)
writer2.release()
print("tmpfs took : "+`time.time()-ctime`)
It gives :
SDCard took : 8.289990901947021 tmpfs took : 8.240657806396484
The tmpfs is well enabled, as stated by mount command :
mount | grep "/var/tmp"
gives tmpfs on /var/tmp type tmpfs (rw,nosuid,nodev,relatime)
mount | grep "/ "
gives /dev/mmcblk0p2 on / type ext4 (rw,noatime,data=ordered)
Did someone know why tmfs isn't improving write speed ?